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

Support special objectAssertion templates for specific property types #204

Open
lhannest opened this issue Apr 1, 2022 · 0 comments
Open

Comments

@lhannest
Copy link

lhannest commented Apr 1, 2022

For example, I would like custom assertions for BigDecimal only like: has${Property}Of(Number value)

public ${self_type} has${Property}Of(Number n) ${throws}{
    if (new BigDecimal(n.toString()).compareTo(actual.${property}) != 0) {
        throw new AssertionError("expected " + n + " but got " + actual.${property});
    }
}

So then I can do:

PersonAssert.hasHeightOf(5);

Instead of

PersonAssert.hasHeightOf(BigDecimal.valueOf(5));

And of course I wouldn't want it to also generate PersonAssert.hasNameOf(Number n);.

So it would be nice to be able to specify a template just for BigDecimal property types. And I assume that this could be generalized to any property type.

@lhannest lhannest changed the title Support objectAssertion templates for specific classes Support special objectAssertion templates for specific property types Apr 1, 2022
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

No branches or pull requests

1 participant