//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldObserveFirstRelationshipAsEmptyInEachDirection() public virtual void ShouldObserveFirstRelationshipAsEmptyInEachDirection() { // GIVEN _cache = new NodeRelationshipCache(NumberArrayFactory_Fields.AutoWithoutPagecache, 1, 100, Base); int nodes = 100; int typeId = 5; Direction[] directions = Direction.values(); GroupVisitor groupVisitor = mock(typeof(GroupVisitor)); _cache.setForwardScan(true, true); _cache.NodeCount = nodes + 1; for (int i = 0; i < nodes; i++) { assertEquals(-1L, _cache.getFirstRel(nodes, groupVisitor)); _cache.incrementCount(i); long previous = _cache.getAndPutRelationship(i, typeId, directions[i % directions.Length], Random.Next(1_000_000), true); assertEquals(-1L, previous); } // WHEN _cache.setForwardScan(false, true); for (int i = 0; i < nodes; i++) { long previous = _cache.getAndPutRelationship(i, typeId, directions[i % directions.Length], Random.Next(1_000_000), false); assertEquals(-1L, previous); } // THEN _cache.setForwardScan(true, true); for (int i = 0; i < nodes; i++) { assertEquals(-1L, _cache.getFirstRel(nodes, groupVisitor)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldKeepNextGroupIdForNextRound() public virtual void ShouldKeepNextGroupIdForNextRound() { // GIVEN _cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, 1, 100, Base); long nodeId = 0; int typeId = 10; _cache.NodeCount = nodeId + 1; _cache.incrementCount(nodeId); GroupVisitor groupVisitor = mock(typeof(GroupVisitor)); when(groupVisitor.Visit(anyLong(), anyInt(), anyLong(), anyLong(), anyLong())).thenReturn(1L, 2L, 3L); long firstRelationshipGroupId; { // WHEN importing the first type long relationshipId = 10; _cache.getAndPutRelationship(nodeId, typeId, OUTGOING, relationshipId, true); firstRelationshipGroupId = _cache.getFirstRel(nodeId, groupVisitor); // THEN assertEquals(1L, firstRelationshipGroupId); verify(groupVisitor).visit(nodeId, typeId, relationshipId, -1L, -1L); // Also simulate going back again ("clearing" of the cache requires this) _cache.setForwardScan(false, true); _cache.getAndPutRelationship(nodeId, typeId, OUTGOING, relationshipId, false); _cache.setForwardScan(true, true); } long secondRelationshipGroupId; { // WHEN importing the second type long relationshipId = 11; _cache.getAndPutRelationship(nodeId, typeId, INCOMING, relationshipId, true); secondRelationshipGroupId = _cache.getFirstRel(nodeId, groupVisitor); // THEN assertEquals(2L, secondRelationshipGroupId); verify(groupVisitor).visit(nodeId, typeId, -1, relationshipId, -1L); // Also simulate going back again ("clearing" of the cache requires this) _cache.setForwardScan(false, true); _cache.getAndPutRelationship(nodeId, typeId, OUTGOING, relationshipId, false); _cache.setForwardScan(true, true); } { // WHEN importing the third type long relationshipId = 10; _cache.getAndPutRelationship(nodeId, typeId, BOTH, relationshipId, true); long thirdRelationshipGroupId = _cache.getFirstRel(nodeId, groupVisitor); assertEquals(3L, thirdRelationshipGroupId); verify(groupVisitor).visit(nodeId, typeId, -1L, -1L, relationshipId); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGetAndPutRelationshipAroundChunkEdge() public virtual void ShouldGetAndPutRelationshipAroundChunkEdge() { // GIVEN _cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, 10); // WHEN long nodeId = 1_000_000 - 1; int typeId = 10; _cache.NodeCount = nodeId + 1; Direction direction = Direction.OUTGOING; long relId = 10; _cache.getAndPutRelationship(nodeId, typeId, direction, relId, false); // THEN assertEquals(relId, _cache.getFirstRel(nodeId, mock(typeof(GroupVisitor)))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCacheMultipleDenseNodeRelationshipHeads() public virtual void ShouldCacheMultipleDenseNodeRelationshipHeads() { // GIVEN _cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, 1); _cache.NodeCount = 10; long nodeId = 3; _cache.setCount(nodeId, 10, 0, OUTGOING); // WHEN IDictionary <Pair <int, Direction>, long> firstRelationshipIds = new Dictionary <Pair <int, Direction>, long>(); int typeCount = 3; for (int typeId = 0, relationshipId = 0; typeId < typeCount; typeId++) { foreach (Direction direction in Direction.values()) { long firstRelationshipId = relationshipId++; _cache.getAndPutRelationship(nodeId, typeId, direction, firstRelationshipId, true); firstRelationshipIds[Pair.of(typeId, direction)] = firstRelationshipId; } } AtomicInteger visitCount = new AtomicInteger(); GroupVisitor visitor = (nodeId1, typeId, @out, @in, loop) => { visitCount.incrementAndGet(); assertEquals(firstRelationshipIds[Pair.of(typeId, OUTGOING)], @out); assertEquals(firstRelationshipIds[Pair.of(typeId, INCOMING)], @in); assertEquals(firstRelationshipIds[Pair.of(typeId, BOTH)], loop); return(0); }; _cache.getFirstRel(nodeId, visitor); // THEN assertEquals(typeCount, visitCount.get()); }