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);
}
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);
}
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);
}
Aggregations