//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void basicProperties() public virtual void BasicProperties() { GraphDatabaseAPI db = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(); PropertyContainer graphProperties = Properties(db); assertThat(graphProperties, inTx(db, not(hasProperty("test")))); Transaction tx = Db.beginTx(); graphProperties.SetProperty("test", "yo"); assertEquals("yo", graphProperties.GetProperty("test")); tx.Success(); tx.Close(); assertThat(graphProperties, inTx(db, hasProperty("test").withValue("yo"))); tx = Db.beginTx(); assertNull(graphProperties.RemoveProperty("something non existent")); assertEquals("yo", graphProperties.RemoveProperty("test")); assertNull(graphProperties.GetProperty("test", null)); graphProperties.SetProperty("other", 10); assertEquals(10, graphProperties.GetProperty("other")); graphProperties.SetProperty("new", "third"); tx.Success(); tx.Close(); assertThat(graphProperties, inTx(db, not(hasProperty("test")))); assertThat(graphProperties, inTx(db, hasProperty("other").withValue(10))); assertThat(getPropertyKeys(db, graphProperties), containsOnly("other", "new")); tx = Db.beginTx(); graphProperties.SetProperty("rollback", true); assertEquals(true, graphProperties.GetProperty("rollback")); tx.Close(); assertThat(graphProperties, inTx(db, not(hasProperty("rollback")))); Db.shutdown(); }
//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 setManyGraphProperties() public virtual void SetManyGraphProperties() { GraphDatabaseAPI db = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(); Transaction tx = Db.beginTx(); object[] values = new object[] { 10, "A string value", new float[] { 1234.567F, 7654.321F }, "A rather longer string which wouldn't fit inlined #!)(&¤" }; int count = 200; for (int i = 0; i < count; i++) { Properties(db).setProperty("key" + i, values[i % values.Length]); } tx.Success(); tx.Close(); for (int i = 0; i < count; i++) { assertThat(Properties(db), inTx(db, hasProperty("key" + i).withValue(values[i % values.Length]))); } for (int i = 0; i < count; i++) { assertThat(Properties(db), inTx(db, hasProperty("key" + i).withValue(values[i % values.Length]))); } Db.shutdown(); }
private long NodeCount() { Transaction transaction = _db.beginTx(); long count = Iterables.count(_db.AllNodes); transaction.Close(); return(count); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void getNonExistentGraphPropertyWithDefaultValue() public virtual void getNonExistentGraphPropertyWithDefaultValue() { GraphDatabaseAPI db = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(); PropertyContainer graphProperties = Properties(db); Transaction tx = Db.beginTx(); assertEquals("default", graphProperties.GetProperty("test", "default")); tx.Success(); tx.Close(); Db.shutdown(); }
private EphemeralFileSystemAbstraction ProduceUncleanStore(EphemeralFileSystemAbstraction fileSystem, File storeDir) { GraphDatabaseService db = (new TestGraphDatabaseFactory()).setFileSystem(fileSystem).newImpermanentDatabase(storeDir); Transaction tx = Db.beginTx(); Node node = Db.createNode(); node.SetProperty("name", "Something"); Properties(( GraphDatabaseAPI )db).setProperty("prop", "Some value"); tx.Success(); tx.Close(); EphemeralFileSystemAbstraction snapshot = fileSystem.Snapshot(); Db.shutdown(); return(snapshot); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void readReplicasShouldRefuseWrites() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ReadReplicasShouldRefuseWrites() { // given //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.startCluster(); Cluster <object> cluster = ClusterRule.startCluster(); GraphDatabaseService db = cluster.FindAnyReadReplica().database(); Transaction tx = Db.beginTx(); // then ExceptionMatcher.expect(typeof(WriteOperationsNotAllowedException)); // when Db.createNode(); tx.Success(); tx.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mixingBeansApiWithKernelAPI() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MixingBeansApiWithKernelAPI() { // 1: Start your transactions through the Beans API Transaction transaction = Db.beginTx(); // 2: Get a hold of a KernelAPI transaction this way: KernelTransaction ktx = StatementContextSupplier.getKernelTransactionBoundToThisThread(true); // 3: Now you can interact through both the statement context and the kernel API to manipulate the // same transaction. Node node = Db.createNode(); int labelId = ktx.TokenWrite().labelGetOrCreateForName("labello"); ktx.DataWrite().nodeAddLabel(node.Id, labelId); // 4: Commit through the beans API transaction.Success(); transaction.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void setBigArrayGraphProperty() public virtual void SetBigArrayGraphProperty() { GraphDatabaseAPI db = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(); long[] array = new long[1000]; for (int i = 0; i < 10; i++) { array[array.Length / 10 * i] = i; } string key = "big long array"; Transaction tx = Db.beginTx(); Properties(db).setProperty(key, array); assertThat(Properties(db), hasProperty(key).withValue(array)); tx.Success(); tx.Close(); assertThat(Properties(db), inTx(db, hasProperty(key).withValue(array))); assertThat(Properties(db), inTx(db, hasProperty(key).withValue(array))); Db.shutdown(); }