Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit c497f62

Browse files
committed
better test
1 parent 37d158b commit c497f62

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

vizceral/src/test/java/io/netifi/proteus/vizceral/service/VizceralBridgeTest.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
import java.io.InputStream;
1111
import java.time.Duration;
12+
import java.util.Collection;
1213
import java.util.List;
14+
import java.util.function.Function;
1315

14-
import static org.junit.Assert.assertEquals;
15-
import static org.junit.Assert.assertNotNull;
16+
import static org.junit.Assert.*;
1617

1718
public class VizceralBridgeTest {
1819

@@ -65,6 +66,26 @@ public void vizSource() {
6566
List<Node> nodeList = root.getNodesList();
6667
assertNotNull(nodeList);
6768
assertEquals(2, nodeList.size());
69+
boolean thereIsRequester = assertOneMatches(nodeList, (node) ->
70+
"quickstart.clients-client1".equals(node.getName())
71+
&&
72+
node.getConnectionsList().isEmpty());
73+
assertTrue(thereIsRequester);
74+
75+
boolean thereIsResponder = assertOneMatches(nodeList, (node) ->
76+
"quickstart.services.helloservices-helloservice-3fa7b9dc-7afd-4767-a781-b7265a9fa02d".equals(node.getName())
77+
&&
78+
node.getConnectionsList().isEmpty());
79+
assertTrue(thereIsResponder);
80+
}
81+
82+
private static <T> boolean assertOneMatches(Collection<T> it, Function<T, Boolean> assertion) {
83+
for (T t : it) {
84+
if (assertion.apply(t)) {
85+
return true;
86+
}
87+
}
88+
return false;
6889
}
6990

7091
private Mono<InputStream> zipkinMockSource() {

0 commit comments

Comments
 (0)