// Path: src/main/java/com/maxdemarzi/Schema.java
// @Path("/schema")
// public class Schema {
//         private final DatabaseManagementService dbms;
//         private final GraphDatabaseService db;
//         private static final ObjectMapper objectMapper = new ObjectMapper();
// 
//         public Schema(@Context DatabaseManagementService dbms ) {
//             this.dbms = dbms;
//             this.db = dbms.database( "neo4j" );;
//         }
// 
//         @POST
//         @Path("/create")
//         public Response create() throws IOException {
//             ArrayList<String> results = new ArrayList<>();
// 
//             try (Transaction tx = db.beginTx()) {
//                 org.neo4j.graphdb.schema.Schema schema = tx.schema();
//                 if (!schema.getConstraints(Labels.User).iterator().hasNext()) {
//                     schema.constraintFor(Labels.User)
//                             .assertPropertyIsUnique(USERNAME)
//                             .create();
//                     tx.commit();
//                     results.add("(:User {username}) constraint created");
//                 }
//             }
// 
//             try (Transaction tx = db.beginTx()) {
//                 org.neo4j.graphdb.schema.Schema schema = tx.schema();
//                 if (!schema.getConstraints(Labels.Tag).iterator().hasNext()) {
//                     schema.constraintFor(Labels.Tag)
//                             .assertPropertyIsUnique(NAME)
//                             .create();
//                     tx.commit();
//                     results.add("(:Tag {name}) constraint created");
//                 }
//             }
// 
//             try (Transaction tx = db.beginTx()) {
//                 org.neo4j.graphdb.schema.Schema schema = tx.schema();
//                 if(!schema.getIndexes(Labels.Post).iterator().hasNext()) {
//                     schema.indexFor(Labels.Post)
//                             .on(STATUS)
//                             .create();
//                     tx.commit();
//                     results.add("(:Post {status}) index created");
//                 }
//             }
// 
//             results.add("Schema Created");
//             return Response.ok().entity(objectMapper.writeValueAsString(results)).build();
//         }
// }


import com.maxdemarzi.Schema;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.neo4j.harness.junit.rule.Neo4jRule;
import org.neo4j.test.server.HTTP;
import java.util.ArrayList;
import java.util.HashMap;
import static java.lang.Thread.sleep;
                    "password: 'swordfish'})" +
                    "CREATE (jexp:User {username:'jexp', " +
                    "email: 'michael@neo4j.com', " +
                    "name: 'Michael Hunger'," +
                    "hash: '0bd90aeb51d5982062f4f303a62df935'," +
                    "time: 1490054400," +
                    "password: 'tunafish'})" +
                    "CREATE (post1:Post {status:'Hello World!', " +
                    "time: 1490140299})" +
                    "CREATE (post2:Post {status:'Hello @jexp', " +
                    "time: 1490208700})" +
                    "CREATE (max)-[:POSTED_ON_2017_03_21 {time: 1490140299}]->(post1)" +
                    "CREATE (jexp)-[:LIKES {time: 1490141300}]->(post1)" +
                    "CREATE (max)-[:POSTED_ON_2017_03_22 {time: 1490208700}]->(post2)";

    private static final ArrayList<HashMap<String, Object>> expected = new ArrayList<HashMap<String, Object>>() {{
        add(new HashMap<String, Object>() {{
            put("status", "Hello @jexp");
            put("time", 1490208700);
            put("name", "Max De Marzi");
            put("username", "maxdemarzi");
            put("hash", "hash");
            put("reposts", 0);
            put("likes", 0);
        }});
        add(new HashMap<String, Object>() {{
            put("status", "Hello World!");
            put("time", 1490140299);
            put("name", "Max De Marzi");
            put("username", "maxdemarzi");
// Path: src/main/java/com/maxdemarzi/Schema.java
// @Path("/schema")
// public class Schema {
//         private final DatabaseManagementService dbms;
//         private final GraphDatabaseService db;
//         private static final ObjectMapper objectMapper = new ObjectMapper();
// 
//         public Schema(@Context DatabaseManagementService dbms ) {
//             this.dbms = dbms;
//             this.db = dbms.database( "neo4j" );;
//         }
// 
//         @POST
//         @Path("/create")
//         public Response create() throws IOException {
//             ArrayList<String> results = new ArrayList<>();
// 
//             try (Transaction tx = db.beginTx()) {
//                 org.neo4j.graphdb.schema.Schema schema = tx.schema();
//                 if (!schema.getConstraints(Labels.User).iterator().hasNext()) {
//                     schema.constraintFor(Labels.User)
//                             .assertPropertyIsUnique(USERNAME)
//                             .create();
//                     tx.commit();
//                     results.add("(:User {username}) constraint created");
//                 }
//             }
// 
//             try (Transaction tx = db.beginTx()) {
//                 org.neo4j.graphdb.schema.Schema schema = tx.schema();
//                 if (!schema.getConstraints(Labels.Tag).iterator().hasNext()) {
//                     schema.constraintFor(Labels.Tag)
//                             .assertPropertyIsUnique(NAME)
//                             .create();
//                     tx.commit();
//                     results.add("(:Tag {name}) constraint created");
//                 }
//             }
// 
//             try (Transaction tx = db.beginTx()) {
//                 org.neo4j.graphdb.schema.Schema schema = tx.schema();
//                 if(!schema.getIndexes(Labels.Post).iterator().hasNext()) {
//                     schema.indexFor(Labels.Post)
//                             .on(STATUS)
//                             .create();
//                     tx.commit();
//                     results.add("(:Post {status}) index created");
//                 }
//             }
// 
//             results.add("Schema Created");
//             return Response.ok().entity(objectMapper.writeValueAsString(results)).build();
//         }
// }


// Path: src/test/java/com/maxdemarzi/search/GetLatestTest.java
import com.maxdemarzi.Schema;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.neo4j.harness.junit.rule.Neo4jRule;
import org.neo4j.test.server.HTTP;
import java.util.ArrayList;
import java.util.HashMap;
import static java.lang.Thread.sleep;

                    "password: 'swordfish'})" +
                    "CREATE (jexp:User {username:'jexp', " +
                    "email: 'michael@neo4j.com', " +
                    "name: 'Michael Hunger'," +
                    "hash: '0bd90aeb51d5982062f4f303a62df935'," +
                    "time: 1490054400," +
                    "password: 'tunafish'})" +
                    "CREATE (post1:Post {status:'Hello World!', " +
                    "time: 1490140299})" +
                    "CREATE (post2:Post {status:'Hello @jexp', " +
                    "time: 1490208700})" +
                    "CREATE (max)-[:POSTED_ON_2017_03_21 {time: 1490140299}]->(post1)" +
                    "CREATE (jexp)-[:LIKES {time: 1490141300}]->(post1)" +
                    "CREATE (max)-[:POSTED_ON_2017_03_22 {time: 1490208700}]->(post2)";

    private static final ArrayList<HashMap<String, Object>> expected = new ArrayList<HashMap<String, Object>>() {{
        add(new HashMap<String, Object>() {{
            put("status", "Hello @jexp");
            put("time", 1490208700);
            put("name", "Max De Marzi");
            put("username", "maxdemarzi");
            put("hash", "hash");
            put("reposts", 0);
            put("likes", 0);
        }});
        add(new HashMap<String, Object>() {{
            put("status", "Hello World!");
            put("time", 1490140299);
            put("name", "Max De Marzi");
            put("username", "maxdemarzi");
            put("hash", "hash");