Search in sources :

Example 6 with SchemaRuleCommand

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);
}
Also used : SchemaRuleCommand(org.neo4j.internal.recordstorage.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 7 with SchemaRuleCommand

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);
}
Also used : SchemaRuleCommand(org.neo4j.internal.recordstorage.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 8 with SchemaRuleCommand

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);
}
Also used : SchemaRuleCommand(org.neo4j.internal.recordstorage.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) SchemaRuleCommand(org.neo4j.internal.recordstorage.Command.SchemaRuleCommand) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 9 with SchemaRuleCommand

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());
}
Also used : SchemaRuleCommand(org.neo4j.internal.recordstorage.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 10 with SchemaRuleCommand

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);
}
Also used : SchemaRuleCommand(org.neo4j.internal.recordstorage.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Aggregations

SchemaRuleCommand (org.neo4j.internal.recordstorage.Command.SchemaRuleCommand)15 Test (org.junit.jupiter.api.Test)13 SchemaRecord (org.neo4j.kernel.impl.store.record.SchemaRecord)9 RepeatedTest (org.junit.jupiter.api.RepeatedTest)8 ArrayList (java.util.ArrayList)6 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)6 StorageCommand (org.neo4j.storageengine.api.StorageCommand)6 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)5 PropertyCommand (org.neo4j.internal.recordstorage.Command.PropertyCommand)4 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)3 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)2 SchemaRule (org.neo4j.internal.schema.SchemaRule)2