@Test public void schemaOnMultipleLabelsAndMultipleSingleProperties() { Neo4jConfiguration configuration = new Neo4jConfiguration(); configuration.setLocation(graphPath.getRoot().getAbsolutePath()); Set<String> property = new HashSet<String>(); property.add("property11"); property.add("property12"); Map<String, Set<String>> schemaIndexes = new HashMap<String, Set<String>>(); schemaIndexes.put("label", property); Set<String> property2 = new HashSet<String>(); property2.add("property21"); property2.add("property22"); schemaIndexes.put("label2", property2); configuration.setSchemaIndexes(schemaIndexes); Neo4jModule.setupSchemaIndexes(graphDb, configuration); try (Transaction tx = graphDb.beginTx()) { assertThat(size(graphDb.schema().getIndexes()), is(4)); tx.success(); tx.close(); } } }
@Test public void supportEmptySchemaDefinition() { Neo4jConfiguration configuration = new Neo4jConfiguration(); configuration.setLocation(graphPath.getRoot().getAbsolutePath()); Neo4jModule.setupSchemaIndexes(graphDb, configuration); try (Transaction tx = graphDb.beginTx()) { assertThat(graphDb.schema().getIndexes().iterator().hasNext(), is(false)); tx.success(); tx.close(); } }
@Test public void schemaOnMultipleProperties() { Neo4jConfiguration configuration = new Neo4jConfiguration(); configuration.setLocation(graphPath.getRoot().getAbsolutePath()); Set<String> property = new HashSet<String>(); property.add("property"); property.add("property2"); Map<String, Set<String>> schemaIndexes = new HashMap<String, Set<String>>(); schemaIndexes.put("label", property); configuration.setSchemaIndexes(schemaIndexes); Neo4jModule.setupSchemaIndexes(graphDb, configuration); try (Transaction tx = graphDb.beginTx()) { assertThat(size(graphDb.schema().getIndexes()), is(2)); tx.success(); tx.close(); } }
@Test public void schemaOnSingleProperty() { Neo4jConfiguration configuration = new Neo4jConfiguration(); configuration.setLocation(graphPath.getRoot().getAbsolutePath()); Set<String> property = new HashSet<String>(); property.add("property"); Map<String, Set<String>> schemaIndexes = new HashMap<String, Set<String>>(); schemaIndexes.put("label", property); configuration.setSchemaIndexes(schemaIndexes); Neo4jModule.setupSchemaIndexes(graphDb, configuration); try (Transaction tx = graphDb.beginTx()) { assertThat(size(graphDb.schema().getIndexes()), is(1)); tx.success(); tx.close(); } }