//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleArrayOfPointsUsingGraphResultDataContent() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleArrayOfPointsUsingGraphResultDataContent() { //Given GraphDatabaseFacade db = Server().Database.Graph; using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(label("N")); node.SetProperty("coordinates", new Point[] { pointValue(WGS84, 30.655691, 104.081602) }); tx.Success(); } //When HTTP.Response response = RunQuery("MATCH (n:N) RETURN n", "graph"); assertEquals(200, response.Status()); AssertNoErrors(response); //Then JsonNode row = response.Get("results").get(0).get("data").get(0).get("graph").get("nodes").get(0).get("properties").get("coordinates").get(0); AssertGeometryTypeEqual(GeometryType.GEOMETRY_POINT, row); AssertCoordinatesEqual(new double[] { 30.655691, 104.081602 }, row); AssertCrsEqual(WGS84, row); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWorkWithPoint2DArrays() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldWorkWithPoint2DArrays() { HTTP.Response response = RunQuery("create (:Node {points: [point({x:1, y:1}), point({x:2, y:2}), point({x: 3.0, y: 3.0})]})"); assertEquals(200, response.Status()); AssertNoErrors(response); GraphDatabaseFacade db = Server().Database.Graph; using (Transaction tx = Db.beginTx()) { foreach (Node node in Db.AllNodes) { if (node.HasLabel(label("Node")) && node.HasProperty("points")) { Point[] points = ( Point[] )node.GetProperty("points"); VerifyPoint(points[0], Cartesian, 1.0, 1.0); VerifyPoint(points[1], Cartesian, 2.0, 2.0); VerifyPoint(points[2], Cartesian, 3.0, 3.0); } } tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturnASingleNode() public virtual void ShouldReturnASingleNode() { GraphDatabaseFacade graphdb = ( GraphDatabaseFacade )(new TestGraphDatabaseFactory()).newImpermanentDatabase(); Database database = new WrappedDatabase(graphdb); CypherExecutor executor = new CypherExecutor(database, NullLogProvider.Instance); executor.Start(); HttpServletRequest request = mock(typeof(HttpServletRequest)); when(request.Scheme).thenReturn("http"); when(request.RemoteAddr).thenReturn("127.0.0.1"); when(request.RemotePort).thenReturn(5678); when(request.ServerName).thenReturn("127.0.0.1"); when(request.ServerPort).thenReturn(7474); when(request.RequestURI).thenReturn("/"); try { CypherSession session = new CypherSession(executor, NullLogProvider.Instance, request); Pair <string, string> result = session.Evaluate("create (a) return a"); assertThat(result.First(), containsString("Node[0]")); } finally { graphdb.Shutdown(); } }
public virtual UpdatePullingTransactionObligationFulfiller CreateObligationFulfiller(UpdatePuller updatePuller) { return(new UpdatePullingTransactionObligationFulfiller(updatePuller, _memberStateMachine, _serverId, () => { GraphDatabaseFacade databaseFacade = this._dependencyResolver.resolveDependency(typeof(DatabaseManager)).getDatabaseFacade(_activeDatabaseName).get(); DependencyResolver databaseResolver = databaseFacade.DependencyResolver; return databaseResolver.resolveDependency(typeof(TransactionIdStore)); })); }
private static DatabaseManager NewDbMock() { GraphDatabaseFacade db = mock(typeof(GraphDatabaseFacade)); DependencyResolver dependencyResolver = mock(typeof(DependencyResolver)); when(Db.DependencyResolver).thenReturn(dependencyResolver); GraphDatabaseQueryService queryService = mock(typeof(GraphDatabaseQueryService)); when(queryService.DependencyResolver).thenReturn(dependencyResolver); when(dependencyResolver.ResolveDependency(typeof(GraphDatabaseQueryService))).thenReturn(queryService); DatabaseManager databaseManager = mock(typeof(DatabaseManager)); when(databaseManager.GetDatabaseFacade(CUSTOM_DB_NAME)).thenReturn(db); return(databaseManager); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void checkExpectedDatabaseDirectory() internal virtual void CheckExpectedDatabaseDirectory() { Config config = Config.builder().withServerDefaults().withSetting(mode, Mode.SINGLE.name()).withSetting(GraphDatabaseSettings.neo4j_home, _testDirectory.storeDir().AbsolutePath).withSetting((new BoltConnector("bolt")).listen_address.name(), "localhost:0").withSetting((new BoltConnector("http")).listen_address.name(), "localhost:0").withSetting((new BoltConnector("https")).listen_address.name(), "localhost:0").build(); GraphDatabaseDependencies dependencies = GraphDatabaseDependencies.newDependencies().userLogProvider(NullLogProvider.Instance); OpenEnterpriseNeoServer server = new OpenEnterpriseNeoServer(config, dependencies); server.Start(); try { Path expectedPath = Paths.get(_testDirectory.storeDir().Path, "data", "databases", "graph.db"); GraphDatabaseFacade graph = server.Database.Graph; assertEquals(expectedPath, graph.DatabaseLayout().databaseDirectory().toPath()); } finally { server.Stop(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.graphdb.GraphDatabaseService apply(org.neo4j.kernel.api.proc.Context context) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException public override GraphDatabaseService Apply(Context context) { KernelTransaction tx = context.GetOrElse(Org.Neo4j.Kernel.api.proc.Context_Fields.KernelTransaction, null); SecurityContext securityContext; if (tx != null) { securityContext = tx.SecurityContext(); } else { securityContext = context.Get(Org.Neo4j.Kernel.api.proc.Context_Fields.SecurityContext); } GraphDatabaseFacade facade = new GraphDatabaseFacade(); ProcedureGDBFacadeSPI procedureGDBFacadeSPI = new ProcedureGDBFacadeSPI(_dataSource, _dataSource.neoStoreDataSource.DependencyResolver, _availability, _urlValidator, securityContext, _bridge); facade.Init(procedureGDBFacadeSPI, _bridge, _platform.config, _tokenHolders); return(facade); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void executeQueryWithSnapshotEngine() public virtual void ExecuteQueryWithSnapshotEngine() { Database database = _server.Database; GraphDatabaseFacade graph = database.Graph; using (Transaction transaction = graph.BeginTx()) { for (int i = 0; i < 10; i++) { Node node = graph.CreateNode(); node.SetProperty("a", "b"); } transaction.Success(); } HTTP.Builder httpClientBuilder = HTTP.withBaseUri(_server.baseUri()); HTTP.Response transactionStart = httpClientBuilder.Post(TransactionURI()); assertThat(transactionStart.Status(), equalTo(201)); HTTP.Response response = httpClientBuilder.POST(transactionStart.Location(), quotedJson("{ 'statements': [ { 'statement': 'MATCH (n) RETURN n' } ] }")); assertThat(response.Status(), equalTo(200)); }
private void SetUpMocks() { _database = mock(typeof(Database)); _databaseFacade = mock(typeof(GraphDatabaseFacade)); _resolver = mock(typeof(DependencyResolver)); _executionEngine = mock(typeof(ExecutionEngine)); _statementBridge = mock(typeof(ThreadToStatementContextBridge)); _databaseQueryService = mock(typeof(GraphDatabaseQueryService)); _kernelTransaction = mock(typeof(KernelTransaction)); _statement = mock(typeof(Statement)); _request = mock(typeof(HttpServletRequest)); InternalTransaction transaction = new TopLevelTransaction(_kernelTransaction); LoginContext loginContext = AUTH_DISABLED; KernelTransaction.Type type = KernelTransaction.Type.@implicit; QueryRegistryOperations registryOperations = mock(typeof(QueryRegistryOperations)); when(_statement.queryRegistration()).thenReturn(registryOperations); when(_statementBridge.get()).thenReturn(_statement); when(_kernelTransaction.securityContext()).thenReturn(loginContext.Authorize(s => - 1, GraphDatabaseSettings.DEFAULT_DATABASE_NAME)); when(_kernelTransaction.transactionType()).thenReturn(type); when(_database.Graph).thenReturn(_databaseFacade); when(_databaseFacade.DependencyResolver).thenReturn(_resolver); when(_resolver.resolveDependency(typeof(QueryExecutionEngine))).thenReturn(_executionEngine); when(_resolver.resolveDependency(typeof(ThreadToStatementContextBridge))).thenReturn(_statementBridge); when(_resolver.resolveDependency(typeof(GraphDatabaseQueryService))).thenReturn(_databaseQueryService); when(_databaseQueryService.beginTransaction(type, loginContext)).thenReturn(transaction); when(_databaseQueryService.beginTransaction(type, loginContext, CUSTOM_TRANSACTION_TIMEOUT, TimeUnit.MILLISECONDS)).thenReturn(transaction); when(_databaseQueryService.DependencyResolver).thenReturn(_resolver); when(_request.Scheme).thenReturn("http"); when(_request.RemoteAddr).thenReturn("127.0.0.1"); when(_request.RemotePort).thenReturn(5678); when(_request.ServerName).thenReturn("127.0.0.1"); when(_request.ServerPort).thenReturn(7474); when(_request.RequestURI).thenReturn("/"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleTemporalUsingGraphResultDataContent() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleTemporalUsingGraphResultDataContent() { //Given GraphDatabaseFacade db = Server().Database.Graph; ZonedDateTime date = ZonedDateTime.of(1980, 3, 11, 0, 0, 0, 0, ZoneId.of("Europe/Stockholm")); using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(label("N")); node.SetProperty("date", date); tx.Success(); } //When HTTP.Response response = RunQuery("MATCH (n:N) RETURN n", "graph"); //Then assertEquals(200, response.Status()); AssertNoErrors(response); JsonNode row = response.Get("results").get(0).get("data").get(0).get("graph").get("nodes").get(0).get("properties").get("date"); assertEquals("\"1980-03-11T00:00+01:00[Europe/Stockholm]\"", row.ToString()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustIgnoreExceptionsFromPreLoadingCypherQuery() public virtual void MustIgnoreExceptionsFromPreLoadingCypherQuery() { // Given a lifecycled database that'll try to warm up Cypher when it starts //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.factory.GraphDatabaseFacade mockDb = mock(org.neo4j.kernel.impl.factory.GraphDatabaseFacade.class); GraphDatabaseFacade mockDb = mock(typeof(GraphDatabaseFacade)); Config config = Config.defaults(); GraphDatabaseFacadeFactory.Dependencies deps = GraphDatabaseDependencies.newDependencies().userLogProvider(NullLogProvider.Instance); GraphFactory factory = new SimpleGraphFactory(mockDb); LifecycleManagingDatabase db = new LifecycleManagingDatabaseAnonymousInnerClass(this, config, factory, deps); // When the execution of the query fails (for instance when this is a slave that just joined a cluster and is // working on catching up to the master) when(mockDb.Execute(LifecycleManagingDatabase.CYPHER_WARMUP_QUERY)).thenThrow(new TransactionFailureException("Boo")); // Then the database should still start up as normal, without bubbling the exception up Db.init(); Db.start(); assertTrue("the database should be running", Db.Running); Db.stop(); Db.shutdown(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleDurationArraysUsingGraphResultDataContent() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleDurationArraysUsingGraphResultDataContent() { //Given GraphDatabaseFacade db = Server().Database.Graph; Duration duration = Duration.ofSeconds(73); using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(label("N")); node.SetProperty("durations", new Duration[] { duration }); tx.Success(); } //When HTTP.Response response = RunQuery("MATCH (n:N) RETURN n", "graph"); //Then assertEquals(200, response.Status()); AssertNoErrors(response); JsonNode row = response.Get("results").get(0).get("data").get(0).get("graph").get("nodes").get(0).get("properties").get("durations").get(0); assertEquals("\"PT1M13S\"", row.ToString()); }
public SimpleGraphFactory(GraphDatabaseFacade db) { this._db = db; }
public GraphDatabaseCypherService(GraphDatabaseService graph) { this._graph = ( GraphDatabaseFacade )graph; this._dbmsOperations = DependencyResolver.resolveDependency(typeof(DbmsOperations)); }
public DataSourceModule(string databaseName, PlatformModule platformModule, AbstractEditionModule editionModule, Procedures procedures, GraphDatabaseFacade graphDatabaseFacade) { platformModule.DiagnosticsManager.prependProvider(platformModule.Config); DatabaseEditionContext editionContext = editionModule.CreateDatabaseContext(databaseName); ModularDatabaseCreationContext context = new ModularDatabaseCreationContext(databaseName, platformModule, editionContext, procedures, graphDatabaseFacade); NeoStoreDataSource = new NeoStoreDataSource(context); this.CoreAPIAvailabilityGuardConflict = context.CoreAPIAvailabilityGuard; this.StoreId = NeoStoreDataSource.getStoreId; this.KernelAPI = NeoStoreDataSource.getKernel; ProcedureGDSFactory gdsFactory = new ProcedureGDSFactory(platformModule, this, CoreAPIAvailabilityGuardConflict, context.TokenHolders, editionModule.ThreadToTransactionBridge); procedures.RegisterComponent(typeof(GraphDatabaseService), gdsFactory.apply, true); }