summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
author@syxhe <t.me/syxhe>2025-10-01 21:26:08 -0500
committer@syxhe <t.me/syxhe>2025-10-01 21:26:08 -0500
commit7b84eb10c7c70dc83acd21afcc1ae631369428eb (patch)
treeee8c2f776be1fa4d052ed42f80884f5a30015ee7 /src/test/java
parentb95b043fd07f8e760b1863ff127bee2b1d2633c9 (diff)
Implement ChannelNode
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/ChannelNodeTest.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/test/java/ChannelNodeTest.java b/src/test/java/ChannelNodeTest.java
index 5623d72..6268a97 100644
--- a/src/test/java/ChannelNodeTest.java
+++ b/src/test/java/ChannelNodeTest.java
@@ -23,6 +23,14 @@ class ChannelNodeTest {
23 // Null direction should always throw 23 // Null direction should always throw
24 assertThrows(IllegalArgumentException.class, () -> testNodeA.setConnections(new HashMap<>(), null)); 24 assertThrows(IllegalArgumentException.class, () -> testNodeA.setConnections(new HashMap<>(), null));
25 25
26 // Self endpoint should throw
27 Map<IChannelNode, Integer> temp = new HashMap<>();
28 temp.put(testNodeA, 1);
29
30 assertThrows(IllegalArgumentException.class, () -> testNodeA.setConnections(temp, IChannelNode.Direction.INCOMING));
31 assertThrows(IllegalArgumentException.class, () -> testNodeA.setConnections(temp, IChannelNode.Direction.OUTGOING));
32 assertThrows(IllegalArgumentException.class, () -> testNodeA.setConnections(temp, IChannelNode.Direction.BOTH));
33
26 // Should not throw 34 // Should not throw
27 assertDoesNotThrow(() -> testNodeA.setConnections(new HashMap<>(), IChannelNode.Direction.INCOMING)); 35 assertDoesNotThrow(() -> testNodeA.setConnections(new HashMap<>(), IChannelNode.Direction.INCOMING));
28 assertDoesNotThrow(() -> testNodeA.setConnections(new HashMap<>(), IChannelNode.Direction.OUTGOING)); 36 assertDoesNotThrow(() -> testNodeA.setConnections(new HashMap<>(), IChannelNode.Direction.OUTGOING));
@@ -30,6 +38,36 @@ class ChannelNodeTest {
30 38
31 39
32 40
41 // Null endpoint should throw
42 assertThrows(IllegalArgumentException.class, () -> testNodeA.setNumConnections(null, null, -1));
43 assertThrows(IllegalArgumentException.class, () -> testNodeA.setNumConnections(null, IChannelNode.Direction.INCOMING, 1));
44 assertThrows(IllegalArgumentException.class, () -> testNodeA.setNumConnections(null, IChannelNode.Direction.OUTGOING, 1));
45 assertThrows(IllegalArgumentException.class, () -> testNodeA.setNumConnections(null, IChannelNode.Direction.BOTH, 1));
46
47 // Null direction should throw
48 assertThrows(IllegalArgumentException.class, () -> testNodeA.setNumConnections(testNodeB, null, 1));
49
50 // Self endpoint should throw
51 assertThrows(IllegalArgumentException.class, () -> testNodeA.setNumConnections(testNodeA, IChannelNode.Direction.INCOMING, 1));
52 assertThrows(IllegalArgumentException.class, () -> testNodeA.setNumConnections(testNodeA, IChannelNode.Direction.OUTGOING, 1));
53 assertThrows(IllegalArgumentException.class, () -> testNodeA.setNumConnections(testNodeA, IChannelNode.Direction.BOTH, 1));
54
55 // Negative connections should throw
56 assertThrows(IllegalArgumentException.class, () -> testNodeA.setNumConnections(testNodeB, IChannelNode.Direction.INCOMING, -1));
57 assertThrows(IllegalArgumentException.class, () -> testNodeA.setNumConnections(testNodeB, IChannelNode.Direction.OUTGOING, -1));
58 assertThrows(IllegalArgumentException.class, () -> testNodeA.setNumConnections(testNodeB, IChannelNode.Direction.BOTH, -1));
59
60 // Should not throw
61 assertDoesNotThrow(() -> testNodeA.setNumConnections(testNodeB, IChannelNode.Direction.INCOMING, 10));
62 assertDoesNotThrow(() -> testNodeA.setNumConnections(testNodeB, IChannelNode.Direction.OUTGOING, 10));
63 assertDoesNotThrow(() -> testNodeA.setNumConnections(testNodeB, IChannelNode.Direction.BOTH, 3));
64
65 assertDoesNotThrow(() -> testNodeB.setNumConnections(testNodeA, IChannelNode.Direction.INCOMING, 3));
66 assertDoesNotThrow(() -> testNodeB.setNumConnections(testNodeA, IChannelNode.Direction.OUTGOING, 5));
67 assertDoesNotThrow(() -> testNodeB.setNumConnections(testNodeA, IChannelNode.Direction.BOTH, 90));
68
69
70
33 // Null endpoint should always throw 71 // Null endpoint should always throw
34 assertThrows(IllegalArgumentException.class, () -> testNodeA.addConnection(null, null)); 72 assertThrows(IllegalArgumentException.class, () -> testNodeA.addConnection(null, null));
35 assertThrows(IllegalArgumentException.class, () -> testNodeA.addConnection(null, IChannelNode.Direction.INCOMING)); 73 assertThrows(IllegalArgumentException.class, () -> testNodeA.addConnection(null, IChannelNode.Direction.INCOMING));
@@ -45,6 +83,11 @@ class ChannelNodeTest {
45 assertThrows(IllegalArgumentException.class, () -> testNodeA.addConnection(testNodeB, null)); 83 assertThrows(IllegalArgumentException.class, () -> testNodeA.addConnection(testNodeB, null));
46 assertThrows(IllegalArgumentException.class, () -> testNodeB.addConnection(testNodeA, null)); 84 assertThrows(IllegalArgumentException.class, () -> testNodeB.addConnection(testNodeA, null));
47 85
86 // Should not throw
87 assertDoesNotThrow(() -> testNodeA.addConnection(testNodeB, IChannelNode.Direction.INCOMING));
88 assertDoesNotThrow(() -> testNodeA.addConnection(testNodeB, IChannelNode.Direction.OUTGOING));
89 assertDoesNotThrow(() -> testNodeA.addConnection(testNodeB, IChannelNode.Direction.BOTH));
90
48 91
49 92
50 // Null iterable should always throw 93 // Null iterable should always throw
@@ -62,6 +105,10 @@ class ChannelNodeTest {
62 assertThrows(IllegalArgumentException.class, () -> testNodeA.addConnections(List.of(new IChannelNode[]{testNodeA}), IChannelNode.Direction.OUTGOING)); 105 assertThrows(IllegalArgumentException.class, () -> testNodeA.addConnections(List.of(new IChannelNode[]{testNodeA}), IChannelNode.Direction.OUTGOING));
63 assertThrows(IllegalArgumentException.class, () -> testNodeA.addConnections(List.of(new IChannelNode[]{testNodeA}), IChannelNode.Direction.BOTH)); 106 assertThrows(IllegalArgumentException.class, () -> testNodeA.addConnections(List.of(new IChannelNode[]{testNodeA}), IChannelNode.Direction.BOTH));
64 107
108 // Should not throw
109 assertDoesNotThrow(() -> testNodeA.addConnections(List.of(new IChannelNode[]{testNodeB}), IChannelNode.Direction.INCOMING));
110 assertDoesNotThrow(() -> testNodeA.addConnections(List.of(new IChannelNode[]{testNodeB}), IChannelNode.Direction.OUTGOING));
111 assertDoesNotThrow(() -> testNodeA.addConnections(List.of(new IChannelNode[]{testNodeB}), IChannelNode.Direction.BOTH));
65 112
66 113
67 // Null node should always throw 114 // Null node should always throw
@@ -114,7 +161,18 @@ class ChannelNodeTest {
114 161
115 162
116 // Null direction should always throw 163 // Null direction should always throw
164 assertThrows(IllegalArgumentException.class, () -> testNodeA.getNumConnections(null));
165 assertDoesNotThrow(() -> testNodeA.getNumConnections(IChannelNode.Direction.INCOMING));
166 assertDoesNotThrow(() -> testNodeA.getNumConnections(IChannelNode.Direction.OUTGOING));
167 assertDoesNotThrow(() -> testNodeA.getNumConnections(IChannelNode.Direction.BOTH));
168
169
170
171 // Null direction should always throw
117 assertThrows(IllegalArgumentException.class, () -> testNodeA.getConnections(null)); 172 assertThrows(IllegalArgumentException.class, () -> testNodeA.getConnections(null));
173 assertDoesNotThrow(() -> testNodeA.getConnections(IChannelNode.Direction.INCOMING));
174 assertDoesNotThrow(() -> testNodeA.getConnections(IChannelNode.Direction.OUTGOING));
175 assertDoesNotThrow(() -> testNodeA.getConnections(IChannelNode.Direction.BOTH));
118 } 176 }
119 177
120} // End of ChannelNodeTest \ No newline at end of file 178} // End of ChannelNodeTest \ No newline at end of file