use of org.neo4j.kernel.impl.transaction.log.Commitment in project neo4j by neo4j.
the class LegacyBatchIndexApplierTest method shouldOnlyCreateOneApplierPerProvider.
@Test
public void shouldOnlyCreateOneApplierPerProvider() throws Exception {
// GIVEN
Map<String, Integer> names = MapUtil.genericMap("first", 0, "second", 1);
Map<String, Integer> keys = MapUtil.genericMap("key", 0);
String applierName = "test-applier";
Commitment commitment = mock(Commitment.class);
when(commitment.hasLegacyIndexChanges()).thenReturn(true);
IndexConfigStore config = newIndexConfigStore(names, applierName);
LegacyIndexApplierLookup applierLookup = mock(LegacyIndexApplierLookup.class);
when(applierLookup.newApplier(anyString(), anyBoolean())).thenReturn(mock(TransactionApplier.class));
try (LegacyBatchIndexApplier applier = new LegacyBatchIndexApplier(config, applierLookup, BYPASS, INTERNAL)) {
TransactionToApply tx = new TransactionToApply(null, 2);
tx.commitment(commitment, 2);
try (TransactionApplier txApplier = applier.startTx(tx)) {
// WHEN
IndexDefineCommand definitions = definitions(names, keys);
txApplier.visitIndexDefineCommand(definitions);
txApplier.visitIndexAddNodeCommand(addNodeToIndex(definitions, "first"));
txApplier.visitIndexAddNodeCommand(addNodeToIndex(definitions, "second"));
txApplier.visitIndexAddRelationshipCommand(addRelationshipToIndex(definitions, "second"));
}
}
// THEN
verify(applierLookup, times(1)).newApplier(eq(applierName), anyBoolean());
}
Aggregations