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-5103 Join factory fails with relations of subtypes #237

Draft
wants to merge 14 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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 @@ -31,14 +31,17 @@
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.d.D;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.d.DDao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.d.DForCreate;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.e.E;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.e.EDao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.e.EForCreate;
import hu.blackbelt.judo.psm.generator.sdk.core.test.guice.ContainerTestDaoModules;
import hu.blackbelt.judo.requirement.report.annotation.Requirement;
import hu.blackbelt.judo.runtime.core.jsl.fixture.JudoRuntimeExtension;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

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

@Slf4j
public class ContainerTest {
Expand All @@ -49,7 +52,8 @@ public class ContainerTest {
@Inject BDao bDao;
@Inject CDao cDao;
@Inject DDao dDao;

@Inject EDao eDao;

@Test
@Requirement(reqs = {
"REQ-ENT-001",
Expand Down Expand Up @@ -96,4 +100,67 @@ public void testContainerFunction() {
assertEquals(b1.identifier().getIdentifier(), dB.identifier().getIdentifier());
}

@Test
@Requirement(reqs = {
"REQ-ENT-001",
"REQ-ENT-004",
"REQ-ENT-005",
"REQ-ENT-007",
"REQ-ENT-008",
"REQ-ENT-012",
"REQ-EXPR-001",
"REQ-EXPR-003",
"REQ-EXPR-004",
"REQ-EXPR-006",
"REQ-EXPR-021",
"REQ-MDL-001",
"REQ-MDL-002",
"REQ-SYNT-001",
"REQ-SYNT-002",
"REQ-SYNT-003"
})
public void testInheritedContainerFunction() {

E e = eDao.create(EForCreate.builder().withName("E").build());

B b = bDao.create(BForCreate.builder()
.withConA(CForCreate.builder().build())
.withDonB(DForCreate.builder().build())
.withRelEonB(e)
.build()
);

// the container is on the parent, the relation is on the child entity
C c = b.getConA();

assertEquals(e.identifier(), cDao.queryContainerAasBrelEonB(c).get().identifier());
// TODO JNG-5103 No value present
//assertEquals(e.identifier(), cDao.queryContainerBrelEonB(c).get().identifier());

// Recursive C relation
assertFalse(cDao.queryContainerAasBrelConB(c).isPresent());
// TODO JNG-5103 When no relConB relation is attached, the recursive relation contains the c instance.
//assertFalse(cDao.queryContainerBrelConB(c).isPresent()); // not work

C c1 = bDao.createRelConB(b, CForCreate.builder().build());
assertEquals(c1.identifier(), cDao.queryContainerAasBrelConB(c).get().identifier());
// TODO JNG-5103 Recursive relation contains the c instance always, not the c.container.relConB if it is present
//assertEquals(c1.identifier(), cDao.queryContainerBrelConB(c).get().identifier()); // not work

// the container and the relation are in the same entity
D d = b.getDonB();

assertEquals(e.identifier(), dDao.queryContainerAasBrelEonB(d).get().identifier());
assertEquals(e.identifier(), dDao.queryContainerBrelEonB(d).get().identifier());

// Recursive D relation
assertFalse(dDao.queryContainerAasBrelDonB(d).isPresent());
assertFalse(dDao.queryContainerBrelDonB(d).isPresent());

D d1 = bDao.createRelDonB(b, DForCreate.builder().build());
assertEquals(d1.identifier(), dDao.queryContainerAasBrelDonB(d).get().identifier());
assertEquals(d1.identifier(), dDao.queryContainerBrelDonB(d).get().identifier());

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.b.BIdentifier;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.c.C;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.c.CDao;
//import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.d.D;
//import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.d.DDao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.d.D;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.d.DDao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.e.E;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.ta.TA;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.ta.TADao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.ta.TAForCreate;
Expand All @@ -46,6 +49,9 @@
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.td.TD;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.td.TDDao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.td.TDForCreate;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.te.TE;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.te.TEDao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.te.TEForCreate;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.tpartner.TPartner;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.tpartner.TPartnerDao;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.containertest.containertest.tpartner.TPartnerForCreate;
Expand All @@ -67,6 +73,7 @@
import java.util.List;

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

@Slf4j
Expand All @@ -92,6 +99,9 @@ public class MappedTransferContainerTest {
@Inject
TADao taDao;

@Inject
TEDao teDao;

@Inject
TPartnerDao tpartnerDao;

Expand Down Expand Up @@ -249,4 +259,68 @@ public void testTransferContainerFunctionWithRange() {


}
}

@Test
@Requirement(reqs = {
"REQ-ENT-001",
"REQ-ENT-004",
"REQ-ENT-005",
"REQ-ENT-007",
"REQ-ENT-008",
"REQ-ENT-012",
"REQ-EXPR-001",
"REQ-EXPR-003",
"REQ-EXPR-004",
"REQ-EXPR-006",
"REQ-EXPR-021",
"REQ-MDL-001",
"REQ-MDL-002",
"REQ-SYNT-001",
"REQ-SYNT-002",
"REQ-SYNT-003"
})
public void testTransferInheritedContainerFunction() {

TE te = teDao.create(TEForCreate.builder().withName("E").build());

TB tb = tbDao.create(TBForCreate.builder()
.withConA(TCForCreate.builder().build())
.withDonB(TDForCreate.builder().build())
.withRelEonB(te)
.build()
);

// the container is on the parent, the relation is on the child entity
TC tc = tb.getConA();

Assertions.assertEquals(te.identifier(), tcDao.queryContainerAasBrelEonB(tc).get().identifier());
// TODO JNG-5103 No value present
// assertEquals(te.identifier(), tcDao.queryContainerBrelEonB(tc).get().identifier());

// Recursive C relation
assertFalse(tcDao.queryContainerAasBrelConB(tc).isPresent());
// TODO JNG-5103 When no relConB relation is attached, the recursive relation contains the c instance.
// assertFalse(tcDao.queryContainerBrelConB(tc).isPresent()); // not work

TC tc1 = tbDao.createRelConB(tb, TCForCreate.builder().build());
Assertions.assertEquals(tc1.identifier(), tcDao.queryContainerAasBrelConB(tc).get().identifier());
// TODO JNG-5103 Recursive relation contains the c instance always, not the c.container.relConB if it is present
// assertEquals(tc1.identifier(), tcDao.queryContainerBrelConB(tc).get().identifier()); // not work

// the container and the relation are in the same entity
TD td = tb.getDonB();

Assertions.assertEquals(te.identifier(), tdDao.queryContainerAasBrelEonB(td).get().identifier());
Assertions.assertEquals(te.identifier(), tdDao.queryContainerBrelEonB(td).get().identifier());

// Recursive D relation
assertFalse(tdDao.queryContainerAasBrelDonB(td).isPresent());
assertFalse(tdDao.queryContainerBrelDonB(td).isPresent());

TD td1 = tbDao.createRelDonB(tb, TDForCreate.builder().build());
Assertions.assertEquals(td1.identifier(), tdDao.queryContainerAasBrelDonB(td).get().identifier());
Assertions.assertEquals(td1.identifier(), tdDao.queryContainerBrelDonB(td).get().identifier());

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,73 @@ entity A {

entity B extends A {
field D donB required;

relation E relEonB;
relation C relConB;
relation D relDonB;
}

entity C {
relation A containerA <= self.container(type = A);
relation B containerB <= self.container(type = A).asType(type = B);
relation B containerB1 <= self.container(type = B);

relation E containerAasBrelEonB <= self.container(type = A).asType(type = B).relEonB;
relation E containerBrelEonB <= self.container(type = B).relEonB; // JNG-5103 cause problem - no value presented

relation D containerAasBrelDonB <= self.container(type = A).asType(type = B).relDonB;
relation D containerBrelDonB <= self.container(type = B).relDonB; // JNG-5103 cause problem - same C as root returned

relation C containerAasBrelConB <= self.container(type = A).asType(type = B).relConB;
relation C containerBrelConB <= self.container(type = B).relConB;
}

entity D {
relation A containerA <= self.container(type = B).asType(type = A);
relation A containerA1 <= self.container(type = A);
relation B containerB <= self.container(type = B);

relation E containerAasBrelEonB <= self.container(type = A).asType(type = B).relEonB;
relation E containerBrelEonB <= self.container(type = B).relEonB;

relation D containerAasBrelDonB <= self.container(type = A).asType(type = B).relDonB;
relation D containerBrelDonB <= self.container(type = B).relDonB;

}

entity E {
field String name;
}

// TRANSFER representation

transfer TA maps A as a {
relation TC conA <= a.conA eager:true required create:true;

event create `create`;
}

transfer TB maps B as b {
relation TD donB <= b.donB required eager:true create:true;
relation TC conA <= b.conA required eager:true create:true;

relation TE relEonB <= b.relEonB create:true;
relation TC relConB <= b.relConB create:true;
relation TD relDonB <= b.relDonB create:true;

event create `create`;
}

transfer TC maps C as c {
relation TA containerA <= c.containerA;
relation TB containerB <= c.containerB;
relation TB containerB1 <= c.containerB1;

relation TE containerAasBrelEonB <= c.containerAasBrelEonB;
relation TE containerBrelEonB <= c.containerBrelEonB;
relation TC containerAasBrelConB <= c.containerAasBrelConB;
relation TC containerBrelConB <= c.containerBrelConB;

event create `create`;
}

Expand All @@ -46,9 +83,20 @@ transfer TD maps D as d {
relation TA containerA1 <= d.containerA1;
relation TB containerB <= d.containerB;

relation TE containerAasBrelEonB <= d.containerAasBrelEonB;
relation TE containerBrelEonB <= d.containerBrelEonB;
relation TD containerAasBrelDonB <= d.containerAasBrelDonB;
relation TD containerBrelDonB <= d.containerBrelDonB;

event create `create`;
}

transfer TE maps E as e {
field String name <=> e.name;

event create `create`;
}


// Transaction model

Expand Down
40 changes: 40 additions & 0 deletions judo-runtime-core-jsl-itest/models/ForTestingModel/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/sdk-core/ContainerTestModel">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions judo-runtime-core-jsl-itest/models/ForTestingModel/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>judo-runtime-core-jsl-itest-model-ContainerTestModel</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Loading
Loading