private void ReadAllRels(Node node) { foreach (Relationship relationship in node.Relationships) { ReadEachProperty(relationship); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void myFriendsAsWellAsYourFriends() public virtual void MyFriendsAsWellAsYourFriends() { /* * Hey, this looks like a futuristic gun or something * * (f8) _----(f1)--(f5) * | / / * (f7)--(you)--(me)--(f2)--(f6) * | / \ * (f4) (f3) */ CreateGraph("you KNOW me", "you KNOW f1", "you KNOW f4", "me KNOW f1", "me KNOW f4", "me KNOW f2", "me KNOW f3", "f1 KNOW f5", "f2 KNOW f6", "you KNOW f7", "f7 KNOW f8"); using (Transaction tx = BeginTx()) { RelationshipType knowRelType = withName("KNOW"); Node you = GetNodeWithName("you"); Node me = GetNodeWithName("me"); string[] levelOneFriends = new string[] { "f1", "f2", "f3", "f4", "f7" }; TraversalDescription levelOneTraversal = GraphDb.traversalDescription().relationships(knowRelType).evaluator(atDepth(1)); ExpectNodes(levelOneTraversal.DepthFirst().traverse(you, me), levelOneFriends); ExpectNodes(levelOneTraversal.BreadthFirst().traverse(you, me), levelOneFriends); string[] levelTwoFriends = new string[] { "f5", "f6", "f8" }; TraversalDescription levelTwoTraversal = GraphDb.traversalDescription().relationships(knowRelType).evaluator(atDepth(2)); ExpectNodes(levelTwoTraversal.DepthFirst().traverse(you, me), levelTwoFriends); ExpectNodes(levelTwoTraversal.BreadthFirst().traverse(you, me), levelTwoFriends); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void validateNodePropertiesOnPopulation() internal virtual void ValidateNodePropertiesOnPopulation() { setUp(); Label label = Label.label("populationTestNodeLabel"); string propertyName = "populationTestPropertyName"; using (Transaction transaction = _database.beginTx()) { Node node = _database.createNode(label); node.SetProperty(propertyName, StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1)); transaction.Success(); } IndexDefinition indexDefinition = CreateIndex(label, propertyName); try { using (Transaction ignored = _database.beginTx()) { _database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES); } } catch (System.InvalidOperationException) { using (Transaction ignored = _database.beginTx()) { string indexFailure = _database.schema().getIndexFailure(indexDefinition); assertThat(indexFailure, allOf(containsString("java.lang.IllegalArgumentException:"), containsString("Please see index documentation for limitations."))); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNotFoundException() public virtual void TestNotFoundException() { Node node1 = _graph.createNode(); Node node2 = _graph.createNode(); Relationship rel = node1.CreateRelationshipTo(node2, MyRelTypes.TEST); long nodeId = node1.Id; long relId = rel.Id; rel.Delete(); node2.Delete(); node1.Delete(); NewTransaction(); try { _graph.getNodeById(nodeId); fail("Get node by id on deleted node should throw exception"); } catch (NotFoundException) { // good } try { _graph.getRelationshipById(relId); fail("Get relationship by id on deleted node should " + "throw exception"); } catch (NotFoundException) { // good } // Finally Rollback(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldOnlyIndexIndexedProperties() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldOnlyIndexIndexedProperties() { IndexReference index; using (KernelTransactionImplementation tx = KernelTransaction) { SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, PROP); index = tx.SchemaWrite().indexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME); tx.Success(); } Await(index); long firstID; using (Transaction tx = Db.beginTx()) { firstID = CreateNodeIndexableByPropertyValue(Label, "Hello. Hello again."); SetNodeProp(firstID, "prop2", "zebra"); Node node2 = Db.createNode(Label); node2.SetProperty("prop2", "zebra"); node2.SetProperty("prop3", "hello"); tx.Success(); } using (Transaction tx = Db.beginTx()) { KernelTransaction ktx = KernelTransaction(tx); AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "hello", firstID); AssertQueryFindsNothing(ktx, NODE_INDEX_NAME, "zebra"); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void removalOfRelationshipIndexDoesNotInfluenceNodeIndexWithSameName() public virtual void RemovalOfRelationshipIndexDoesNotInfluenceNodeIndexWithSameName() { string indexName = "index"; CreateNodeExplicitIndexWithSingleNode(Db, indexName); CreateRelationshipExplicitIndexWithSingleRelationship(Db, indexName); using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(); Index <Node> nodeIndex = Db.index().forNodes(indexName); nodeIndex.Add(node, "key", "otherValue"); Index <Relationship> relationshipIndex = Db.index().forRelationships(indexName); relationshipIndex.Delete(); tx.Success(); } using (Transaction tx = Db.beginTx()) { assertFalse(Db.index().existsForRelationships(indexName)); Index <Node> nodeIndex = Db.index().forNodes(indexName); assertEquals(2, SizeOf(nodeIndex)); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowIllegalArgumentChangingTypeOfFieldOnRelationshipIndex() public virtual void ShouldThrowIllegalArgumentChangingTypeOfFieldOnRelationshipIndex() { string indexName = "index"; CreateRelationshipExplicitIndexWithSingleRelationship(Db, indexName); long relId; using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(); Relationship rel = node.CreateRelationshipTo(node, _type); relId = rel.Id; RelationshipIndex index = Db.index().forRelationships(indexName); index.add(rel, "key", "otherValue"); tx.Success(); } using (Transaction tx = Db.beginTx()) { RelationshipIndex index = Db.index().forRelationships(indexName); index.remove(Db.getRelationshipById(relId), "key"); tx.Success(); } ExpectedException.expect(typeof(System.ArgumentException)); using (Transaction tx = Db.beginTx()) { RelationshipIndex index = Db.index().forRelationships(indexName); index.add(Db.getRelationshipById(relId), "key", ValueContext.numeric(52)); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void compositeNodeKeyConstraintUpdate() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CompositeNodeKeyConstraintUpdate() { GraphDatabaseService database = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(TestDirectory.storeDir()).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase(); Label label = Label.label("label"); using (Transaction transaction = database.BeginTx()) { Node node = database.CreateNode(label); node.SetProperty("b", ( short )3); node.SetProperty("a", new double[] { 0.6, 0.4, 0.2 }); transaction.Success(); } using (Transaction transaction = database.BeginTx()) { string query = format("CREATE CONSTRAINT ON (n:%s) ASSERT (n.%s,n.%s) IS NODE KEY", label.Name(), "a", "b"); database.Execute(query); transaction.Success(); } AwaitIndex(database); using (Transaction transaction = database.BeginTx()) { Node node = database.CreateNode(label); node.SetProperty("a", ( short )7); node.SetProperty("b", new double[] { 0.7, 0.5, 0.3 }); transaction.Success(); } database.Shutdown(); ConsistencyCheckService.Result consistencyCheckResult = CheckDbConsistency(TestDirectory.storeDir()); assertTrue("Database is consistent", consistencyCheckResult.Successful); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUpdateRelationshipWithLabelCountsWhenRemovingLabelAndDeletingRelationship() public virtual void ShouldUpdateRelationshipWithLabelCountsWhenRemovingLabelAndDeletingRelationship() { // given Node foo; using (Transaction tx = Db.beginTx()) { foo = Db.createNode(label("Foo")); Node bar = Db.createNode(label("Bar")); foo.CreateRelationshipTo(bar, withName("BAZ")); tx.Success(); } long before = NumberOfRelationshipsMatching(label("Foo"), withName("BAZ"), null); // when using (Transaction tx = Db.beginTx()) { foreach (Relationship relationship in foo.Relationships) { relationship.Delete(); } foo.RemoveLabel(label("Foo")); tx.Success(); } long after = NumberOfRelationshipsMatching(label("Foo"), withName("BAZ"), null); // then assertEquals(before - 1, after); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateACountsStoreWhenThereAreUnusedNodeRecordsInTheDB() public virtual void ShouldCreateACountsStoreWhenThereAreUnusedNodeRecordsInTheDB() { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("deprecation") final org.neo4j.kernel.internal.GraphDatabaseAPI db = (org.neo4j.kernel.internal.GraphDatabaseAPI) dbBuilder.newGraphDatabase(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase(); using (Transaction tx = Db.beginTx()) { Db.createNode(Label.label("A")); Db.createNode(Label.label("C")); Node node = Db.createNode(Label.label("D")); Db.createNode(); node.Delete(); tx.Success(); } long lastCommittedTransactionId = GetLastTxId(db); Db.shutdown(); RebuildCounts(lastCommittedTransactionId); using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker()); assertEquals(BASE_TX_ID + 1 + 1 + 1 + 1, store.TxId()); assertEquals(3, store.TotalEntriesStored()); assertEquals(3, Get(store, nodeKey(-1))); assertEquals(1, Get(store, nodeKey(0))); assertEquals(1, Get(store, nodeKey(1))); assertEquals(0, Get(store, nodeKey(2))); assertEquals(0, Get(store, nodeKey(3))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void visitsRelationshipTypeIds() public virtual void VisitsRelationshipTypeIds() { // GIVEN DbStructureVisitor visitor = mock(typeof(DbStructureVisitor)); Node lhs = _graph.createNode(); Node rhs = _graph.createNode(); lhs.CreateRelationshipTo(rhs, withName("KNOWS")); lhs.CreateRelationshipTo(rhs, withName("LOVES")); lhs.CreateRelationshipTo(rhs, withName("FAWNS_AT")); int knowsId; int lovesId; int fawnsAtId; KernelTransaction ktx = ktx(); TokenRead tokenRead = ktx.TokenRead(); knowsId = tokenRead.RelationshipType("KNOWS"); lovesId = tokenRead.RelationshipType("LOVES"); fawnsAtId = tokenRead.RelationshipType("FAWNS_AT"); // WHEN Accept(visitor); // THEN verify(visitor).visitRelationshipType(knowsId, "KNOWS"); verify(visitor).visitRelationshipType(lovesId, "LOVES"); verify(visitor).visitRelationshipType(fawnsAtId, "FAWNS_AT"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void firstRecordOtherThanZeroIfNotFirst() public virtual void FirstRecordOtherThanZeroIfNotFirst() { File storeDir = TestDirectory.databaseDir(); GraphDatabaseAPI db = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(storeDir); Transaction tx = Db.beginTx(); Node node = Db.createNode(); node.SetProperty("name", "Yo"); tx.Success(); tx.Close(); Db.shutdown(); db = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(storeDir); tx = Db.beginTx(); Properties(db).setProperty("test", "something"); tx.Success(); tx.Close(); Db.shutdown(); Config config = Config.defaults(); StoreFactory storeFactory = new StoreFactory(TestDirectory.databaseLayout(), config, new DefaultIdGeneratorFactory(Fs.get()), PageCacheRule.getPageCache(Fs.get()), Fs.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY); NeoStores neoStores = storeFactory.OpenAllNeoStores(); long prop = neoStores.MetaDataStore.GraphNextProp; assertTrue(prop != 0); neoStores.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testBasicPropagationFromSlaveToMaster() public virtual void TestBasicPropagationFromSlaveToMaster() { // given ClusterManager.ManagedCluster cluster = ClusterRule.startCluster(); HighlyAvailableGraphDatabase master = cluster.Master; HighlyAvailableGraphDatabase slave = cluster.AnySlave; long nodeId; // a node with a property using (Transaction tx = master.BeginTx()) { Node node = master.CreateNode(); nodeId = node.Id; node.SetProperty("foo", "bar"); tx.Success(); } cluster.Sync(); // when // the slave does a change using (Transaction tx = slave.BeginTx()) { slave.GetNodeById(nodeId).setProperty("foo", "bar2"); tx.Success(); } // then // the master must pick up the change using (Transaction tx = master.BeginTx()) { assertEquals("bar2", master.GetNodeById(nodeId).getProperty("foo")); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testBasicPropagationFromMasterToSlave() public virtual void TestBasicPropagationFromMasterToSlave() { // given ClusterManager.ManagedCluster cluster = ClusterRule.startCluster(); long nodeId = 4; HighlyAvailableGraphDatabase master = cluster.Master; using (Transaction tx = master.BeginTx()) { Node node = master.CreateNode(); node.SetProperty("Hello", "World"); nodeId = node.Id; tx.Success(); } cluster.Sync(); // No need to wait, the push factor is 2 HighlyAvailableGraphDatabase slave1 = cluster.AnySlave; CheckNodeOnSlave(nodeId, slave1); HighlyAvailableGraphDatabase slave2 = cluster.GetAnySlave(slave1); CheckNodeOnSlave(nodeId, slave2); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void slaveShouldMoveToPendingAndThenRecoverIfMasterDiesAndThenRecovers() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SlaveShouldMoveToPendingAndThenRecoverIfMasterDiesAndThenRecovers() { HighlyAvailableGraphDatabase master = _cluster.Master; HighlyAvailableGraphDatabase theSlave = _cluster.AnySlave; string propertyName = "prop"; string propertyValue = "value1"; long slaveNodeId; ClusterManager.RepairKit repairKit = _cluster.fail(master); _cluster.await(memberSeesOtherMemberAsFailed(theSlave, master)); assertEquals(HighAvailabilityMemberState.PENDING, theSlave.InstanceState); repairKit.Repair(); _cluster.await(allSeesAllAsAvailable()); using (Transaction tx = theSlave.BeginTx()) { Node node = theSlave.CreateNode(); slaveNodeId = node.Id; node.SetProperty(propertyName, propertyValue); tx.Success(); } using (Transaction tx = master.BeginTx()) { assertEquals(propertyValue, master.GetNodeById(slaveNodeId).getProperty(propertyName)); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportTotalNumberOfRelationships() public virtual void ShouldReportTotalNumberOfRelationships() { // given GraphDatabaseService graphDb = Db.GraphDatabaseAPI; long before = NumberOfRelationships(); long during; using (Transaction tx = graphDb.BeginTx()) { Node node = graphDb.CreateNode(); node.CreateRelationshipTo(graphDb.CreateNode(), withName("KNOWS")); node.CreateRelationshipTo(graphDb.CreateNode(), withName("KNOWS")); node.CreateRelationshipTo(graphDb.CreateNode(), withName("KNOWS")); during = CountsForRelationship(null, null, null); tx.Success(); } // when long after = NumberOfRelationships(); // then assertEquals(0, before); assertEquals(3, during); assertEquals(3, after); }
private StoreAccess CreateStoreWithOneHighDegreeNodeAndSeveralDegreeTwoNodes(int nDegreeTwoNodes) { File storeDirectory = _testDirectory.databaseDir(); GraphDatabaseService database = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDirectory).setConfig(GraphDatabaseSettings.record_format, RecordFormatName).setConfig("dbms.backup.enabled", "false").newGraphDatabase(); using (Transaction transaction = database.BeginTx()) { Node denseNode = database.CreateNode(); for (int i = 0; i < nDegreeTwoNodes; i++) { Node degreeTwoNode = database.CreateNode(); Node leafNode = database.CreateNode(); if (i % 2 == 0) { denseNode.CreateRelationshipTo(degreeTwoNode, TestRelationshipType.Connected); } else { degreeTwoNode.CreateRelationshipTo(denseNode, TestRelationshipType.Connected); } degreeTwoNode.CreateRelationshipTo(leafNode, TestRelationshipType.Connected); } transaction.Success(); } database.Shutdown(); PageCache pageCache = PageCacheRule.getPageCache(_fileSystemRule.get()); StoreAccess storeAccess = new StoreAccess(_fileSystemRule.get(), pageCache, _testDirectory.databaseLayout(), Config.defaults()); return(storeAccess.Initialize()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void requirePropertyFromMultipleNodeKeys() public virtual void RequirePropertyFromMultipleNodeKeys() { Label label = Label.label("multiNodeKeyLabel"); SchemaHelper.createNodeKeyConstraint(Db, label, "property1", "property2"); SchemaHelper.createNodeKeyConstraint(Db, label, "property2", "property3"); SchemaHelper.createNodeKeyConstraint(Db, label, "property3", "property4"); assertException(() => { using (Org.Neo4j.Graphdb.Transaction transaction = Db.beginTx()) { Node node = Db.createNode(label); node.setProperty("property1", "1"); node.setProperty("property2", "2"); transaction.Success(); } }, typeof(ConstraintViolationException), "Node(0) with label `multiNodeKeyLabel` must have the properties `property2, property3`"); assertException(() => { using (Org.Neo4j.Graphdb.Transaction transaction = Db.beginTx()) { Node node = Db.createNode(label); node.setProperty("property1", "1"); node.setProperty("property2", "2"); node.setProperty("property3", "3"); transaction.Success(); } }, typeof(ConstraintViolationException), "Node(1) with label `multiNodeKeyLabel` must have the properties `property3, property4`"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowIllegalArgumentChangingTypeOfFieldOnNodeIndex() public virtual void ShouldThrowIllegalArgumentChangingTypeOfFieldOnNodeIndex() { string indexName = "index"; CreateNodeExplicitIndexWithSingleNode(Db, indexName); long nodeId; using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(); nodeId = node.Id; Index <Node> nodeIndex = Db.index().forNodes(indexName); nodeIndex.Add(node, "key", "otherValue"); tx.Success(); } using (Transaction tx = Db.beginTx()) { Index <Node> nodeIndex = Db.index().forNodes(indexName); nodeIndex.Remove(Db.getNodeById(nodeId), "key"); tx.Success(); } ExpectedException.expect(typeof(System.ArgumentException)); using (Transaction tx = Db.beginTx()) { Index <Node> nodeIndex = Db.index().forNodes(indexName); nodeIndex.Add(Db.getNodeById(nodeId), "key", ValueContext.numeric(52)); tx.Success(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.util.concurrent.Future<org.neo4j.graphdb.Lock> tryToAcquireSameLockOnAnotherThread(org.neo4j.graphdb.Node resource, org.neo4j.test.OtherThreadExecutor<Void> otherThread) throws Exception private Future <Lock> TryToAcquireSameLockOnAnotherThread(Node resource, OtherThreadExecutor <Void> otherThread) { Future <Lock> future = otherThread.ExecuteDontWait(AcquireWriteLock(resource)); otherThread.WaitUntilWaiting(); return(future); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToAddNodesAfterRemovalOfKey() public virtual void ShouldBeAbleToAddNodesAfterRemovalOfKey() { string indexName = "index"; long nodeId; //add two keys and delete one of them using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(); nodeId = node.Id; Index <Node> nodeIndex = Db.index().forNodes(indexName); nodeIndex.Add(node, "key", "hej"); nodeIndex.Add(node, "keydelete", "hej"); tx.Success(); } using (Transaction tx = Db.beginTx()) { Index <Node> nodeIndex = Db.index().forNodes(indexName); nodeIndex.Remove(Db.getNodeById(nodeId), "keydelete"); tx.Success(); } Db.shutdownAndKeepStore(); Db.GraphDatabaseAPI; //should be able to add more stuff to the index using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(); Index <Node> nodeIndex = Db.index().forNodes(indexName); nodeIndex.Add(node, "key", "hej"); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void nestedTransactionCanAcquireLocksFromTransactionObject() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void NestedTransactionCanAcquireLocksFromTransactionObject() { // given Node resource = CreateNode(); using (Transaction outerTx = _db.beginTx(), Transaction nestedTx = _db.beginTx()) { assertNotSame(outerTx, nestedTx); using (OtherThreadExecutor <Void> otherThread = new OtherThreadExecutor <Void>("other thread", null)) { // when Lock @lock = nestedTx.AcquireWriteLock(resource); Future <Lock> future = TryToAcquireSameLockOnAnotherThread(resource, otherThread); // then AcquireOnOtherThreadTimesOut(future); // and when @lock.Release(); //then assertNotNull(future.get()); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGiveNiceErrorWhenShutdownLegacy() public virtual void ShouldGiveNiceErrorWhenShutdownLegacy() { GraphDatabaseService graphDb = _graph; Node node = graphDb.CreateNode(); Commit(); graphDb.Shutdown(); try { node.Relationships; fail("Did not get a nice exception"); } catch (DatabaseShutdownException) { // good } try { graphDb.CreateNode(); fail("Create node did not produce expected error"); } catch (DatabaseShutdownException) { // good } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPropagateRelationshipCountsInHA() throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPropagateRelationshipCountsInHA() { ManagedCluster cluster = ClusterRule.startCluster(); HighlyAvailableGraphDatabase master = cluster.Master; using (Transaction tx = master.BeginTx()) { Node left = master.CreateNode(); Node right = master.CreateNode(Label.label("A")); left.CreateRelationshipTo(right, RelationshipType.withName("Type")); tx.Success(); } cluster.Sync(); foreach (HighlyAvailableGraphDatabase db in cluster.AllMembers) { using ([email protected] tx = Db.DependencyResolver.resolveDependency(typeof(Kernel)).beginTransaction(@explicit, AUTH_DISABLED)) { assertEquals(1, tx.dataRead().countsForRelationship(-1, -1, -1)); assertEquals(1, tx.dataRead().countsForRelationship(-1, -1, 0)); assertEquals(1, tx.dataRead().countsForRelationship(-1, 0, -1)); assertEquals(1, tx.dataRead().countsForRelationship(-1, 0, 0)); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSearchAcrossMultipleProperties() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSearchAcrossMultipleProperties() { IndexReference index; using (KernelTransactionImplementation tx = KernelTransaction) { SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, "prop", "prop2"); index = tx.SchemaWrite().indexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME); tx.Success(); } Await(index); long firstID; long secondID; long thirdID; using (Transaction tx = Db.beginTx()) { firstID = CreateNodeIndexableByPropertyValue(Label, "Tomtar tomtar oftsat i tomteutstyrsel."); secondID = CreateNodeIndexableByPropertyValue(Label, "Olof och Hans"); SetNodeProp(secondID, "prop2", "och karl"); Node node3 = Db.createNode(Label); thirdID = node3.Id; node3.SetProperty("prop2", "Tomtar som inte tomtar ser upp till tomtar som tomtar."); tx.Success(); } using (Transaction tx = Db.beginTx()) { KernelTransaction ktx = KernelTransaction(tx); AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "tomtar Karl", firstID, secondID, thirdID); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testIndexDeleteIssue() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestIndexDeleteIssue() { using (Transaction tx = Db.beginTx()) { Db.index().forNodes("index"); tx.Success(); } ShutdownDB(); Db.ensureStarted(); Index <Node> index; Index <Node> index2; using (Transaction tx = Db.beginTx()) { index = Db.index().forNodes("index"); index2 = Db.index().forNodes("index2"); Node node = Db.createNode(); index.Add(node, "key", "value"); tx.Success(); } using (Transaction tx = Db.beginTx()) { index.Delete(); index2.Add(Db.createNode(), "key", "value"); tx.Success(); } Db.shutdown(); Db.ensureStarted(); ForceRecover(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode() public virtual void ShouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode() { RelationshipType type = MyRelTypes.TEST; long startId; long endId; Relationship rel; using (Transaction tx = Db.beginTx()) { Node start = Db.createNode(); Node end = Db.createNode(); startId = start.Id; endId = end.Id; rel = start.CreateRelationshipTo(end, type); rel.SetProperty("Type", type.Name()); tx.Success(); } using (Transaction tx = Db.beginTx()) { ReadableRelationshipIndex autoRelationshipIndex = Db.index().RelationshipAutoIndexer.AutoIndex; Node start = Db.getNodeById(startId); Node end = Db.getNodeById(endId); IndexHits <Relationship> hits = autoRelationshipIndex.Get("Type", type.Name(), start, end); assertEquals(1, count(hits)); assertEquals(1, hits.Size()); rel.Delete(); autoRelationshipIndex = Db.index().RelationshipAutoIndexer.AutoIndex; hits = autoRelationshipIndex.Get("Type", type.Name(), start, end); assertEquals(0, count(hits)); assertEquals(0, hits.Size()); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void recoveryForRelationshipCommandsOnly() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RecoveryForRelationshipCommandsOnly() { // shutdown db here DatabaseLayout databaseLayout = Db.databaseLayout(); ShutdownDB(); using (Transaction tx = Db.beginTx()) { Index <Relationship> index = Db.index().forRelationships("myIndex"); Node node = Db.createNode(); Relationship relationship = Db.createNode().createRelationshipTo(node, RelationshipType.withName("KNOWS")); index.Add(relationship, "key", "value"); tx.Success(); } Db.shutdown(); Config config = Config.defaults(); IndexConfigStore indexStore = new IndexConfigStore(databaseLayout, FileSystemRule.get()); LuceneDataSource ds = new LuceneDataSource(databaseLayout, config, indexStore, FileSystemRule.get(), OperationalMode.single); ds.Start(); ds.Stop(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void validateExplicitIndexedRelationshipProperties() internal virtual void ValidateExplicitIndexedRelationshipProperties() { setUp(); Label label = Label.label("explicitIndexedRelationshipPropertiesTestLabel"); string propertyName = "explicitIndexedRelationshipProperties"; string explicitIndexedRelationshipIndex = "explicitIndexedRelationshipIndex"; RelationshipType indexType = RelationshipType.withName("explicitIndexType"); using (Transaction transaction = _database.beginTx()) { Node source = _database.createNode(label); Node destination = _database.createNode(label); Relationship relationship = source.CreateRelationshipTo(destination, indexType); _database.index().forRelationships(explicitIndexedRelationshipIndex).add(relationship, propertyName, "shortString"); transaction.Success(); } System.ArgumentException argumentException = assertThrows(typeof(System.ArgumentException), () => { using (Transaction transaction = _database.beginTx()) { Node source = _database.createNode(label); Node destination = _database.createNode(label); Relationship relationship = source.createRelationshipTo(destination, indexType); string longValue = StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1); _database.index().forRelationships(explicitIndexedRelationshipIndex).add(relationship, propertyName, longValue); transaction.Success(); } }); assertEquals("Property value size is too large for index. Please see index documentation for limitations.", argumentException.Message); }
private void AttemptAndFailConstraintCreation() { using (Transaction tx = Db.beginTx()) { for (int i = 0; i < 2; i++) { Node node1 = Db.createNode(_label); node1.SetProperty("prop", true); } tx.Success(); } // when try { using (Transaction tx = Db.beginTx()) { Db.schema().constraintFor(_label).assertPropertyIsUnique("prop").create(); fail("Should have failed with ConstraintViolationException"); tx.Success(); } } catch (ConstraintViolationException) { } // then using (Transaction ignore = Db.beginTx()) { assertEquals(0, Iterables.count(Db.schema().Indexes)); } }