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-4219 Builders can be reusable #249

Merged
merged 8 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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 @@ -23,6 +23,13 @@
import com.google.inject.Inject;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.abstract_.Abstract;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.abstract_.AbstractDao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.c.C;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.c.CBuilder;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.c.CDao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.d.D;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.d.DDao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.e.E;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.e.EDao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.entitya.EntityA;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.entitya.EntityADao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.specialcases.specialcases.entitya.querysamename.EntityAQuerySameNameParameter;
Expand All @@ -41,6 +48,10 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand All @@ -65,6 +76,7 @@ public class SpecialCasesTest {
@Inject
TestEntityDao testEntityDao;


/**
* This test checks the entities with the same query name declaration.
*
Expand Down Expand Up @@ -193,5 +205,58 @@ public void TestEntityThatHasJavaKeywordInItsPackageName() {
assertEquals(1, abstractDao.countAll());
}

@Inject
CDao cDao;

@Inject
DDao dDao;

@Inject
EDao eDao;

@Test
@TestCase("TestBuilderCopyTheCollectionRecursively")
@Requirement(reqs = {
"REQ-TYPE-001",
"REQ-ENT-001",
"REQ-ENT-002",
"REQ-ENT-004",
"REQ-ENT-007",
"REQ-MDL-001",
"REQ-MDL-002",
"REQ-MDL-003",
"REQ-SRV-002",
})
public void TestBuilderCopyTheCollectionRecursively() {


CBuilder cBuilder1 = C.builder()
.withCompD(List.of(D.builder()
.withCompE(List.of(E.builder().build(), E.builder().build()))
.build(),
D.builder().build())
);

CBuilder cBuilder2 = cBuilder1.withName("Name");

C c1 = cBuilder1.build();
C c11 = cBuilder1.build();
C c2 = cBuilder2.build();

c1.getCompD().get(0).getCompE().remove(c1.getCompD().get(0).getCompE().get(0));

assertEquals(1, c1.getCompD().get(0).getCompE().size());
assertEquals(2, c11.getCompD().get(0).getCompE().size());
assertEquals(2, c2.getCompD().get(0).getCompE().size());

cDao.queryCompD(c1).count();
gaborflorian marked this conversation as resolved.
Show resolved Hide resolved

c2.getCompD().get(0).getCompE().remove(c2.getCompD().get(0).getCompE().get(0));

assertEquals(1, c1.getCompD().get(0).getCompE().size());
assertEquals(2, c11.getCompD().get(0).getCompE().size());
assertEquals(1, c2.getCompD().get(0).getCompE().size());

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,19 @@ entity entityB {
@Query
relation ReferenceEntity querySameName(String name) <= ReferenceEntity!any();
}

// Builder copy the collection recursively

entity C {
field String name;
field D[] compD;
}

entity D {
field E[] compE;
}

entity E {

}

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

<judo-tatami-jsl-version>1.1.4.20231107_043414_de7314a5_develop</judo-tatami-jsl-version>
<judo-runtime-core-version>1.0.6.20231107_043031_831a45c5_develop</judo-runtime-core-version>
<judo-psm-generator-sdk-core-version>1.0.0.20231107_042218_ce601617_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.20231108_122327_9c7f6459_feature_JNG_4219_Builders_can_be_reusable</judo-psm-generator-sdk-core-version>

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

Expand Down
Loading