Search in sources :

Example 6 with Database

use of org.neo4j.server.database.Database 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)

Aggregations

Database (org.neo4j.server.database.Database)6 Test (org.junit.Test)5 WrappedDatabase (org.neo4j.server.database.WrappedDatabase)4 Map (java.util.Map)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Response (javax.ws.rs.core.Response)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Transaction (org.neo4j.graphdb.Transaction)2 Config (org.neo4j.kernel.configuration.Config)2 GraphDatabaseFacade (org.neo4j.kernel.impl.factory.GraphDatabaseFacade)2 CypherExecutor (org.neo4j.server.database.CypherExecutor)2 CypherSession (org.neo4j.server.rest.management.console.CypherSession)2 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)2 UsageData (org.neo4j.udc.UsageData)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Configuration (org.apache.commons.configuration.Configuration)1 Matchers.anyString (org.mockito.Matchers.anyString)1 AuthManager (org.neo4j.kernel.api.security.AuthManager)1