Search in sources :

Example 11 with SchemaRecord

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);
}
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 12 with SchemaRecord

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

SchemaRecord (org.neo4j.kernel.impl.store.record.SchemaRecord)12 Test (org.junit.Test)7 SchemaRuleCommand (org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand)7 SchemaRule (org.neo4j.storageengine.api.schema.SchemaRule)4 Command (org.neo4j.kernel.impl.transaction.command.Command)3 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)2 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)2 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)2 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)2 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)2 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)2 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)2 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)2 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)2 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)2 LinkedList (java.util.LinkedList)1 NeoStores (org.neo4j.kernel.impl.store.NeoStores)1 NodeStore (org.neo4j.kernel.impl.store.NodeStore)1 RelationshipGroupStore (org.neo4j.kernel.impl.store.RelationshipGroupStore)1 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)1