Skip to content

Commit

Permalink
Test with allowNullableCollections
Browse files Browse the repository at this point in the history
  • Loading branch information
olsavmic committed Jun 7, 2024
1 parent fd4e6ba commit a52252d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

import io.soabase.recordbuilder.core.RecordBuilder;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Set;

@RecordBuilder
@RecordBuilder.Options(useImmutableCollections = true, builderMode = RecordBuilder.BuilderMode.STANDARD_AND_STAGED_REQUIRED_ONLY)
public record CombinedSimpleStagedRequiredOnly(Set<Integer> numbers, @Null String foo) {
@RecordBuilder.Options(useImmutableCollections = true, builderMode = RecordBuilder.BuilderMode.STANDARD_AND_STAGED_REQUIRED_ONLY, allowNullableCollections = true, interpretNotNulls = true)
public record CombinedSimpleStagedRequiredOnly(Set<Integer> numbers, @Null String foo, @NotNull Set<Integer> requiredNumbers) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,16 @@ void testOptionalList() {
void testCombinedSimpleStagedRequiredOnly() {
CombinedSimpleStagedRequiredOnly obj = CombinedSimpleStagedRequiredOnlyBuilder.stagedBuilder()
.numbers(Set.of(5, 4)).build();
assertEquals(new CombinedSimpleStagedRequiredOnly(Set.of(5, 4), null), obj);
assertEquals(new CombinedSimpleStagedRequiredOnly(Set.of(5, 4), null, Set.of()), obj);

obj = CombinedSimpleStagedRequiredOnlyBuilder.stagedBuilder().foo("ok").numbers(Set.of(5, 2)).build();
assertEquals(new CombinedSimpleStagedRequiredOnly(Set.of(5, 2), "ok"), obj);
obj = CombinedSimpleStagedRequiredOnlyBuilder.stagedBuilder().build();
assertEquals(new CombinedSimpleStagedRequiredOnly(null, null, Set.of()), obj);

obj = CombinedSimpleStagedRequiredOnlyBuilder.stagedBuilder()
.foo("ok")
.numbers(Set.of(5, 2))
.requiredNumbers(Set.of())
.build();
assertEquals(new CombinedSimpleStagedRequiredOnly(Set.of(5, 2), "ok", Set.of()), obj);
}
}

0 comments on commit a52252d

Please sign in to comment.