use of org.neo4j.kernel.impl.api.BatchTransactionApplier in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStoreThrowingIndexProblem.
@Test
public void shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStoreThrowingIndexProblem() throws IOException, IndexNotFoundKernelException, IndexPopulationFailedKernelException, IndexActivationFailedKernelException {
// given
final BatchTransactionApplier applier = newIndexApplier();
doThrow(new IndexNotFoundKernelException("")).when(indexingService).activateIndex(anyLong());
final DynamicRecord record = DynamicRecord.dynamicRecord(21, true);
final Collection<DynamicRecord> recordsAfter = Arrays.asList(record);
final IndexRule rule = constraintIndexRule(0, 1, 2, new SchemaIndexProvider.Descriptor("K", "X.Y"), 42L);
final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(Collections.<DynamicRecord>emptyList(), recordsAfter, rule);
// when
try {
apply(applier, command::handle, transactionToApply);
fail("should have thrown");
} catch (Exception e) {
// then
assertTrue(e.getCause() instanceof IndexNotFoundKernelException);
}
}
use of org.neo4j.kernel.impl.api.BatchTransactionApplier in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyDeleteIndexRuleSchemaRuleCommandToTheStore.
@Test
public void shouldApplyDeleteIndexRuleSchemaRuleCommandToTheStore() throws Exception {
// given
final BatchTransactionApplier base = newApplier(false);
final BatchTransactionApplier indexApplier = newIndexApplier();
final BatchTransactionApplierFacade applier = new BatchTransactionApplierFacade(base, indexApplier);
final DynamicRecord record = DynamicRecord.dynamicRecord(21, true);
record.setInUse(false);
final Collection<DynamicRecord> recordsAfter = Arrays.asList(record);
final IndexRule rule = indexRule(0, 1, 2, new SchemaIndexProvider.Descriptor("K", "X.Y"));
final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(Collections.<DynamicRecord>emptyList(), recordsAfter, rule);
// when
boolean result = apply(applier, command::handle, transactionToApply);
// then
assertFalse(result);
verify(schemaStore, times(1)).updateRecord(record);
verify(indexingService, times(1)).dropIndex(rule);
verify(cacheAccess, times(1)).removeSchemaRuleFromCache(command.getKey());
}
use of org.neo4j.kernel.impl.api.BatchTransactionApplier in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyUpdateUniquenessConstraintRuleSchemaRuleCommandToTheStoreInRecovery.
@Test
public void shouldApplyUpdateUniquenessConstraintRuleSchemaRuleCommandToTheStoreInRecovery() throws Exception {
// given
final BatchTransactionApplier applier = newApplier(true);
final DynamicRecord record = DynamicRecord.dynamicRecord(21, true);
final Collection<DynamicRecord> recordsAfter = Arrays.asList(record);
final ConstraintRule rule = uniquenessConstraintRule(0L, 1, 2, 3L);
final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(Collections.<DynamicRecord>emptyList(), recordsAfter, rule);
// when
boolean result = apply(applier, command::handle, transactionToApply);
// then
assertFalse(result);
verify(schemaStore, times(1)).setHighestPossibleIdInUse(record.getId());
verify(schemaStore, times(1)).updateRecord(record);
verify(metaDataStore, times(1)).setLatestConstraintIntroducingTx(transactionId);
verify(cacheAccess, times(1)).addSchemaRule(rule);
}
use of org.neo4j.kernel.impl.api.BatchTransactionApplier in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyLabelTokenCommandToTheStoreInRecovery.
@Test
public void shouldApplyLabelTokenCommandToTheStoreInRecovery() throws Exception {
// given
final BatchTransactionApplier applier = newApplier(true);
final LabelTokenRecord before = new LabelTokenRecord(42);
final LabelTokenRecord after = new LabelTokenRecord(42);
after.setInUse(true);
after.setNameId(323);
final Command.LabelTokenCommand command = new Command.LabelTokenCommand(before, after);
final Token token = new Token("token", 21);
when(labelTokenStore.getToken((int) command.getKey())).thenReturn(token);
// when
boolean result = apply(applier, command::handle, transactionToApply);
// then
assertFalse(result);
verify(labelTokenStore, times(1)).setHighestPossibleIdInUse(after.getId());
verify(labelTokenStore, times(1)).updateRecord(after);
verify(cacheAccess, times(1)).addLabelToken(token);
}
use of org.neo4j.kernel.impl.api.BatchTransactionApplier in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyLabelTokenCommandToTheStore.
// LABEL TOKEN COMMAND
@Test
public void shouldApplyLabelTokenCommandToTheStore() throws Exception {
// given
final BatchTransactionApplier applier = newApplier(false);
final LabelTokenRecord before = new LabelTokenRecord(42);
final LabelTokenRecord after = new LabelTokenRecord(42);
after.setInUse(true);
after.setNameId(323);
final Command command = new LabelTokenCommand(before, after);
// when
boolean result = apply(applier, command::handle, transactionToApply);
// then
assertFalse(result);
verify(labelTokenStore, times(1)).updateRecord(after);
}
Aggregations