private void AssertThatCommunityCanStartOnNormalConstraint(string constraintCreationQuery) { // given GraphDatabaseService graphDb = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabase(Dir.storeDir()); try { graphDb.Execute(constraintCreationQuery); } finally { graphDb.Shutdown(); } graphDb = null; // when try { graphDb = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(Dir.storeDir()); // Should not get exception } finally { if (graphDb != null) { graphDb.Shutdown(); } } }
private static void ExecuteQueryAndShutdown(GraphDatabaseService database, string query, IDictionary <string, object> @params) { Result execute = database.Execute(query, @params); execute.Close(); database.Shutdown(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRenderNestedEntities() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRenderNestedEntities() { using (Transaction ignored = Database.GraphDatabaseAPI.beginTx()) { GraphDatabaseService graphdb = Database.GraphDatabaseAPI; graphdb.Execute("CREATE (n {name: 'Sally'}), (m {age: 42}), (n)-[r:FOO {drunk: false}]->(m)"); Result result = graphdb.Execute("MATCH p=(n)-[r]->(m) RETURN n, r, p, {node: n, edge: r, path: p}"); CypherResultRepresentation representation = new CypherResultRepresentation(result, false, false); // When IDictionary <string, object> serialized = SerializeToStringThenParseAsToMap(representation); // Then object firstRow = ((System.Collections.IList)serialized["data"])[0]; System.Collections.IDictionary nested = (System.Collections.IDictionary)((System.Collections.IList)firstRow)[3]; assertThat(nested["node"], @is(equalTo(((System.Collections.IList)firstRow)[0]))); assertThat(nested["edge"], @is(equalTo(((System.Collections.IList)firstRow)[1]))); assertThat(nested["path"], @is(equalTo(((System.Collections.IList)firstRow)[2]))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFormatMapsProperly() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFormatMapsProperly() { GraphDatabaseService graphdb = Database.GraphDatabaseAPI; Result result = graphdb.Execute("RETURN {one:{two:['wait for it...', {three: 'GO!'}]}}"); CypherResultRepresentation representation = new CypherResultRepresentation(result, false, false); // When IDictionary <string, object> serialized = SerializeToStringThenParseAsToMap(representation); // Then System.Collections.IDictionary one = (System.Collections.IDictionary)((System.Collections.IDictionary)((System.Collections.IList)((System.Collections.IList)serialized["data"])[0])[0])["one"]; System.Collections.IList two = (System.Collections.IList)one["two"]; assertThat(two[0], @is("wait for it...")); System.Collections.IDictionary foo = (System.Collections.IDictionary)two[1]; assertThat(foo["three"], @is("GO!")); }
private void AssertThatCommunityCannotStartOnEnterpriseOnlyConstraint(string constraintCreationQuery, string errorMessage) { // given GraphDatabaseService graphDb = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabase(Dir.storeDir()); try { graphDb.Execute(constraintCreationQuery); } finally { graphDb.Shutdown(); } graphDb = null; // when try { graphDb = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(Dir.storeDir()); fail("should have failed to start!"); } // then catch (Exception e) { Exception error = Exceptions.rootCause(e); assertThat(error, instanceOf(typeof(System.InvalidOperationException))); assertEquals(errorMessage, error.Message); } finally { if (graphDb != null) { graphDb.Shutdown(); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldMigrate() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldMigrate() { DatabaseLayout databaseLayout = _testDir.databaseLayout(BaseDirName(To, From)); GraphDatabaseService database = GetGraphDatabaseService(databaseLayout.DatabaseDirectory(), From.storeVersion()); database.Execute("CREATE INDEX ON :Person(name)"); database.Execute("CREATE INDEX ON :Person(born)"); database.Execute("CREATE CONSTRAINT ON (person:Person) ASSERT exists(person.name)"); database.Execute(CreateQuery); long beforeNodes; long beforeLabels; long beforeKeys; long beforeRels; long beforeRelTypes; long beforeIndexes; long beforeConstraints; using (Transaction ignore = database.BeginTx()) { beforeNodes = database.AllNodes.Count(); beforeLabels = database.AllLabels.Count(); beforeKeys = database.AllPropertyKeys.Count(); beforeRels = database.AllRelationships.Count(); beforeRelTypes = database.AllRelationshipTypes.Count(); beforeIndexes = Stream(database.Schema().Indexes).count(); beforeConstraints = Stream(database.Schema().Constraints).count(); } database.Shutdown(); database = GetGraphDatabaseService(databaseLayout.DatabaseDirectory(), To.storeVersion()); long afterNodes; long afterLabels; long afterKeys; long afterRels; long afterRelTypes; long afterIndexes; long afterConstraints; using (Transaction ignore = database.BeginTx()) { afterNodes = database.AllNodes.Count(); afterLabels = database.AllLabels.Count(); afterKeys = database.AllPropertyKeys.Count(); afterRels = database.AllRelationships.Count(); afterRelTypes = database.AllRelationshipTypes.Count(); afterIndexes = Stream(database.Schema().Indexes).count(); afterConstraints = Stream(database.Schema().Constraints).count(); } database.Shutdown(); assertEquals(beforeNodes, afterNodes); //171 assertEquals(beforeLabels, afterLabels); //2 assertEquals(beforeKeys, afterKeys); //8 assertEquals(beforeRels, afterRels); //253 assertEquals(beforeRelTypes, afterRelTypes); //6 assertEquals(beforeIndexes, afterIndexes); //2 assertEquals(beforeConstraints, afterConstraints); //1 ConsistencyCheckService consistencyCheckService = new ConsistencyCheckService(); ConsistencyCheckService.Result result = RunConsistencyChecker(databaseLayout, _fileSystemRule.get(), consistencyCheckService, To.storeVersion()); if (!result.Successful) { fail("Database is inconsistent after migration."); } }