Feature: Create "unwrapped" overload for `hasX` if X is a value type
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
No source file or test is named. Start with the generator's Maven plugin path and the existing template customization mechanism mentioned in the issue, then review how generated hasX methods are defined. Before implementation, agree on supported value-type construction patterns, parameter limits, and whether annotation-based aliases are in scope; done means the chosen behavior is specified and covered by generated output tests.
Written by the indexing model from the issue text.
Description
This is potentially a little vague in its broadness, but here goes.
Say we have a value class like e.g.
@Value
class AccountNumber {
String rawValue;
}
If another class (for which we generate assertions) has a property of this type, we can assert:
assertThat(someObject).hasAccountNumber(new AccountNumber("abc"))
Nicer would be:
assertThat(someObject).hasAccountNumber("abc")
The generator could look for constructors, static _.of methods, and other popular patterns. It's not clear to me if there should be a limit on the length of the parameter list. Anyway, the desired implementation seems straight-forward:
public S hasAccountNumber(String accountNumberRawValue) {
return hasAccountNumber(new AccountNumber(fooRawValue));
}
As an alternative, there could be an annotation like e.g.
@AssertionAlias
static Foo of(String rawValue) { ... }
On a property Foo bar, this would cause additional generation of something like
public S hasBar(String fooRawValue) {
return hasBar(Foo.of(fooRawValue));
}
PS: This is probably easily done for specific use cases in any given project using templates, but I don't see documentation for a way to inject custom templates when using the generator through the Maven plugin.
- Dominant language
- Java
- Stars
- 72
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from assertj/assertj-generator
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
assertj/assertj-generator#278 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
assertj/assertj-generator#220 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
assertj/assertj-generator#219 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
assertj/assertj-generator#204 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
assertj/assertj-generator#197 · 7 comments ·
All issues in assertj/assertj-generator
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
apache/cloudstack#14222 ·
-
[BUG]茶杯方块在取茶时会引发崩溃 Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
1.0.0-alpha2 Type/Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wso2/dpdp-accelerator#272 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
area/frontend
Difficulty 2/5 1-3 hours Newbie friendliness 65/100