Skip to content
Snippets Groups Projects
Commit b011f323 authored by René Schöne's avatar René Schöne
Browse files

working on relations

- proceed with RelationTest
- todo: fix fake-resolving in input
parent ab306beb
No related branches found
No related tags found
1 merge request!27Resolve "Feature: Send endpoint for relations"
Pipeline #12680 failed
...@@ -22,6 +22,7 @@ aspect NameResolution { ...@@ -22,6 +22,7 @@ aspect NameResolution {
} }
// override resolving of SenderRoot for As in ReceiverRoot // override resolving of SenderRoot for As in ReceiverRoot
// TODO change overriden attr to "globallyResolveSenderRootByToken" (should work for all relations in the end)
refine RefResolverStubs eq A.resolveToMyAByToken(String id) = getParent() != null ? resolveToMyAByTokenInh(id) : null; refine RefResolverStubs eq A.resolveToMyAByToken(String id) = getParent() != null ? resolveToMyAByTokenInh(id) : null;
inh SenderRoot A.resolveToMyAByTokenInh(String id); inh SenderRoot A.resolveToMyAByTokenInh(String id);
......
package org.jastadd.ragconnect.tests; package org.jastadd.ragconnect.tests.relation;
import org.assertj.core.groups.Tuple; import org.assertj.core.groups.Tuple;
import org.jastadd.ragconnect.tests.AbstractMqttTest;
import org.jastadd.ragconnect.tests.TestUtils;
import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Tag;
import relationInc.ast.*; import relationInc.ast.*;
...@@ -38,6 +40,9 @@ public class RelationTest extends AbstractMqttTest { ...@@ -38,6 +40,9 @@ public class RelationTest extends AbstractMqttTest {
private static final String TOPIC_BI_OPTIONAL_B = "rel/bi_optional_b"; private static final String TOPIC_BI_OPTIONAL_B = "rel/bi_optional_b";
private static final String TOPIC_BI_MANY_B = "rel/bi_many_b"; private static final String TOPIC_BI_MANY_B = "rel/bi_many_b";
// FIXME: remove when finished with test
private final boolean testing_shortcut = true;
private MqttHandler handler; private MqttHandler handler;
private ReceiverData data; private ReceiverData data;
...@@ -173,11 +178,12 @@ public class RelationTest extends AbstractMqttTest { ...@@ -173,11 +178,12 @@ public class RelationTest extends AbstractMqttTest {
@Override @Override
protected void communicateSendInitialValue() throws IOException, InterruptedException { protected void communicateSendInitialValue() throws IOException, InterruptedException {
// TODO also check disconnect // TODO also check disconnect
// myA -> a1, myB -> b1 // myA -> uni-a1, myB -> uni-b1
// biMyA -> a1, biMyB -> b1
check(8, "uni-a1", null, tuple(), "bi-a1", null, tuple(), check(8, "uni-a1", null, tuple(), "bi-a1", null, tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple()); "uni-b1", null, tuple(), "bi-b1", null, tuple());
if (!testing_shortcut) {
// --- testing unmapped unidirectional normal role --- // // --- testing unmapped unidirectional normal role --- //
uniA(1).setValue("test-1"); uniA(1).setValue("test-1");
...@@ -279,10 +285,70 @@ public class RelationTest extends AbstractMqttTest { ...@@ -279,10 +285,70 @@ public class RelationTest extends AbstractMqttTest {
uniA(3).getInner().setInnerValue("inner-a3"); uniA(3).getInner().setInnerValue("inner-a3");
check(23, "test-3:test-6", "test-3:test-6", tuple("test-7:inner-uni-a3", "test-3:test-6"), "bi-a1", null, tuple(), check(23, "test-3:test-6", "test-3:test-6", tuple("test-7:inner-uni-a3", "test-3:test-6"), "bi-a1", null, tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple(), true); "uni-b1", null, tuple(), "bi-b1", null, tuple(), true);
} else {
data.numberOfValues = 23;
}
// --- todo testing unmapped bidirectional normal role --- // // "reset" values in receiver-root to make check method call shorted
receiverRoot.setFromMyA(null);
receiverRoot.setFromOptionalA(null);
receiverRoot.setFromManyAList(new JastAddList<>());
check(23, null, null, tuple(), "bi-a1", null, tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple());
// biMyA -> bi-a1, biMyB -> bi-b1
// --- testing unmapped bidirectional normal role --- //
biA(1).setValue("test-9");
check(24, null, null, tuple(), "test-9:inner-bi-a1", null, tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple());
// set opposite role of relation must trigger message
biA(2).setToMyA(senderBi);
check(25, null, null, tuple(), "bi-a2", null, tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple());
// changing something that was previously the relation target must not trigger a message
biA(1).setValue("test-9-ignored");
check(25, null, null, tuple(), "bi-a2", null, tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple(), true);
biA(2).setValue("test-10");
check(26, null, null, tuple(), "test-10:inner-bi-a2", null, tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple());
biA(2).getInner().setInnerValue("test-11");
check(27, null, null, tuple(), "test-10:test-11", null, tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple());
// setting a new relation target resulting in the same serialization must not trigger a message
biA(1).setValue("test-10");
biA(1).getInner().setInnerValue("test-11");
biA(1).setToMyA(senderBi);
check(27, null, null, tuple(), "test-10:test-11", null, tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple(), true);
// --- todo testing unmapped bidirectional optional role --- // // --- todo testing unmapped bidirectional optional role --- //
// reset a2
biA(2).setValue("bi-a2");
biA(2).getInner().setInnerValue("inner-bi-a2");
senderBi.setBiOptionalA(biA(2));
check(28, null, null, tuple(), "test-10:test-11", "bi-a2", tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple());
biA(2).setValue("test-12");
check(29, null, null, tuple(), "test-10:test-11", "test-12:inner-bi-a2", tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple());
// set opposite role of relation must trigger message
biA(1).setToOptionalA(senderBi);
check(30, null, null, tuple(), "test-10:test-11", "test-10:test-11", tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple());
// change a nonterminal target of two relations must trigger two messages
biA(1).getInner().setInnerValue("test-13");
check(32, null, null, tuple(), "test-10:test-13", "test-10:test-13", tuple(),
"uni-b1", null, tuple(), "bi-b1", null, tuple());
// --- todo testing unmapped bidirectional list role --- // // --- todo testing unmapped bidirectional list role --- //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment