Search in sources :

Example 6 with WrappedDatabase

use of org.neo4j.server.database.WrappedDatabase in project neo4j by neo4j.

the class DatabaseMetadataServiceTest method shouldAdvertiseRelationshipTypesThatCurrentlyExistInTheDatabase.

@Test
public void shouldAdvertiseRelationshipTypesThatCurrentlyExistInTheDatabase() throws Throwable {
    try (Transaction tx = db.beginTx()) {
        db.getRelationshipById(relId).delete();
        tx.success();
    }
    Database database = new WrappedDatabase(db);
    DatabaseMetadataService service = new DatabaseMetadataService(database);
    try (Transaction tx = db.beginTx()) {
        Response response = service.getRelationshipTypes(false);
        assertEquals(200, response.getStatus());
        List<Map<String, Object>> jsonList = JsonHelper.jsonToList(response.getEntity().toString());
        assertEquals(3, jsonList.size());
    }
    database.stop();
}
Also used : Response(javax.ws.rs.core.Response) Transaction(org.neo4j.graphdb.Transaction) Database(org.neo4j.server.database.Database) WrappedDatabase(org.neo4j.server.database.WrappedDatabase) WrappedDatabase(org.neo4j.server.database.WrappedDatabase) Map(java.util.Map) Test(org.junit.Test)

Example 7 with WrappedDatabase

use of org.neo4j.server.database.WrappedDatabase in project neo4j by neo4j.

the class RestfulGraphDatabasePagedTraversalTest method startDatabase.

@Before
public void startDatabase() throws IOException {
    graph = (GraphDatabaseFacade) new TestGraphDatabaseFactory().newImpermanentDatabase();
    database = new WrappedDatabase(graph);
    helper = new GraphDbHelper(database);
    output = new EntityOutputFormat(new JsonFormat(), URI.create(BASE_URI), null);
    leaseManager = new LeaseManager(Clocks.fakeClock());
    service = new RestfulGraphDatabase(new JsonFormat(), output, new DatabaseActions(leaseManager, true, database.getGraph()), null);
    service = new TransactionWrappingRestfulGraphDatabase(graph, service);
}
Also used : GraphDbHelper(org.neo4j.server.rest.domain.GraphDbHelper) JsonFormat(org.neo4j.server.rest.repr.formats.JsonFormat) LeaseManager(org.neo4j.server.rest.paging.LeaseManager) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) WrappedDatabase(org.neo4j.server.database.WrappedDatabase) EntityOutputFormat(org.neo4j.test.server.EntityOutputFormat) Before(org.junit.Before)

Aggregations

WrappedDatabase (org.neo4j.server.database.WrappedDatabase)7 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)5 GraphDbHelper (org.neo4j.server.rest.domain.GraphDbHelper)4 LeaseManager (org.neo4j.server.rest.paging.LeaseManager)4 Test (org.junit.Test)3 Database (org.neo4j.server.database.Database)3 JsonFormat (org.neo4j.server.rest.repr.formats.JsonFormat)3 EntityOutputFormat (org.neo4j.test.server.EntityOutputFormat)3 Map (java.util.Map)2 Response (javax.ws.rs.core.Response)2 Before (org.junit.Before)2 BeforeClass (org.junit.BeforeClass)2 Transaction (org.neo4j.graphdb.Transaction)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 GraphDatabaseFacade (org.neo4j.kernel.impl.factory.GraphDatabaseFacade)1 CypherExecutor (org.neo4j.server.database.CypherExecutor)1 ConfigAdapter (org.neo4j.server.plugins.ConfigAdapter)1 CypherSession (org.neo4j.server.rest.management.console.CypherSession)1