//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldUseConcurrentlyCreatedNode() internal virtual void ShouldUseConcurrentlyCreatedNode() { // given GraphDatabaseService graphdb = mock(typeof(GraphDatabaseService)); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") Index<org.neo4j.graphdb.Node> index = mock(Index.class); Index <Node> index = mock(typeof(Index)); Transaction tx = mock(typeof(Transaction)); when(graphdb.BeginTx()).thenReturn(tx); when(index.GraphDatabase).thenReturn(graphdb); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") IndexHits<org.neo4j.graphdb.Node> getHits = mock(IndexHits.class); IndexHits <Node> getHits = mock(typeof(IndexHits)); when(index.get("key1", "value1")).thenReturn(getHits); Node createdNode = mock(typeof(Node)); when(graphdb.CreateNode()).thenReturn(createdNode); Node concurrentNode = mock(typeof(Node)); when(index.PutIfAbsent(createdNode, "key1", "value1")).thenReturn(concurrentNode); UniqueFactory.UniqueNodeFactory unique = new UniqueNodeFactoryAnonymousInnerClass(this, index); // when UniqueEntity <Node> node = unique.GetOrCreateWithOutcome("key1", "value1"); // then assertSame(node.Entity(), concurrentNode); assertFalse(node.WasCreated()); verify(index).get("key1", "value1"); verify(index).putIfAbsent(createdNode, "key1", "value1"); verify(graphdb, times(1)).createNode(); verify(tx).success(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldCreateNodeWithOutcomeAndIndexItIfMissing() internal virtual void ShouldCreateNodeWithOutcomeAndIndexItIfMissing() { // given GraphDatabaseService graphdb = mock(typeof(GraphDatabaseService)); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") Index<org.neo4j.graphdb.Node> index = mock(Index.class); Index <Node> index = mock(typeof(Index)); Transaction tx = mock(typeof(Transaction)); when(graphdb.BeginTx()).thenReturn(tx); when(index.GraphDatabase).thenReturn(graphdb); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") IndexHits<org.neo4j.graphdb.Node> indexHits = mock(IndexHits.class); IndexHits <Node> indexHits = mock(typeof(IndexHits)); when(index.get("key1", "value1")).thenReturn(indexHits); Node indexedNode = mock(typeof(Node)); when(graphdb.CreateNode()).thenReturn(indexedNode); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean initializeCalled = new java.util.concurrent.atomic.AtomicBoolean(false); AtomicBoolean initializeCalled = new AtomicBoolean(false); UniqueFactory.UniqueNodeFactory unique = new UniqueNodeFactoryAnonymousInnerClass3(this, index, initializeCalled); // when UniqueEntity <Node> node = unique.GetOrCreateWithOutcome("key1", "value1"); // then assertSame(node.Entity(), indexedNode); assertTrue(node.WasCreated()); verify(index).get("key1", "value1"); verify(index).putIfAbsent(indexedNode, "key1", "value1"); verify(graphdb, times(1)).createNode(); verify(tx).success(); assertTrue(initializeCalled.get(), "Node not initialized"); }