//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleSingleNodePath() public virtual void ShouldHandleSingleNodePath() { // Given Node node; using (Transaction tx = Db.beginTx()) { node = Db.createNode(); tx.Success(); } // When Path mapped = _mapper.mapPath(path(AsNodeValues(node), AsRelationshipsValues())); // Then using (Transaction ignore = Db.beginTx()) { assertThat(mapped.Length(), equalTo(0)); assertThat(mapped.StartNode(), equalTo(node)); assertThat(mapped.EndNode(), equalTo(node)); assertThat(Iterables.asList(mapped.Relationships()), hasSize(0)); assertThat(Iterables.asList(mapped.ReverseRelationships()), hasSize(0)); assertThat(Iterables.asList(mapped.Nodes()), equalTo(singletonList(node))); assertThat(Iterables.asList(mapped.ReverseNodes()), equalTo(singletonList(node))); assertThat(mapped.LastRelationship(), nullValue()); assertThat(Iterators.asList(mapped.GetEnumerator()), equalTo(singletonList(node))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleSingleRelationshipPath() public virtual void ShouldHandleSingleRelationshipPath() { // Given Node start, end; Relationship relationship; using (Transaction tx = Db.beginTx()) { start = Db.createNode(); end = Db.createNode(); relationship = start.CreateRelationshipTo(end, RelationshipType.withName("R")); tx.Success(); } // When Path mapped = _mapper.mapPath(path(AsNodeValues(start, end), AsRelationshipsValues(relationship))); // Then using (Transaction ignore = Db.beginTx()) { assertThat(mapped.Length(), equalTo(1)); assertThat(mapped.StartNode(), equalTo(start)); assertThat(mapped.EndNode(), equalTo(end)); assertThat(Iterables.asList(mapped.Relationships()), equalTo(singletonList(relationship))); assertThat(Iterables.asList(mapped.ReverseRelationships()), equalTo(singletonList(relationship))); assertThat(Iterables.asList(mapped.Nodes()), equalTo(Arrays.asList(start, end))); assertThat(Iterables.asList(mapped.ReverseNodes()), equalTo(Arrays.asList(end, start))); assertThat(mapped.LastRelationship(), equalTo(relationship)); assertThat(Iterators.asList(mapped.GetEnumerator()), equalTo(Arrays.asList(start, relationship, end))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void copyConstructor() internal virtual void CopyConstructor() { Listeners <Listener> original = NewListeners(new Listener(), new Listener(), new Listener()); Listeners <Listener> copy = new Listeners <Listener>(original); assertEquals(Iterables.asList(original), Iterables.asList(copy)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void listenersIterable() internal virtual void ListenersIterable() { Listener listener1 = new Listener(); Listener listener2 = new Listener(); Listener listener3 = new Listener(); Listeners <Listener> listeners = NewListeners(listener1, listener2, listener3); assertEquals(Arrays.asList(listener1, listener2, listener3), Iterables.asList(listeners)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void remove() internal virtual void Remove() { Listener listener1 = new Listener(); Listener listener2 = new Listener(); Listener listener3 = new Listener(); Listeners <Listener> listeners = NewListeners(listener1, listener2, listener3); assertEquals(Arrays.asList(listener1, listener2, listener3), Iterables.asList(listeners)); listeners.Remove(listener1); assertEquals(Arrays.asList(listener2, listener3), Iterables.asList(listeners)); listeners.Remove(listener3); assertEquals(singletonList(listener2), Iterables.asList(listeners)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleLongPath() public virtual void ShouldHandleLongPath() { // Given Node a, b, c, d, e; Relationship r1, r2, r3, r4; using (Transaction tx = Db.beginTx()) { a = Db.createNode(); b = Db.createNode(); c = Db.createNode(); d = Db.createNode(); e = Db.createNode(); r1 = a.CreateRelationshipTo(b, RelationshipType.withName("R")); r2 = b.CreateRelationshipTo(c, RelationshipType.withName("R")); r3 = c.CreateRelationshipTo(d, RelationshipType.withName("R")); r4 = d.CreateRelationshipTo(e, RelationshipType.withName("R")); tx.Success(); } // When Path mapped = _mapper.mapPath(path(AsNodeValues(a, b, c, d, e), AsRelationshipsValues(r1, r2, r3, r4))); // Then using (Transaction ignore = Db.beginTx()) { assertThat(mapped.Length(), equalTo(4)); assertThat(mapped.StartNode(), equalTo(a)); assertThat(mapped.EndNode(), equalTo(e)); assertThat(Iterables.asList(mapped.Relationships()), equalTo(Arrays.asList(r1, r2, r3, r4))); assertThat(Iterables.asList(mapped.ReverseRelationships()), equalTo(Arrays.asList(r4, r3, r2, r1))); assertThat(Iterables.asList(mapped.Nodes()), equalTo(Arrays.asList(a, b, c, d, e))); assertThat(Iterables.asList(mapped.ReverseNodes()), equalTo(Arrays.asList(e, d, c, b, a))); assertThat(mapped.LastRelationship(), equalTo(r4)); assertThat(Iterators.asList(mapped.GetEnumerator()), equalTo(Arrays.asList(a, r1, b, r2, c, r3, d, r4, e))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHaveAvailableOrphanedConstraintIndexIfUniqueConstraintCreationFails() public virtual void ShouldHaveAvailableOrphanedConstraintIndexIfUniqueConstraintCreationFails() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction fs = fileSystemRule.get(); EphemeralFileSystemAbstraction fs = FileSystemRule.get(); fs.Mkdir(new File("/tmp")); File pathToDb = new File("/tmp/bar2"); TestGraphDatabaseFactory dbFactory = new TestGraphDatabaseFactory(); dbFactory.FileSystem = fs; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction[] storeInNeedOfRecovery = new org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction[1]; EphemeralFileSystemAbstraction[] storeInNeedOfRecovery = new EphemeralFileSystemAbstraction[1]; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean monitorCalled = new java.util.concurrent.atomic.AtomicBoolean(false); AtomicBoolean monitorCalled = new AtomicBoolean(false); Monitors monitors = new Monitors(); monitors.AddMonitorListener(new MonitorAdapterAnonymousInnerClass(this, fs, storeInNeedOfRecovery, monitorCalled)); dbFactory.Monitors = monitors; // This test relies on behaviour that is specific to the Lucene populator, where uniqueness is controlled // after index has been populated, which is why we're using NATIVE20 and index booleans (they end up in Lucene) _db = ( GraphDatabaseAPI )dbFactory.NewImpermanentDatabaseBuilder(pathToDb).setConfig(default_schema_provider, NATIVE20.providerName()).newGraphDatabase(); using (Transaction tx = _db.beginTx()) { for (int i = 0; i < 2; i++) { _db.createNode(_label).setProperty(KEY, true); } tx.Success(); } try { using (Transaction tx = _db.beginTx()) { _db.schema().constraintFor(_label).assertPropertyIsUnique(KEY).create(); fail("Should have failed with ConstraintViolationException"); tx.Success(); } } catch (ConstraintViolationException) { } _db.shutdown(); assertTrue(monitorCalled.get()); // when dbFactory = new TestGraphDatabaseFactory(); dbFactory.FileSystem = storeInNeedOfRecovery[0]; _db = ( GraphDatabaseAPI )dbFactory.NewImpermanentDatabase(pathToDb); // then using (Transaction ignore = _db.beginTx()) { _db.schema().awaitIndexesOnline(10, TimeUnit.SECONDS); } using (Transaction ignore = _db.beginTx()) { assertEquals(2, Iterables.count(_db.AllNodes)); } using (Transaction ignore = _db.beginTx()) { assertEquals(0, Iterables.count(Iterables.asList(_db.schema().Constraints))); } using (Transaction ignore = _db.beginTx()) { IndexDefinition orphanedConstraintIndex = single(_db.schema().Indexes); assertEquals(_label.name(), single(orphanedConstraintIndex.Labels).name()); assertEquals(KEY, single(orphanedConstraintIndex.PropertyKeys)); } _db.shutdown(); }