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

working on relations

- finished second half of RelationTest
parent de868379
No related branches found
No related tags found
1 merge request!27Resolve "Feature: Send endpoint for relations"
Pipeline #12698 passed
......@@ -211,14 +211,13 @@ public class TestUtils {
// if there is at least one call to this, we do not need to manually wait in the next check()
needManualWait = false;
Integer currentExpected = intValues.computeIfAbsent(NUMBER_OF_VALUES, ActualAndExpected::new).expected;
if (currentExpected == null) {
currentExpected = 0;
}
return put(NUMBER_OF_VALUES, currentExpected + increment);
}
public TestChecker setActualNumberOfValues(Callable<Integer> actual) {
return setActualInteger(NUMBER_OF_VALUES, actual);
setActualInteger(NUMBER_OF_VALUES, actual);
intValues.get(NUMBER_OF_VALUES).expected = 0;
return this;
}
public TestChecker setActualString(String name, Callable<String> actual) {
......
......@@ -7,13 +7,12 @@ import relationInc.ast.*;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import static java.util.function.Predicate.isEqual;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.groups.Tuple.tuple;
import static org.jastadd.ragconnect.tests.TestUtils.*;
import static org.jastadd.ragconnect.tests.TestUtils.TestChecker;
import static org.jastadd.ragconnect.tests.TestUtils.mqttUri;
import static org.junit.jupiter.api.Assertions.*;
/**
......@@ -39,9 +38,6 @@ public class RelationTest extends AbstractMqttTest {
private static final String TOPIC_BI_OPTIONAL_B = "rel/bi_optional_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 ReceiverData data;
private TestChecker checker;
......@@ -182,28 +178,10 @@ public class RelationTest extends AbstractMqttTest {
assertTrue(senderBi.connectBiMyB(mqttUri(TOPIC_BI_MY_B), isWriteCurrentValue()));
assertTrue(senderBi.connectBiOptionalB(mqttUri(TOPIC_BI_OPTIONAL_B), isWriteCurrentValue()));
assertTrue(senderBi.connectBiManyB(mqttUri(TOPIC_BI_MANY_B), isWriteCurrentValue()));
// waitForNonNull(receiverRoot::getFromMyA);
// waitForNonNull(receiverRoot::getFromBiMyA);
// waitForNonNull(receiverRoot::getFromMyB);
// waitForNonNull(receiverRoot::getFromBiMyB);
}
// private <T> void waitForValue(T expectedValue, Callable<T> callable) {
// if (isWriteCurrentValue()) {
// awaitMqtt().until(callable, isEqual(expectedValue));
// }
// }
//
// private <T> void waitForNonNull(Callable<T> callable) {
// if (isWriteCurrentValue()) {
// awaitMqtt().until(callable, Predicate.not(isEqual(null)));
// }
// }
@Override
protected void communicateSendInitialValue() throws IOException, InterruptedException {
// myA -> uni-a1, myB -> uni-b1
protected void communicateSendInitialValue() throws IOException {
checker.addToNumberOfValues(8)
.put(TOPIC_MY_A, "uni-a1")
.put(TOPIC_OPTIONAL_A, (String) null)
......@@ -218,8 +196,31 @@ public class RelationTest extends AbstractMqttTest {
.put(TOPIC_BI_OPTIONAL_B, (String) null)
.put(TOPIC_BI_MANY_B, tuple());
communicateBoth();
}
@Override
protected void communicateOnlyUpdatedValue() throws IOException, InterruptedException {
checker.put(TOPIC_MY_A, (String) null)
.put(TOPIC_OPTIONAL_A, (String) null)
.put(TOPIC_MANY_A, tuple())
.put(TOPIC_BI_MY_A, (String) null)
.put(TOPIC_BI_OPTIONAL_A, (String) null)
.put(TOPIC_BI_MANY_A, tuple())
.put(TOPIC_MY_B, (String) null)
.put(TOPIC_OPTIONAL_B, (String) null)
.put(TOPIC_MANY_B, tuple())
.put(TOPIC_BI_MY_B, (String) null)
.put(TOPIC_BI_OPTIONAL_B, (String) null)
.put(TOPIC_BI_MANY_B, tuple());
communicateBoth();
}
protected void communicateBoth() throws IOException {
checker.check();
// myA -> uni-a1, myB -> uni-b1
// --- testing unmapped unidirectional normal role --- //
uniA(1).setValue("test-1");
......@@ -618,17 +619,6 @@ public class RelationTest extends AbstractMqttTest {
}
@Override
protected void communicateOnlyUpdatedValue() throws IOException, InterruptedException {
waitForMqtt();
// TODO implement test
// TODO also check disconnect
}
private <T> void awaitEquals(T expected, Callable<T> actual, String alias) {
awaitMqtt().alias(alias).until(actual, isEqual(expected));
}
private void assertNullOrA(String expectedValue, A actual, String alias) {
if (expectedValue == null) {
assertNull(actual, alias);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment