use of org.neo4j.internal.recordstorage.Command.SchemaRuleCommand in project neo4j by neo4j.
the class SchemaRuleCommandTest method shouldDropSchemaRuleFromIndex.
@Test
void shouldDropSchemaRuleFromIndex() throws Exception {
// GIVEN
SchemaRecord before = new SchemaRecord(id).initialize(true, 42);
before.setCreated();
SchemaRecord after = new SchemaRecord(id).initialize(false, NO_NEXT_PROPERTY.longValue());
when(neoStores.getSchemaStore()).thenReturn(schemaStore);
// WHEN
visitSchemaRuleCommand(indexApplier, new SchemaRuleCommand(serialization, before, after, rule));
// THEN
verify(indexUpdateListener).dropIndex(rule);
}
use of org.neo4j.internal.recordstorage.Command.SchemaRuleCommand in project neo4j by neo4j.
the class SchemaRuleCommandTest method shouldSetLatestConstraintRule.
@Test
void shouldSetLatestConstraintRule() throws Exception {
// Given
SchemaRecord before = new SchemaRecord(id).initialize(true, 42);
before.setCreated();
SchemaRecord after = new SchemaRecord(id).initialize(true, 42);
after.setConstraint(true);
when(neoStores.getSchemaStore()).thenReturn(schemaStore);
when(neoStores.getMetaDataStore()).thenReturn(metaDataStore);
ConstraintDescriptor schemaRule = ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyKey).withId(id).withOwnedIndexId(0);
// WHEN
visitSchemaRuleCommand(storeApplier, new SchemaRuleCommand(serialization, before, after, schemaRule));
// THEN
verify(schemaStore).updateRecord(eq(after), any(), any());
verify(metaDataStore).setLatestConstraintIntroducingTx(txId, NULL);
}
use of org.neo4j.internal.recordstorage.Command.SchemaRuleCommand in project neo4j by neo4j.
the class SchemaRuleCommandTest method shouldRecreateSchemaRuleWhenDeleteCommandReadFromDisk.
@Test
void shouldRecreateSchemaRuleWhenDeleteCommandReadFromDisk() throws Exception {
// GIVEN
SchemaRecord before = new SchemaRecord(id).initialize(true, 42);
before.setCreated();
SchemaRecord after = new SchemaRecord(id).initialize(false, NO_NEXT_PROPERTY.longValue());
SchemaRuleCommand command = new SchemaRuleCommand(serialization, before, after, rule);
InMemoryClosableChannel buffer = new InMemoryClosableChannel();
when(neoStores.getSchemaStore()).thenReturn(schemaStore);
// WHEN
command.serialize(buffer);
Command readCommand = serialization.read(buffer);
// THEN
assertThat(readCommand).isInstanceOf(SchemaRuleCommand.class);
assertSchemaRule((SchemaRuleCommand) readCommand);
}
use of org.neo4j.internal.recordstorage.Command.SchemaRuleCommand in project neo4j by neo4j.
the class SchemaRuleCommandTest method shouldDropSchemaRuleFromStore.
@Test
void shouldDropSchemaRuleFromStore() throws Exception {
// GIVEN
SchemaRecord before = new SchemaRecord(id).initialize(true, 42);
before.setCreated();
SchemaRecord after = new SchemaRecord(id).initialize(false, NO_NEXT_PROPERTY.longValue());
when(neoStores.getSchemaStore()).thenReturn(schemaStore);
// WHEN
visitSchemaRuleCommand(storeApplier, new SchemaRuleCommand(serialization, before, after, rule));
// THEN
verify(schemaStore).updateRecord(eq(after), any(), any());
}
use of org.neo4j.internal.recordstorage.Command.SchemaRuleCommand in project neo4j by neo4j.
the class SchemaRuleCommandTest method shouldCreateIndexForCreatedSchemaRule.
@Test
void shouldCreateIndexForCreatedSchemaRule() throws Exception {
// GIVEN
SchemaRecord before = new SchemaRecord(id).initialize(false, NO_NEXT_PROPERTY.longValue());
SchemaRecord after = new SchemaRecord(id).initialize(true, 42);
after.setCreated();
when(neoStores.getSchemaStore()).thenReturn(schemaStore);
// WHEN
visitSchemaRuleCommand(indexApplier, new SchemaRuleCommand(serialization, before, after, rule));
// THEN
verify(indexUpdateListener).createIndexes(SYSTEM, rule);
}
Aggregations