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

JNG-4220 add_add_method_for_builder #251

Merged
merged 7 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -563,4 +563,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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}

}
9 changes: 3 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@
javax.resource;version="[1.6,2)"
</osgi-transaction-import>

<judo-tatami-jsl-version>1.1.4.20231110_041308_b5800baf_develop</judo-tatami-jsl-version>
<judo-runtime-core-version>1.0.6.20231110_040919_ad19e1b8_develop</judo-runtime-core-version>
<judo-psm-generator-sdk-core-version>1.0.0.20231110_040634_869c28ea_develop</judo-psm-generator-sdk-core-version>
<judo-tatami-jsl-version>1.1.4.20231108_122951_030b2c1a_feature_JNG_4219_Builders_can_be_reusable</judo-tatami-jsl-version>
<judo-runtime-core-version>1.0.6.20231108_122557_6fd7a3a8_feature_JNG_4219_Builders_can_be_reusable</judo-runtime-core-version>
<judo-psm-generator-sdk-core-version>1.0.0.20231109_155226_8eda3a23_develop</judo-psm-generator-sdk-core-version>
<judo-tatami-jsl-version>1.1.4.20231110_104930_6430d7fa_feature_JNG_4220_add_add_method_for_builder</judo-tatami-jsl-version>
<judo-runtime-core-version>1.0.6.20231110_104911_9eea0366_feature_JNG_4220_add_add_method_for_builder</judo-runtime-core-version>
<judo-psm-generator-sdk-core-version>1.0.0.20231110_110153_e96e1edb_feature_JNG_4220_add_add_method_for_builder</judo-psm-generator-sdk-core-version>

<judo-meta-psm-version>1.3.0.20231107_041329_29cfda41_develop</judo-meta-psm-version>

Expand Down
Loading