@Test public void shouldGetConstraintsByLabel() throws Exception { // given UniquenessConstraint constraint1 = new UniquenessConstraint(11, 66); UniquenessConstraint constraint2 = new UniquenessConstraint(11, 99); TxState txState = new TxStateImpl( mock(OldTxStateBridge.class), mock(PersistenceManager.class), mock(IdGeneration.class)); KernelStatement state = mockedState(txState); when(inner.constraintsGetForLabelAndPropertyKey(10, 66)) .thenAnswer(asAnswer(Collections.emptyList())); when(inner.constraintsGetForLabelAndPropertyKey(11, 99)) .thenAnswer(asAnswer(Collections.emptyList())); when(inner.constraintsGetForLabel(10)).thenAnswer(asAnswer(Collections.emptyList())); when(inner.constraintsGetForLabel(11)).thenAnswer(asAnswer(asIterable(constraint1))); StateHandlingStatementOperations context = newTxStateOps(inner); context.uniquenessConstraintCreate(state, 10, 66); context.uniquenessConstraintCreate(state, 11, 99); // when Set<UniquenessConstraint> result = asSet(asIterable(context.constraintsGetForLabel(state, 11))); // then assertEquals(asSet(constraint1, constraint2), result); }
@Override public Iterator<UniquenessConstraint> constraintsGetForLabel(KernelStatement state, int labelId) { return applyConstraintsDiff(state, storeLayer.constraintsGetForLabel(labelId), labelId); }