use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method failSamplingWhenProvidingOnlyLabel.
@Test
public void failSamplingWhenProvidingOnlyLabel() throws Exception {
// GIVEN
Label label = label("Person");
String property = "name";
beginTx();
IndexDefinition index = db.schema().indexFor(label).on(property).create();
finishTx();
waitForIndex(db, index);
// WHEN / THEN
try {
executeCommand("schema sample -l Person");
fail("This should fail");
} catch (ShellException e) {
assertThat(e.getMessage(), containsString("Provide both the property and the label, or run with -a to sample all indexes"));
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method failSamplingWhenProvidingBadLabel.
@Test
public void failSamplingWhenProvidingBadLabel() throws Exception {
// GIVEN
Label label = label("Person");
String property = "name";
beginTx();
IndexDefinition index = db.schema().indexFor(label).on(property).create();
finishTx();
waitForIndex(db, index);
// WHEN / THEN
try {
executeCommand("schema sample -l People -p name");
fail("This should fail");
} catch (ShellException e) {
assertThat(e.getMessage(), containsString("No label associated with 'People' was found"));
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method canAwaitIndexesToComeOnline.
@Test
public void canAwaitIndexesToComeOnline() throws Exception {
// GIVEN
Label label = label("Person");
beginTx();
IndexDefinition index = db.schema().indexFor(label).on("name").create();
finishTx();
// WHEN / THEN
executeCommand("schema await -l " + label.name());
beginTx();
assertEquals(IndexState.ONLINE, db.schema().getIndexState(index));
finishTx();
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method failSamplingWhenProvidingMultipleLabels.
@Test
public void failSamplingWhenProvidingMultipleLabels() throws Exception {
// GIVEN
Label label = label("Person");
Label otherLabel = label("Dog");
String property = "name";
beginTx();
IndexDefinition index1 = db.schema().indexFor(label).on(property).create();
IndexDefinition index2 = db.schema().indexFor(otherLabel).on(property).create();
finishTx();
waitForIndex(db, index1);
waitForIndex(db, index2);
// WHEN / THEN
try {
executeCommand("schema sample -p name -l [Person,Dog]");
fail("This should fail");
} catch (ShellException e) {
assertThat(e.getMessage(), containsString("Only one label must be provided"));
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method canListIndexesForGivenPropertyAndLabel.
@Test
public void canListIndexesForGivenPropertyAndLabel() throws Exception {
// GIVEN
Label label1 = label("Person");
Label label2 = label("Thing");
String property1 = "name";
String property2 = "age";
beginTx();
IndexDefinition index1 = db.schema().indexFor(label1).on(property1).create();
IndexDefinition index2 = db.schema().indexFor(label1).on(property2).create();
IndexDefinition index3 = db.schema().indexFor(label2).on(property1).create();
IndexDefinition index4 = db.schema().indexFor(label2).on(property2).create();
finishTx();
waitForIndex(db, index1);
waitForIndex(db, index2);
waitForIndex(db, index3);
waitForIndex(db, index4);
// WHEN / THEN
executeCommand("schema ls" + " -l :" + label2.name() + " -p " + property1, label2.name(), property1, "!" + label1.name(), "!" + property2);
}
Aggregations