Skip to content
Snippets Groups Projects

Resolve "Feature: Send endpoint for relations"

Merged René Schöne requested to merge 37-feature-send-endpoint-for-relations into dev
2 files
+ 29
40
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -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);
Loading