Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[assertj] initial framework.dto #375

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

stbischof
Copy link
Contributor

TODO:

  • Predicated
  • Conditions
  • more convenient assertions
  • tests

Copy link
Contributor

@kriegfrj kriegfrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start!


// null safe check
String actualSymbolicName = actual.symbolicName;
if (!java.util.Objects.deepEquals(actualSymbolicName, symbolicName)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need a deep equals here as it's a string and not a complicated object with deep nested hierarchy. Regular equals would be fine (that's what BundleAssert does).


// null safe check
String actualVersion = actual.version;
if (!java.util.Objects.deepEquals(actualVersion, version)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equals() is sufficient.

Comment on lines +47 to +48
Iterables.instance()
.assertContains(info, actual.bundles, bundles);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best to steer clear of Iterables - it is in an AssertJ internal package.

Comment on lines +78 to +79
Iterables.instance()
.assertContains(info, actual.bundles, bundles.toArray());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steer clear of Iterables.

Comment on lines +106 to +107
Iterables.instance()
.assertContainsOnly(info, actual.bundles, bundles);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steer clear of Iterables.

* Abstract base class for {@link BundleDTO} specific assertions
*/

public abstract class AbstractBundleDTOAssert<S extends AbstractBundleDTOAssert<S, A>, A extends BundleDTO>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of the assertion implementation here could be cut-and-pasted from AbstractBundleAssert, because they have the same fields. I think this would give a more consistent user experience rather than rolling our own (slightly different) ones from scratch. Maybe even think of a way that they could share code.

* @throws AssertionError - if the actual BundleDTO's state is not equal to
* the given one.
*/
public S hasState(int state) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bitmapped field. Having the extra bitmap functionality that AbstractBundleAssert has would make for more user-friendly usage. This is especially the case for the failure message: the code as written will report something like:

Expected:
 <4>
but was:
 <2>

Whereas the AbstractBundleAssert implementation gives you something more human-readable like:

Expected:
 <4:RESOLVED>
but was:
 <2:INSTALLED>

* Abstract base class for {@link ServiceReferenceDTO} specific assertions
*/

public abstract class AbstractServiceReferenceDTOAssert<S extends AbstractServiceReferenceDTOAssert<S, A>, A extends ServiceReferenceDTO>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, try and keep this consistent with AbstractServiceReferenceAssert.

@@ -0,0 +1,215 @@
package org.osgi.test.assertj.servicereference;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package org.osgi.test.assertj.dto.servicereference;

@@ -0,0 +1,459 @@
package org.osgi.test.assertj.framework;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package org.osgi.test.assertj.framework.dto;

@kriegfrj
Copy link
Contributor

Note: @stbischof, because your PR is still marked as draft, I have not made this review very thorough. These were mostly some high-level comments to help push you in the right direction before you invest too much time. Hope it helps!

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be closed if no further activity occurs. If you intend to work on this pull request, please reopen the PR. Thank you for your contributions.

@github-actions github-actions bot added the stale label Oct 20, 2022
@github-actions
Copy link

This pull request has been automatically closed due to inactivity. If you are still interested in contributing this, please ensure that it is rebased against the latest main branch, all review comments have been addressed and the build is passing.

@github-actions github-actions bot closed this Nov 11, 2022
@stbischof
Copy link
Contributor Author

@timothyjward

Could you reopen this?

@timothyjward timothyjward reopened this Feb 7, 2024
@github-actions github-actions bot removed the stale label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants