@Test( expected = ConstraintViolationException.class ) public void onlineConstraintShouldRejectConflictingPropertyChange() { // Given givenOnlineConstraint(); // Then transaction( setProperty( b, "a" ), success, fail( "Setting b.name = \"a\" should have caused a conflict" ) ); }
@Test( expected = ConstraintViolationException.class ) public void onlineConstraintShouldRejectConflictingLabelChange() { // Given givenOnlineConstraint(); // Then transaction( addLabel( c, label ), success, fail( "Setting c:Cybermen should have caused a conflict" ) ); }
@Test( expected = ConstraintViolationException.class ) public void onlineConstraintShouldRejectDuplicateEntriesAddedInSameTransaction() { // Given givenOnlineConstraint(); // Then transaction( setProperty( b, "d" ), addLabel( d, label ), success, fail( "Setting b.name = \"d\" and d:Cybermen should have caused a conflict" )); }
@Test( expected = ConstraintViolationException.class ) public void onlineConstraintShouldRejectConflictsInTheSameTransaction() { // Given givenOnlineConstraint(); // Then transaction( setProperty( a, "x" ), setProperty( b, "x" ), success, fail( "Should have rejected changes of two node/properties to the same index value" ) ); }
@Test( expected = ConstraintViolationException.class ) public void onlineConstraintShouldRejectAddingEntryForValueAlreadyIndexedByPriorChange() { // Given givenOnlineConstraint(); // When transaction( setProperty( a, "a1" ), success ); // This is a CHANGE update // Then transaction( setProperty( b, "a1" ), success, fail( "Setting b.name = \"a1\" should have caused a conflict" ) ); }
@Test( expected = ConstraintViolationException.class ) public void onlineConstraintShouldRejectChangingEntryToAlreadyIndexedValue() { // Given givenOnlineConstraint(); transaction( setProperty( b, "b" ), success ); // When transaction( setProperty( b, "a" ), success, fail( "Changing a property to an already indexed value should have thrown" ) ); }
@Test public void onlineConstraintShouldRejectChangingEntryToAlreadyIndexedValueThatOtherTransactionsAreRemoving() { // Given givenOnlineConstraint(); transaction( setProperty( b, "b" ), success ); Transaction otherTx = db.beginTx(); a.removeLabel( label ); suspend( otherTx ); // When try { transaction( setProperty( b, "a" ), success, fail( "Changing a property to an already indexed value should have thrown" ) ); } catch ( ConstraintViolationException ignore ) { // we're happy } finally { resume( otherTx ); otherTx.failure(); otherTx.close(); } }