Search in sources :

Example 1 with SchemaRuleCommand

use of org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand in project neo4j by neo4j.

the class Commands method createIndexRule.

public static SchemaRuleCommand createIndexRule(SchemaIndexProvider.Descriptor provider, long id, NodePropertyDescriptor descriptor) {
    SchemaRule rule = IndexRule.indexRule(id, NewIndexDescriptorFactory.forSchema(SchemaBoundary.map(descriptor)), provider);
    DynamicRecord record = new DynamicRecord(id);
    record.setInUse(true);
    record.setCreated();
    record.setData(rule.serialize());
    return new SchemaRuleCommand(Collections.<DynamicRecord>emptyList(), singletonList(record), rule);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) SchemaRule(org.neo4j.storageengine.api.schema.SchemaRule)

Example 2 with SchemaRuleCommand

use of org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand in project neo4j by neo4j.

the class SchemaRuleCommandTest method shouldDropSchemaRuleFromStore.

@Test
public void shouldDropSchemaRuleFromStore() throws Exception {
    // GIVEN
    SchemaRecord beforeRecords = serialize(rule, id, true, true);
    SchemaRecord afterRecords = serialize(rule, id, false, false);
    when(neoStores.getSchemaStore()).thenReturn(schemaStore);
    // WHEN
    visitSchemaRuleCommand(storeApplier, new SchemaRuleCommand(beforeRecords, afterRecords, rule));
    // THEN
    verify(schemaStore).updateRecord(Iterables.first(afterRecords));
}
Also used : SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) Test(org.junit.Test)

Example 3 with SchemaRuleCommand

use of org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand in project neo4j by neo4j.

the class SchemaRuleCommandTest method shouldDropSchemaRuleFromIndex.

@Test
public void shouldDropSchemaRuleFromIndex() throws Exception {
    // GIVEN
    SchemaRecord beforeRecords = serialize(rule, id, true, true);
    SchemaRecord afterRecords = serialize(rule, id, false, false);
    when(neoStores.getSchemaStore()).thenReturn(schemaStore);
    // WHEN
    visitSchemaRuleCommand(indexApplier, new SchemaRuleCommand(beforeRecords, afterRecords, rule));
    // THEN
    verify(indexes).dropIndex(rule);
}
Also used : SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) Test(org.junit.Test)

Example 4 with SchemaRuleCommand

use of org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand in project neo4j by neo4j.

the class SchemaRuleCommandTest method shouldWriteCreatedSchemaRuleToStore.

@Test
public void shouldWriteCreatedSchemaRuleToStore() throws Exception {
    // GIVEN
    SchemaRecord beforeRecords = serialize(rule, id, false, false);
    SchemaRecord afterRecords = serialize(rule, id, true, true);
    when(neoStores.getSchemaStore()).thenReturn(schemaStore);
    // WHEN
    visitSchemaRuleCommand(storeApplier, new SchemaRuleCommand(beforeRecords, afterRecords, rule));
    // THEN
    verify(schemaStore).updateRecord(Iterables.first(afterRecords));
}
Also used : SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) Test(org.junit.Test)

Example 5 with SchemaRuleCommand

use of org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand in project neo4j by neo4j.

the class SchemaRuleCommandTest method shouldCreateIndexForCreatedSchemaRule.

@Test
public void shouldCreateIndexForCreatedSchemaRule() throws Exception {
    // GIVEN
    SchemaRecord beforeRecords = serialize(rule, id, false, false);
    SchemaRecord afterRecords = serialize(rule, id, true, true);
    when(neoStores.getSchemaStore()).thenReturn(schemaStore);
    // WHEN
    visitSchemaRuleCommand(indexApplier, new SchemaRuleCommand(beforeRecords, afterRecords, rule));
    // THEN
    verify(indexes).createIndexes(rule);
}
Also used : SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) Test(org.junit.Test)

Aggregations

SchemaRuleCommand (org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand)8 Test (org.junit.Test)7 SchemaRecord (org.neo4j.kernel.impl.store.record.SchemaRecord)7 Command (org.neo4j.kernel.impl.transaction.command.Command)2 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)2 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)1 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)1 SchemaRule (org.neo4j.storageengine.api.schema.SchemaRule)1