Search in sources :

Example 6 with SchemaRuleCommand

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

the class SchemaRuleCommandTest method shouldWriteSchemaRuleToLog.

@Test
public void shouldWriteSchemaRuleToLog() throws Exception {
    // GIVEN
    SchemaRecord beforeRecords = serialize(rule, id, false, false);
    SchemaRecord afterRecords = serialize(rule, id, true, true);
    SchemaRuleCommand command = new SchemaRuleCommand(beforeRecords, afterRecords, rule);
    InMemoryClosableChannel buffer = new InMemoryClosableChannel();
    when(neoStores.getSchemaStore()).thenReturn(schemaStore);
    // WHEN
    command.serialize(buffer);
    Command readCommand = reader.read(buffer);
    // THEN
    assertThat(readCommand, instanceOf(SchemaRuleCommand.class));
    assertSchemaRule((SchemaRuleCommand) readCommand);
}
Also used : SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Command(org.neo4j.kernel.impl.transaction.command.Command) SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) Test(org.junit.Test)

Example 7 with SchemaRuleCommand

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

the class SchemaRuleCommandTest method shouldSetLatestConstraintRule.

@Test
public void shouldSetLatestConstraintRule() throws Exception {
    // Given
    SchemaRecord beforeRecords = serialize(rule, id, true, true);
    SchemaRecord afterRecords = serialize(rule, id, true, false);
    when(neoStores.getSchemaStore()).thenReturn(schemaStore);
    when(neoStores.getMetaDataStore()).thenReturn(metaDataStore);
    ConstraintRule schemaRule = ConstraintRule.constraintRule(id, ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyKey), 0);
    // WHEN
    visitSchemaRuleCommand(storeApplier, new SchemaRuleCommand(beforeRecords, afterRecords, schemaRule));
    // THEN
    verify(schemaStore).updateRecord(Iterables.first(afterRecords));
    verify(metaDataStore).setLatestConstraintIntroducingTx(txId);
}
Also used : SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) ConstraintRule(org.neo4j.kernel.impl.store.record.ConstraintRule) Test(org.junit.Test)

Example 8 with SchemaRuleCommand

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

the class SchemaRuleCommandTest method shouldRecreateSchemaRuleWhenDeleteCommandReadFromDisk.

@Test
public void shouldRecreateSchemaRuleWhenDeleteCommandReadFromDisk() throws Exception {
    // GIVEN
    SchemaRecord beforeRecords = serialize(rule, id, true, true);
    SchemaRecord afterRecords = serialize(rule, id, false, false);
    SchemaRuleCommand command = new SchemaRuleCommand(beforeRecords, afterRecords, rule);
    InMemoryClosableChannel buffer = new InMemoryClosableChannel();
    when(neoStores.getSchemaStore()).thenReturn(schemaStore);
    // WHEN
    command.serialize(buffer);
    Command readCommand = reader.read(buffer);
    // THEN
    assertThat(readCommand, instanceOf(SchemaRuleCommand.class));
    assertSchemaRule((SchemaRuleCommand) readCommand);
}
Also used : SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Command(org.neo4j.kernel.impl.transaction.command.Command) SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) 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