Search in sources :

Example 6 with IndexSetting

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

the class SchemaAcceptanceTest method mustBeAbleToGetIndexConfig.

@Test
void mustBeAbleToGetIndexConfig() {
    try (Transaction tx = db.beginTx()) {
        IndexDefinition index = tx.schema().indexFor(label).on(propertyKey).withName("my_index").create();
        Map<IndexSetting, Object> config = index.getIndexConfiguration();
        assertNotNull(config);
        assertTrue(config.containsKey(IndexSettingImpl.SPATIAL_CARTESIAN_MIN));
        tx.commit();
    }
    try (Transaction tx = db.beginTx()) {
        IndexDefinition index = getIndex(tx, "my_index");
        Map<IndexSetting, Object> config = index.getIndexConfiguration();
        assertNotNull(config);
        assertTrue(config.containsKey(IndexSettingImpl.SPATIAL_CARTESIAN_MIN));
        tx.commit();
    }
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) IndexSetting(org.neo4j.graphdb.schema.IndexSetting) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with IndexSetting

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

the class SchemaAcceptanceTest method mustBeAbleToSpecifyIndexConfigurationForUniquenessConstraint.

@Test
void mustBeAbleToSpecifyIndexConfigurationForUniquenessConstraint() {
    try (Transaction tx = db.beginTx()) {
        ConstraintDefinition constraint = tx.schema().constraintFor(label).withName("my constraint").assertPropertyIsUnique(propertyKey).withIndexConfiguration(Map.of(IndexSettingImpl.SPATIAL_CARTESIAN_MAX, new double[] { 200.0, 200.0 }, IndexSettingImpl.SPATIAL_WGS84_MIN, new double[] { -90.0, -90.0 })).create();
        IndexDefinition index = getIndex(tx, constraint.getName());
        Map<IndexSetting, Object> config = index.getIndexConfiguration();
        assertArrayEquals(new double[] { 200.0, 200.0 }, (double[]) config.get(IndexSettingImpl.SPATIAL_CARTESIAN_MAX));
        assertArrayEquals(new double[] { -90.0, -90.0 }, (double[]) config.get(IndexSettingImpl.SPATIAL_WGS84_MIN));
        tx.commit();
    }
    try (Transaction tx = db.beginTx()) {
        IndexDefinition index = getIndex(tx, "my constraint");
        Map<IndexSetting, Object> config = index.getIndexConfiguration();
        assertArrayEquals(new double[] { 200.0, 200.0 }, (double[]) config.get(IndexSettingImpl.SPATIAL_CARTESIAN_MAX));
        assertArrayEquals(new double[] { -90.0, -90.0 }, (double[]) config.get(IndexSettingImpl.SPATIAL_WGS84_MIN));
        tx.commit();
    }
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) ConstraintDefinition(org.neo4j.graphdb.schema.ConstraintDefinition) IndexSetting(org.neo4j.graphdb.schema.IndexSetting) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Test (org.junit.jupiter.api.Test)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)7 IndexSetting (org.neo4j.graphdb.schema.IndexSetting)7 RepeatedTest (org.junit.jupiter.api.RepeatedTest)5 Transaction (org.neo4j.graphdb.Transaction)2 ConstraintDefinition (org.neo4j.graphdb.schema.ConstraintDefinition)1