@@ -173,13 +173,34 @@ public void testViewIntersection() {
173173
174174 view .intersection (view2 );
175175
176+ // Positive assertions - expected elements ARE present
176177 Assert .assertTrue (view .containsNode (n1 ));
177178 Assert .assertTrue (view .containsNode (n2 ));
178179 Assert .assertTrue (view .containsEdge (e1 ));
180+
181+ // Negative assertions - elements not in intersection should be absent
179182 Assert .assertFalse (view .containsNode (n3 ));
180183 Assert .assertFalse (view .containsNode (n4 ));
181184 Assert .assertFalse (view .containsEdge (e2 ));
182185
186+ // Exact count assertions
187+ Assert .assertEquals (view .getNodeCount (), 2 , "Should have exactly 2 nodes after intersection" );
188+ Assert .assertEquals (view .getEdgeCount (), 1 , "Should have exactly 1 edge after intersection" );
189+
190+ // Verify no other elements from the graph are present
191+ for (Node n : graphStore .getNodes ()) {
192+ if (n != n1 && n != n2 ) {
193+ Assert .assertFalse (view
194+ .containsNode ((NodeImpl ) n ), "Node " + n .getId () + " should not be in view after intersection" );
195+ }
196+ }
197+ for (Edge e : graphStore .getEdges ()) {
198+ if (e != e1 ) {
199+ Assert .assertFalse (view
200+ .containsEdge ((EdgeImpl ) e ), "Edge " + e .getId () + " should not be in view after intersection" );
201+ }
202+ }
203+
183204 Assert .assertTrue (view2 .deepEquals (view ));
184205 }
185206
@@ -193,6 +214,7 @@ public void testViewIntersectionEdgeView() {
193214 view .fill ();
194215 view2 .fill ();
195216
217+ int totalEdges = graphStore .getEdgeCount ();
196218 EdgeImpl e1 = graphStore .getEdge ("0" );
197219 EdgeImpl e2 = graphStore .getEdge ("5" );
198220
@@ -201,8 +223,21 @@ public void testViewIntersectionEdgeView() {
201223
202224 view .intersection (view2 );
203225
226+ // Negative assertions - removed edges should be absent
204227 Assert .assertFalse (view .containsEdge (e1 ));
205228 Assert .assertFalse (view .containsEdge (e2 ));
229+
230+ // Exact count assertion - intersection excludes both removed edges
231+ Assert .assertEquals (view
232+ .getEdgeCount (), totalEdges - 2 , "Should have all edges except e1 and e2 after intersection" );
233+
234+ // Verify all other edges are present
235+ for (Edge e : graphStore .getEdges ()) {
236+ if (e != e1 && e != e2 ) {
237+ Assert .assertTrue (view
238+ .containsEdge ((EdgeImpl ) e ), "Edge " + e .getId () + " should be in view after intersection" );
239+ }
240+ }
206241 }
207242
208243 @ Test
@@ -215,6 +250,7 @@ public void testViewIntersectionNodeView() {
215250 view .fill ();
216251 view2 .fill ();
217252
253+ int totalNodes = graphStore .getNodeCount ();
218254 EdgeImpl e1 = graphStore .getEdge ("0" );
219255 EdgeImpl e2 = graphStore .getEdge ("5" );
220256 NodeImpl s1 = e1 .getSource ();
@@ -224,9 +260,21 @@ public void testViewIntersectionNodeView() {
224260
225261 view .intersection (view2 );
226262
227- Assert . assertFalse ( view . containsEdge ( e1 ));
263+ // Node intersection: s1 was removed from view2, so it should be absent
228264 Assert .assertFalse (view .containsNode (s1 ));
229- Assert .assertTrue (view .containsEdge (e2 ));
265+ Assert .assertEquals (view .getNodeCount (), totalNodes - 1 , "Should have all nodes except s1 after intersection" );
266+
267+ // Edge intersection: e1 removed because s1 is gone (node view), e2 present
268+ Assert .assertFalse (view .containsEdge (e1 ), "e1 should be absent (source node removed)" );
269+ Assert .assertTrue (view .containsEdge (e2 ), "e2 should be present" );
270+
271+ // Verify all other nodes are present
272+ for (Node n : graphStore .getNodes ()) {
273+ if (n != s1 ) {
274+ Assert .assertTrue (view
275+ .containsNode ((NodeImpl ) n ), "Node " + n .getId () + " should be in view after intersection" );
276+ }
277+ }
230278 }
231279
232280 @ Test
@@ -253,12 +301,31 @@ public void testViewUnion() {
253301
254302 view .union (view2 );
255303
304+ // Positive assertions - expected elements ARE present
256305 Assert .assertTrue (view .containsNode (n1 ));
257306 Assert .assertTrue (view .containsNode (n2 ));
258307 Assert .assertTrue (view .containsEdge (e1 ));
259308 Assert .assertTrue (view .containsNode (n3 ));
260309 Assert .assertTrue (view .containsNode (n4 ));
261310 Assert .assertTrue (view .containsEdge (e2 ));
311+
312+ // Exact count assertions - verify ONLY expected elements
313+ Assert .assertEquals (view .getNodeCount (), 4 , "Should have exactly 4 nodes after union" );
314+ Assert .assertEquals (view .getEdgeCount (), 2 , "Should have exactly 2 edges after union" );
315+
316+ // Negative assertions - verify other graph elements are NOT present
317+ for (Node n : graphStore .getNodes ()) {
318+ if (n != n1 && n != n2 && n != n3 && n != n4 ) {
319+ Assert .assertFalse (view
320+ .containsNode ((NodeImpl ) n ), "Node " + n .getId () + " should not be in view after union" );
321+ }
322+ }
323+ for (Edge e : graphStore .getEdges ()) {
324+ if (e != e1 && e != e2 ) {
325+ Assert .assertFalse (view
326+ .containsEdge ((EdgeImpl ) e ), "Edge " + e .getId () + " should not be in view after union" );
327+ }
328+ }
262329 }
263330
264331 @ Test
@@ -276,8 +343,20 @@ public void testViewUnionEdgeView() {
276343
277344 view .union (view2 );
278345
346+ // Positive assertions
279347 Assert .assertTrue (view .containsEdge (e1 ));
280348 Assert .assertTrue (view .containsEdge (e2 ));
349+
350+ // Exact count assertion
351+ Assert .assertEquals (view .getEdgeCount (), 2 , "Should have exactly 2 edges after union" );
352+
353+ // Negative assertions - verify other edges are NOT present
354+ for (Edge e : graphStore .getEdges ()) {
355+ if (e != e1 && e != e2 ) {
356+ Assert .assertFalse (view
357+ .containsEdge ((EdgeImpl ) e ), "Edge " + e .getId () + " should not be in view after union" );
358+ }
359+ }
281360 }
282361
283362 @ Test
@@ -300,8 +379,24 @@ public void testViewUnionNodeView() {
300379
301380 view .union (view2 );
302381
382+ // Positive assertions
303383 Assert .assertTrue (view .containsEdge (e1 ));
304- Assert .assertTrue (view .containsEdge (e2 ));
384+ Assert .assertTrue (view .containsEdge (e2 ), "e2 should be present (both endpoints are in union)" );
385+
386+ // All 4 nodes should be present
387+ Assert .assertTrue (view .containsNode (n1 ));
388+ Assert .assertTrue (view .containsNode (n2 ));
389+ Assert .assertTrue (view .containsNode (n3 ));
390+ Assert .assertTrue (view .containsNode (n4 ));
391+ Assert .assertEquals (view .getNodeCount (), 4 , "Should have exactly 4 nodes after union" );
392+
393+ // Verify no other nodes are present
394+ for (Node n : graphStore .getNodes ()) {
395+ if (n != n1 && n != n2 && n != n3 && n != n4 ) {
396+ Assert .assertFalse (view
397+ .containsNode ((NodeImpl ) n ), "Node " + n .getId () + " should not be in view after union" );
398+ }
399+ }
305400 }
306401
307402 @ Test
@@ -586,6 +681,7 @@ public void testIntersectionWithMutualEdges() {
586681 Assert .assertEquals (view1 .getUndirectedEdgeCount (), 1 , "View1 should have 1 undirected edge" );
587682
588683 // Remove one of the mutual edges from view2
684+ EdgeImpl e0 = graphStore .getEdge ("0" );
589685 EdgeImpl e1 = graphStore .getEdge ("1" );
590686 view2 .removeEdge (e1 );
591687
@@ -600,6 +696,10 @@ public void testIntersectionWithMutualEdges() {
600696 Assert .assertEquals (view1 .mutualEdgesCount , 0 , "View1 should have 0 mutual edges after intersection" );
601697 Assert .assertEquals (view1 .getEdgeCount (), 1 , "View1 should have 1 edge total" );
602698 Assert .assertEquals (view1 .getUndirectedEdgeCount (), 1 , "View1 should have 1 undirected edge" );
699+
700+ // Verify which edge remains
701+ Assert .assertTrue (view1 .containsEdge (e0 ), "e0 should remain after intersection" );
702+ Assert .assertFalse (view1 .containsEdge (e1 ), "e1 should be absent after intersection" );
603703 }
604704
605705 @ Test
@@ -634,6 +734,15 @@ public void testUnionWithMutualEdges() {
634734 Assert .assertEquals (view1 .mutualEdgesCount , 1 , "View1 should have mutual count of 1 after union" );
635735 Assert .assertEquals (view1 .getEdgeCount (), 2 , "View1 should have 2 edges total" );
636736 Assert .assertEquals (view1 .getUndirectedEdgeCount (), 1 , "View1 should have 1 undirected edge" );
737+
738+ // Verify both edges are present
739+ Assert .assertTrue (view1 .containsEdge (e0 ), "e0 should be present after union" );
740+ Assert .assertTrue (view1 .containsEdge (e1 ), "e1 should be present after union" );
741+
742+ // Verify only the expected nodes are present
743+ Assert .assertEquals (view1 .getNodeCount (), 2 , "Should have exactly 2 nodes" );
744+ Assert .assertTrue (view1 .containsNode (n1 ));
745+ Assert .assertTrue (view1 .containsNode (n2 ));
637746 }
638747
639748 @ Test
@@ -643,7 +752,6 @@ public void testNotWithMutualEdges() {
643752 GraphViewImpl view = store .createView ();
644753
645754 EdgeImpl e0 = graphStore .getEdge ("0" );
646- EdgeImpl e1 = graphStore .getEdge ("1" );
647755 NodeImpl n1 = e0 .getSource ();
648756 NodeImpl n2 = e0 .getTarget ();
649757
@@ -681,6 +789,7 @@ public void testIntersectionMultipleEdgeTypes() {
681789 // Verify initial state has multiple edge types
682790 int type0CountInitial = view1 .getEdgeCount (0 );
683791 int type1CountInitial = view1 .getEdgeCount (1 );
792+ int type2CountInitial = view1 .getEdgeCount (2 );
684793 Assert .assertTrue (type0CountInitial > 0 , "Should have type 0 edges" );
685794 Assert .assertTrue (type1CountInitial > 0 , "Should have type 1 edges" );
686795
@@ -700,9 +809,18 @@ public void testIntersectionMultipleEdgeTypes() {
700809 Assert .assertEquals (view1 .getEdgeCount (0 ), 0 , "View1 should have 0 type 0 edges after intersection" );
701810 Assert .assertEquals (view1
702811 .getEdgeCount (1 ), type1CountInitial , "View1 should have all type 1 edges after intersection" );
703- int type2CountInitial = view1 .getEdgeCount (2 );
812+ Assert .assertEquals (view1
813+ .getEdgeCount (2 ), type2CountInitial , "View1 should have all type 2 edges after intersection" );
704814 Assert .assertEquals (view1
705815 .getEdgeCount (), type1CountInitial + type2CountInitial , "Total edge count should match sum of type 1 and type 2" );
816+
817+ // Verify no type 0 edges are present
818+ for (Edge e : graphStore .getEdges ()) {
819+ if (e .getType () == 0 ) {
820+ Assert .assertFalse (view1 .containsEdge ((EdgeImpl ) e ), "Type 0 edge " + e
821+ .getId () + " should not be in view after intersection" );
822+ }
823+ }
706824 }
707825
708826 @ Test
@@ -749,6 +867,12 @@ public void testUnionMultipleEdgeTypes() {
749867 Assert .assertEquals (view1 .getEdgeCount (2 ), type2Count , "View1 should have all type 2 edges after union" );
750868 Assert .assertEquals (view1
751869 .getEdgeCount (), type0Count + type1Count + type2Count , "Total should be sum of all types" );
870+
871+ // Verify all edges of each type are present
872+ for (Edge e : graphStore .getEdges ()) {
873+ Assert .assertTrue (view1 .containsEdge ((EdgeImpl ) e ), "Edge " + e .getId () + " of type " + e
874+ .getType () + " should be in view after union" );
875+ }
752876 }
753877
754878 @ Test
@@ -808,6 +932,16 @@ public void testIntersectionWithEmptyView() {
808932
809933 Assert .assertEquals (view1 .getNodeCount (), 0 , "View1 should be empty after intersection with empty view" );
810934 Assert .assertEquals (view1 .getEdgeCount (), 0 , "View1 should have no edges after intersection with empty view" );
935+
936+ // Verify all elements are absent
937+ for (Node n : graphStore .getNodes ()) {
938+ Assert .assertFalse (view1 .containsNode ((NodeImpl ) n ), "Node " + n
939+ .getId () + " should not be in view after intersection with empty view" );
940+ }
941+ for (Edge e : graphStore .getEdges ()) {
942+ Assert .assertFalse (view1 .containsEdge ((EdgeImpl ) e ), "Edge " + e
943+ .getId () + " should not be in view after intersection with empty view" );
944+ }
811945 }
812946
813947 @ Test
@@ -828,6 +962,12 @@ public void testIntersectionOfEmptyView() {
828962
829963 Assert .assertEquals (view1 .getNodeCount (), 0 , "View1 should still be empty after intersection" );
830964 Assert .assertEquals (view1 .getEdgeCount (), 0 , "View1 should still have no edges after intersection" );
965+
966+ // Verify all elements are absent
967+ for (Node n : graphStore .getNodes ()) {
968+ Assert .assertFalse (view1 .containsNode ((NodeImpl ) n ), "Node " + n
969+ .getId () + " should not be in empty view after intersection" );
970+ }
831971 }
832972
833973 @ Test
@@ -851,6 +991,16 @@ public void testUnionWithEmptyView() {
851991
852992 Assert .assertEquals (view1 .getNodeCount (), initialNodeCount , "View1 node count should not change" );
853993 Assert .assertEquals (view1 .getEdgeCount (), initialEdgeCount , "View1 edge count should not change" );
994+
995+ // Verify all elements are still present
996+ for (Node n : graphStore .getNodes ()) {
997+ Assert .assertTrue (view1 .containsNode ((NodeImpl ) n ), "Node " + n
998+ .getId () + " should still be in view after union with empty view" );
999+ }
1000+ for (Edge e : graphStore .getEdges ()) {
1001+ Assert .assertTrue (view1 .containsEdge ((EdgeImpl ) e ), "Edge " + e
1002+ .getId () + " should still be in view after union with empty view" );
1003+ }
8541004 }
8551005
8561006 @ Test
@@ -873,6 +1023,14 @@ public void testUnionOfEmptyView() {
8731023
8741024 Assert .assertEquals (view1 .getNodeCount (), view2NodeCount , "View1 should have same node count as view2" );
8751025 Assert .assertEquals (view1 .getEdgeCount (), view2EdgeCount , "View1 should have same edge count as view2" );
1026+
1027+ // Verify all elements are present
1028+ for (Node n : graphStore .getNodes ()) {
1029+ Assert .assertTrue (view1 .containsNode ((NodeImpl ) n ), "Node " + n .getId () + " should be in view after union" );
1030+ }
1031+ for (Edge e : graphStore .getEdges ()) {
1032+ Assert .assertTrue (view1 .containsEdge ((EdgeImpl ) e ), "Edge " + e .getId () + " should be in view after union" );
1033+ }
8761034 }
8771035
8781036 @ Test
@@ -918,6 +1076,12 @@ public void testIntersectionBothEmpty() {
9181076
9191077 Assert .assertEquals (view1 .getNodeCount (), 0 , "View1 should still be empty" );
9201078 Assert .assertEquals (view1 .getEdgeCount (), 0 , "View1 should still have no edges" );
1079+
1080+ // Verify all elements are absent (trivial case but validates correctness)
1081+ for (Node n : graphStore .getNodes ()) {
1082+ Assert .assertFalse (view1
1083+ .containsNode ((NodeImpl ) n ), "No nodes should be in view after intersection of empty views" );
1084+ }
9211085 }
9221086
9231087 @ Test
@@ -936,6 +1100,12 @@ public void testUnionBothEmpty() {
9361100
9371101 Assert .assertEquals (view1 .getNodeCount (), 0 , "View1 should still be empty" );
9381102 Assert .assertEquals (view1 .getEdgeCount (), 0 , "View1 should still have no edges" );
1103+
1104+ // Verify all elements are absent (trivial case but validates correctness)
1105+ for (Node n : graphStore .getNodes ()) {
1106+ Assert .assertFalse (view1
1107+ .containsNode ((NodeImpl ) n ), "No nodes should be in view after union of empty views" );
1108+ }
9391109 }
9401110
9411111 // ========== Tests for Retain Operations ==========
@@ -1032,7 +1202,6 @@ public void testRetainNodesWithMutualEdges() {
10321202 view .fill ();
10331203
10341204 EdgeImpl e0 = graphStore .getEdge ("0" );
1035- EdgeImpl e1 = graphStore .getEdge ("1" );
10361205 NodeImpl n1 = e0 .getSource ();
10371206 NodeImpl n2 = e0 .getTarget ();
10381207
0 commit comments