@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 public void onlineConstraintShouldNotConflictOnIntermediateStatesInSameTransaction() { // Given givenOnlineConstraint(); // When transaction( setProperty( a, "b" ), setProperty( b, "a" ), success ); // Then transaction( assertLookupNode( "a", is( b ) ), assertLookupNode( "b", is( a ) ) ); }
@Test public void onlineConstraintShouldAcceptDistinctValuesInDifferentTransactions() { // Given givenOnlineConstraint(); // When Node n; try ( Transaction tx = db.beginTx() ) { n = db.createNode( label ); n.setProperty( property, "n" ); tx.success(); } // Then transaction( assertLookupNode( "a", is( a ) ), assertLookupNode( "n" , is( n ) ) ); }
@Test public void onlineConstraintShouldAcceptUniqueEntryChanges() { // Given givenOnlineConstraint(); // When transaction( setProperty( a, "a1" ), success ); // This is a CHANGE update // Then transaction( assertLookupNode( "a1", is( a ) ) ); }
@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 ) ) ); }
@Test public void onlineConstraintShouldAcceptDistinctValuesInSameTransaction() { // Given givenOnlineConstraint(); // When Node n; Node m; try ( Transaction tx = db.beginTx() ) { n = db.createNode( label ); n.setProperty( property, "n" ); m = db.createNode( label ); m.setProperty( property, "m" ); tx.success(); } // Then transaction( assertLookupNode( "n", is( n ) ), assertLookupNode( "m", is( m ) ) ); }
@Test public void onlineConstraintShouldNotFalselyCollideOnFindNodesByLabelAndProperty() { // Given givenOnlineConstraint(); Node n; Node m; try ( Transaction tx = db.beginTx() ) { n = db.createNode( label ); n.setProperty( property, COLLISION_X ); tx.success(); } // When try ( Transaction tx = db.beginTx() ) { m = db.createNode( label ); m.setProperty( property, COLLISION_Y ); tx.success(); } // Then transaction( assertLookupNode( COLLISION_X, is( n ) ), assertLookupNode( COLLISION_Y, is( m ) ) ); }