diff --git a/generators/java/templates/src/test/java/_package_/_entityPackage_/domain/_persistClass_Test.java.ejs b/generators/java/templates/src/test/java/_package_/_entityPackage_/domain/_persistClass_Test.java.ejs index 938b14384038..b06c5946058d 100644 --- a/generators/java/templates/src/test/java/_package_/_entityPackage_/domain/_persistClass_Test.java.ejs +++ b/generators/java/templates/src/test/java/_package_/_entityPackage_/domain/_persistClass_Test.java.ejs @@ -26,6 +26,7 @@ import static <%= otherEntity.entityAbsolutePackage %>.domain.<%= otherEntity.pe import <%= otherEntity.entityAbsolutePackage %>.domain.<%= otherEntity.persistClass %>; <%_ } _%> <%_ if (relationships.some(relationship => relationship.collection)) { _%> +import java.util.HashSet; import java.util.Set; <%_ } _%> import org.junit.jupiter.api.Test; @@ -92,7 +93,7 @@ class <%= persistClass %>Test { <%_ } _%> <%_ if (relationship.collection) { _%> - <%= persistInstance %>.set<%- relationship.propertyNameCapitalized %>(Set.of(<%= relationship.otherEntity.persistInstance %>Back)); + <%= persistInstance %>.set<%- relationship.propertyNameCapitalized %>(new HashSet<>(Set.of(<%= relationship.otherEntity.persistInstance %>Back))); assertThat(<%= persistInstance %>.get<%- relationship.propertyNameCapitalized %>()).containsOnly(<%= relationship.otherEntity.persistInstance %>Back); <%_ if (relationship.otherRelationship && !relationship.ownerSide && !relationship.otherEntity.embedded) { _%> <%_ if (relationship.otherRelationship.collection) { _%> @@ -102,7 +103,7 @@ class <%= persistClass %>Test { <%_ } _%> <%_ } _%> - <%= persistInstance %>.set<%- relationship.propertyNameCapitalized %>(Set.of()); + <%= persistInstance %>.set<%- relationship.propertyNameCapitalized %>(new HashSet<>()); assertThat(<%= persistInstance %>.get<%- relationship.propertyNameCapitalized %>()).doesNotContain(<%= relationship.otherEntity.persistInstance %>Back); <%_ if (relationship.otherRelationship && !relationship.ownerSide && !relationship.otherEntity.embedded) { _%> <%_ if (relationship.otherRelationship.collection) { _%>