From 04e213682e0c3e272f56a2efb8d669547e3e22b3 Mon Sep 17 00:00:00 2001 From: Madmat8 Date: Thu, 9 Nov 2023 16:05:12 +0100 Subject: [PATCH 1/5] JNG-4220 Initial feature commit [ci skip] From 8be541bc501eca8ce60e3fd7fdc3f6fe4d645a31 Mon Sep 17 00:00:00 2001 From: Madmat8 Date: Fri, 10 Nov 2023 11:25:14 +0100 Subject: [PATCH 2/5] test addTo method on builder --- .../entity/CompositionRelationshipsTest.java | 80 +++++++++++++++++++ ...ppedTransferCompositonAggregationTest.java | 74 +++++++++++++++++ pom.xml | 6 +- 3 files changed, 157 insertions(+), 3 deletions(-) diff --git a/judo-runtime-core-jsl-itest/models/EntityRelationshipsModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/entity/CompositionRelationshipsTest.java b/judo-runtime-core-jsl-itest/models/EntityRelationshipsModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/entity/CompositionRelationshipsTest.java index 0ce93378..37683c39 100644 --- a/judo-runtime-core-jsl-itest/models/EntityRelationshipsModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/entity/CompositionRelationshipsTest.java +++ b/judo-runtime-core-jsl-itest/models/EntityRelationshipsModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/entity/CompositionRelationshipsTest.java @@ -568,4 +568,84 @@ void testDeepCopyUpdate() { () -> entityADao.update(a5) ); } + + + @Test + void testAddMethodOnBuilder() { + EntityC c1 = entityCDao.create(EntityC.builder().withStringC("C1").build()); + EntityC c2 = entityCDao.create(EntityC.builder().withStringC("C2").build()); + EntityC c3 = entityCDao.create(EntityC.builder().withStringC("C3").build()); + EntityC c4 = entityCDao.create(EntityC.builder().withStringC("C4").build()); + + EntityA entityA = entityADao.create(EntityA.builder() + .withSingleRequiredConA(EntityC.builder().withStringC("C1").build()) + .addToCollectionConA(c2) + .build()); + + assertEquals(1, entityA.getCollectionConA().size()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C2")).count()); + + entityA = entityADao.create(EntityA.builder() + .withSingleRequiredConA(EntityC.builder().withStringC("C1").build()) + .addToCollectionConA(c2, c3) + .build()); + + assertEquals(2, entityA.getCollectionConA().size()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C2")).count()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C3")).count()); + + entityA = entityADao.create(EntityA.builder() + .withSingleRequiredConA(EntityC.builder().withStringC("C1").build()) + .addToCollectionConA(c2, c2) + .build()); + + assertEquals(2, entityA.getCollectionConA().size()); + assertEquals(2, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C2")).count()); + + entityA = entityADao.create(EntityA.builder() + .withSingleRequiredConA(EntityC.builder().withStringC("C1").build()) + .addToCollectionConA(c2) + .addToCollectionConA(c2) + .build()); + + assertEquals(2, entityA.getCollectionConA().size()); + assertEquals(2, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C2")).count()); + + entityA = entityADao.create(EntityA.builder() + .withSingleRequiredConA(EntityC.builder().withStringC("C1").build()) + .addToCollectionConA(c2) + .addToCollectionConA(c3) + .addToCollectionConA(c4) + .build()); + + assertEquals(3, entityA.getCollectionConA().size()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C2")).count()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C3")).count()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C4")).count()); + + entityA = entityADao.create(EntityA.builder() + .withSingleRequiredConA(EntityC.builder().withStringC("C1").build()) + .withCollectionConA(List.of(c1, c2)) + .addToCollectionConA(c3) + .addToCollectionConA(c4) + .build()); + + assertEquals(4, entityA.getCollectionConA().size()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C1")).count()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C2")).count()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C3")).count()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C4")).count()); + + entityA = entityADao.create(EntityA.builder() + .withSingleRequiredConA(EntityC.builder().withStringC("C1").build()) + .withCollectionConA(List.of(c1, c2)) + .addToCollectionConA(c3, c4) + .build()); + + assertEquals(4, entityA.getCollectionConA().size()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C1")).count()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C2")).count()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C3")).count()); + assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C4")).count()); + } } diff --git a/judo-runtime-core-jsl-itest/models/TransferAggregationModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/transfer/MappedTransferCompositonAggregationTest.java b/judo-runtime-core-jsl-itest/models/TransferAggregationModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/transfer/MappedTransferCompositonAggregationTest.java index 0098bf64..033ad073 100644 --- a/judo-runtime-core-jsl-itest/models/TransferAggregationModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/transfer/MappedTransferCompositonAggregationTest.java +++ b/judo-runtime-core-jsl-itest/models/TransferAggregationModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/transfer/MappedTransferCompositonAggregationTest.java @@ -21,6 +21,7 @@ */ import com.google.inject.Inject; +import hu.blackbelt.judo.psm.generator.sdk.core.test.api.compositionrelationships.compositionrelationships.entitya.EntityA; import hu.blackbelt.judo.psm.generator.sdk.core.test.api.compositionrelationships.compositionrelationships.entityc.EntityC; import hu.blackbelt.judo.psm.generator.sdk.core.test.api.compositionrelationships.compositionrelationships.entityd.EntityD; import hu.blackbelt.judo.psm.generator.sdk.core.test.api.mappedtransfercompositonaggregation.mappedtransfercompositonaggregation.entitya.EntityADao; @@ -483,4 +484,77 @@ void testDeepCopyUpdate() { } + + @Test + void testAddMethodOnBuilder() { + TransferB b1 = transferBDao.create(TransferB.builder().withNameB("B1").build()); + TransferB b2 = transferBDao.create(TransferB.builder().withNameB("B2").build()); + TransferB b3 = transferBDao.create(TransferB.builder().withNameB("B3").build()); + TransferB b4 = transferBDao.create(TransferB.builder().withNameB("B4").build()); + + TransferA transferA = transferADao.create(TransferA.builder() + .addToMultiEntityB(b2) + .build()); + + assertEquals(1, transferA.getMultiEntityB().size()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B2")).count()); + + transferA = transferADao.create(TransferA.builder() + .addToMultiEntityB(b2, b3) + .build()); + + assertEquals(2, transferA.getMultiEntityB().size()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B2")).count()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B3")).count()); + + transferA = transferADao.create(TransferA.builder() + .addToMultiEntityB(b2, b2) + .build()); + + assertEquals(2, transferA.getMultiEntityB().size()); + assertEquals(2, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B2")).count()); + + transferA = transferADao.create(TransferA.builder() + .addToMultiEntityB(b2) + .addToMultiEntityB(b2) + .build()); + + assertEquals(2, transferA.getMultiEntityB().size()); + assertEquals(2, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B2")).count()); + + transferA = transferADao.create(TransferA.builder() + .addToMultiEntityB(b2) + .addToMultiEntityB(b3) + .addToMultiEntityB(b4) + .build()); + + assertEquals(3, transferA.getMultiEntityB().size()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B2")).count()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B3")).count()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B4")).count()); + + transferA = transferADao.create(TransferA.builder() + .withMultiEntityB(List.of(b1, b2)) + .addToMultiEntityB(b3) + .addToMultiEntityB(b4) + .build()); + + assertEquals(4, transferA.getMultiEntityB().size()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B1")).count()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B2")).count()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B3")).count()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B4")).count()); + + transferA = transferADao.create(TransferA.builder() + .withMultiEntityB(List.of(b1, b2)) + .addToMultiEntityB(b3, b4) + .build()); + + assertEquals(4, transferA.getMultiEntityB().size()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B1")).count()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B2")).count()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B3")).count()); + assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B4")).count()); + } + } diff --git a/pom.xml b/pom.xml index 93368ab9..63f68b8b 100644 --- a/pom.xml +++ b/pom.xml @@ -40,9 +40,9 @@ javax.resource;version="[1.6,2)" - 1.1.4.20231108_122951_030b2c1a_feature_JNG_4219_Builders_can_be_reusable - 1.0.6.20231108_122557_6fd7a3a8_feature_JNG_4219_Builders_can_be_reusable - 1.0.0.20231108_122327_9c7f6459_feature_JNG_4219_Builders_can_be_reusable + 1.1.4-SNAPSHOT + 1.0.6-SNAPSHOT + 1.0.0-SNAPSHOT 1.3.0.20231107_041329_29cfda41_develop From 872ac62b11d185b993246037532075386384c0c6 Mon Sep 17 00:00:00 2001 From: Madmat8 Date: Fri, 10 Nov 2023 12:16:36 +0100 Subject: [PATCH 3/5] update versions --- pom.xml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 10157acd..27c349ed 100644 --- a/pom.xml +++ b/pom.xml @@ -40,12 +40,9 @@ javax.resource;version="[1.6,2)" - 1.1.4-SNAPSHOT - 1.0.6-SNAPSHOT - 1.0.0-SNAPSHOT - 1.1.4.20231108_122951_030b2c1a_feature_JNG_4219_Builders_can_be_reusable - 1.0.6.20231108_122557_6fd7a3a8_feature_JNG_4219_Builders_can_be_reusable - 1.0.0.20231109_155226_8eda3a23_develop + v1.1.4.20231110_104930_6430d7fa_feature_JNG_4220_add_add_method_for_builder + v1.0.6.20231110_104911_9eea0366_feature_JNG_4220_add_add_method_for_builder + 1.0.0.20231110_110153_e96e1edb_feature_JNG_4220_add_add_method_for_builder 1.3.0.20231107_041329_29cfda41_develop From a82d816174e9a45bdc02e00793508b31b9573094 Mon Sep 17 00:00:00 2001 From: Madmat8 Date: Fri, 10 Nov 2023 12:23:32 +0100 Subject: [PATCH 4/5] fix version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 27c349ed..bef306c1 100644 --- a/pom.xml +++ b/pom.xml @@ -40,8 +40,8 @@ javax.resource;version="[1.6,2)" - v1.1.4.20231110_104930_6430d7fa_feature_JNG_4220_add_add_method_for_builder - v1.0.6.20231110_104911_9eea0366_feature_JNG_4220_add_add_method_for_builder + 1.1.4.20231110_104930_6430d7fa_feature_JNG_4220_add_add_method_for_builder + 1.0.6.20231110_104911_9eea0366_feature_JNG_4220_add_add_method_for_builder 1.0.0.20231110_110153_e96e1edb_feature_JNG_4220_add_add_method_for_builder 1.3.0.20231107_041329_29cfda41_develop From f26b911b0f10b34921a33aeb84b4b432eb06ae2b Mon Sep 17 00:00:00 2001 From: Madmat8 Date: Thu, 16 Nov 2023 16:42:23 +0100 Subject: [PATCH 5/5] fix errors --- .../core/jsl/entity/CompositionRelationshipsTest.java | 1 + .../MappedTransferCompositonAggregationTest.java | 10 ++-------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/judo-runtime-core-jsl-itest/models/EntityRelationshipsModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/entity/CompositionRelationshipsTest.java b/judo-runtime-core-jsl-itest/models/EntityRelationshipsModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/entity/CompositionRelationshipsTest.java index 6bd9c496..82839b55 100644 --- a/judo-runtime-core-jsl-itest/models/EntityRelationshipsModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/entity/CompositionRelationshipsTest.java +++ b/judo-runtime-core-jsl-itest/models/EntityRelationshipsModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/entity/CompositionRelationshipsTest.java @@ -633,6 +633,7 @@ void testAddMethodOnBuilder() { assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C2")).count()); assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C3")).count()); assertEquals(1, entityA.getCollectionConA().stream().filter(entityC -> entityC.getStringC().orElseThrow().equals("C4")).count()); + } @Test void testAddAndRemoveOnCollections() { diff --git a/judo-runtime-core-jsl-itest/models/TransferAggregationModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/transfer/MappedTransferCompositonAggregationTest.java b/judo-runtime-core-jsl-itest/models/TransferAggregationModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/transfer/MappedTransferCompositonAggregationTest.java index d9b29800..3b23cfff 100644 --- a/judo-runtime-core-jsl-itest/models/TransferAggregationModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/transfer/MappedTransferCompositonAggregationTest.java +++ b/judo-runtime-core-jsl-itest/models/TransferAggregationModel/src/test/java/hu/blackbelt/judo/runtime/core/jsl/transfer/MappedTransferCompositonAggregationTest.java @@ -21,16 +21,10 @@ */ import com.google.inject.Inject; -<<<<<<< HEAD -import hu.blackbelt.judo.psm.generator.sdk.core.test.api.compositionrelationships.compositionrelationships.entitya.EntityA; -import hu.blackbelt.judo.psm.generator.sdk.core.test.api.compositionrelationships.compositionrelationships.entityc.EntityC; -import hu.blackbelt.judo.psm.generator.sdk.core.test.api.compositionrelationships.compositionrelationships.entityd.EntityD; -======= +import hu.blackbelt.judo.psm.generator.sdk.core.test.api.mappedtransfercompositonaggregation.mappedtransfercompositonaggregation.entitya.EntityA; import hu.blackbelt.judo.psm.generator.sdk.core.test.api.mappedtransfercompositonaggregation.mappedtransfercompositonaggregation.composition.Composition; import hu.blackbelt.judo.psm.generator.sdk.core.test.api.mappedtransfercompositonaggregation.mappedtransfercompositonaggregation.composition.CompositionDao; import hu.blackbelt.judo.psm.generator.sdk.core.test.api.mappedtransfercompositonaggregation.mappedtransfercompositonaggregation.composition.CompositionIdentifier; -import hu.blackbelt.judo.psm.generator.sdk.core.test.api.mappedtransfercompositonaggregation.mappedtransfercompositonaggregation.entitya.EntityA; ->>>>>>> develop import hu.blackbelt.judo.psm.generator.sdk.core.test.api.mappedtransfercompositonaggregation.mappedtransfercompositonaggregation.entitya.EntityADao; import hu.blackbelt.judo.psm.generator.sdk.core.test.api.mappedtransfercompositonaggregation.mappedtransfercompositonaggregation.entitya.EntityAIdentifier; import hu.blackbelt.judo.psm.generator.sdk.core.test.api.mappedtransfercompositonaggregation.mappedtransfercompositonaggregation.entityb.EntityB; @@ -66,7 +60,6 @@ import hu.blackbelt.judo.runtime.core.exception.ValidationException; import hu.blackbelt.judo.runtime.core.jsl.fixture.JudoRuntimeExtension; import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -569,6 +562,7 @@ void testAddMethodOnBuilder() { assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B2")).count()); assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B3")).count()); assertEquals(1, transferA.getMultiEntityB().stream().filter(entityC -> entityC.getNameB().orElseThrow().equals("B4")).count()); + } @Test void testAddAndRemoveOnCollections() {