Search in sources :

Example 26 with IndexDefinition

use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.

the class AppsIT method canListIndexes.

@Test
public void canListIndexes() throws Exception {
    // GIVEN
    Label label = label("Person");
    beginTx();
    IndexDefinition index = db.schema().indexFor(label).on("name").create();
    finishTx();
    waitForIndex(db, index);
    // WHEN / THEN
    executeCommand("schema ls", ":Person", IndexState.ONLINE.name());
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) Test(org.junit.Test)

Example 27 with IndexDefinition

use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.

the class AppsIT method failSamplingWhenProvidingBadProperty.

@Test
public void failSamplingWhenProvidingBadProperty() 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 -p namn");
        fail("This should fail");
    } catch (ShellException e) {
        assertThat(e.getMessage(), containsString("No property associated with 'namn' was found"));
    }
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 28 with IndexDefinition

use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.

the class AppsIT method canSampleAllIndexes.

@Test
public void canSampleAllIndexes() 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
    executeCommand("schema sample -a");
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 29 with IndexDefinition

use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.

the class AppsIT method failSampleWhenNoOptionGiven.

@Test
public void failSampleWhenNoOptionGiven() 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");
        fail("This should fail");
    } catch (ShellException e) {
        assertThat(e.getMessage(), containsString("Invalid usage of sample"));
    }
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 30 with IndexDefinition

use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.

the class AppsIT method canListIndexesForGivenLabel.

@Test
public void canListIndexesForGivenLabel() throws Exception {
    // GIVEN
    Label label1 = label("Person");
    Label label2 = label("Building");
    beginTx();
    IndexDefinition index1 = db.schema().indexFor(label1).on("name").create();
    IndexDefinition index2 = db.schema().indexFor(label2).on("name").create();
    finishTx();
    waitForIndex(db, index1);
    waitForIndex(db, index2);
    // WHEN / THEN
    executeCommand("schema ls -l " + label2.name(), ":" + label2.name(), IndexState.ONLINE.name(), "!:" + label1.name());
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) Test(org.junit.Test)

Aggregations

IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)84 Test (org.junit.Test)56 Transaction (org.neo4j.graphdb.Transaction)32 StringContains.containsString (org.hamcrest.core.StringContains.containsString)11 Node (org.neo4j.graphdb.Node)9 Statement (org.neo4j.kernel.api.Statement)7 ArrayList (java.util.ArrayList)4 PrimitiveLongSet (org.neo4j.collection.primitive.PrimitiveLongSet)4 Label (org.neo4j.graphdb.Label)4 ReadOperations (org.neo4j.kernel.api.ReadOperations)4 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)4 HighlyAvailableGraphDatabase (org.neo4j.kernel.ha.HighlyAvailableGraphDatabase)4 ManagedCluster (org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster)4 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)3 Iterator (java.util.Iterator)2 PrimitiveLongIterator (org.neo4j.collection.primitive.PrimitiveLongIterator)2 TransactionFailureException (org.neo4j.graphdb.TransactionFailureException)2 TransactionData (org.neo4j.graphdb.event.TransactionData)2 TransactionEventHandler (org.neo4j.graphdb.event.TransactionEventHandler)2 ConstraintDefinition (org.neo4j.graphdb.schema.ConstraintDefinition)2