use of org.neo4j.kernel.impl.store.record.SchemaRecord 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.store.record.SchemaRecord 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