@Test public void onlineConstraintShouldAcceptUniqueEntries() { // Given givenOnlineConstraint(); // When transaction( setProperty( b, "b" ), addLabel( d, label ), success ); transaction( setProperty( c, "c" ), addLabel( c, label ), success ); // Then transaction( assertLookupNode( "a", is( a ) ), assertLookupNode( "b", is( b ) ), assertLookupNode( "c", is( c ) ), assertLookupNode( "d", is( d ) ) ); }
@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 public void onlineConstraintShouldAddAndRemoveFromIndexAsPropertiesAndLabelsChange() { // Given givenOnlineConstraint(); // When transaction( setProperty( b, "b" ), success ); transaction( setProperty( c, "c" ), addLabel( c, label ), success ); transaction( setProperty( d, "d" ), addLabel( d, label ), success ); transaction( removeProperty( a ), success ); transaction( removeProperty( b ), success ); transaction( removeProperty( c ), success ); transaction( setProperty( a, "a" ), success ); transaction( setProperty( c, "c2" ), success ); // Then transaction( assertLookupNode( "a", is( a ) ), assertLookupNode( "b", is( nullValue( Node.class ) ) ), assertLookupNode( "c", is( nullValue( Node.class ) ) ), assertLookupNode( "d", is( d ) ), assertLookupNode( "c2", is( c ) ) ); }