@Test public void populatingConstraintMustAcceptDatasetOfUniqueEntries() { // Given givenUniqueDataset(); // Then this does not throw: createUniqueConstraint(); }
@Test public void populatingConstraintMustAcceptDatasetThatGetsUpdatedWithUniqueEntries() throws Exception { // Given givenUniqueDataset(); // When Future<?> createConstraintTransaction = applyChangesToPopulatingUpdater( d.getId(), a.getId(), setProperty( d, "d1" ) ); // Then observe that our constraint was created successfully: createConstraintTransaction.get(); // Future.get() will throw an ExecutionException, if the Runnable threw an exception. }
@Test( expected = ConstraintViolationException.class ) public void populatingConstraintMustRejectDatasetWithDuplicateEntries() { // Given givenUniqueDataset(); transaction( setProperty( c, "b" ), // same property value as 'b' has success ); // Then this must throw: createUniqueConstraint(); }
@Test public void populatingConstraintMustRejectDatasetThatGetsUpdatedWithDuplicates() throws Exception { // Given givenUniqueDataset(); // When Future<?> createConstraintTransaction = applyChangesToPopulatingUpdater( d.getId(), a.getId(), setProperty( d, "b" ) ); // Then observe that our constraint creation failed: try { createConstraintTransaction.get(); Assert.fail( "expected to throw when PopulatingUpdater got duplicates" ); } catch ( ExecutionException ee ) { Throwable cause = ee.getCause(); assertThat( cause, instanceOf( ConstraintViolationException.class ) ); } }
@Test public void populatingConstraintMustRejectDatasetThatGetsUpdatedWithDuplicateAddition() throws Exception { // Given givenUniqueDataset(); // When Future<?> createConstraintTransaction = applyChangesToPopulatingUpdater( d.getId(), a.getId(), createNode( "b" ) ); // Then observe that our constraint creation failed: try { createConstraintTransaction.get(); Assert.fail( "expected to throw when PopulatingUpdater got duplicates" ); } catch ( ExecutionException ee ) { Throwable cause = ee.getCause(); assertThat( cause, instanceOf( ConstraintViolationException.class ) ); } }
@Test public void populatingConstraintMustRejectDatasetThatGetsUpdatedWithDuplicatesInSameTransaction() throws Exception { // Given givenUniqueDataset(); // When Future<?> createConstraintTransaction = applyChangesToPopulatingUpdater( d.getId(), a.getId(), setProperty( d, "x" ), setProperty( c, "x" ) ); // Then observe that our constraint creation failed: try { createConstraintTransaction.get(); Assert.fail( "expected to throw when PopulatingUpdater got duplicates" ); } catch ( ExecutionException ee ) { Throwable cause = ee.getCause(); assertThat( cause, instanceOf( ConstraintViolationException.class ) ); } }
@Test public void populatingConstraintMustAcceptDatasetWithDalseIndexCollisions() { // Given givenUniqueDataset(); transaction( setProperty( b, COLLISION_X ), setProperty( c, COLLISION_Y ), success ); // Then this does not throw: createUniqueConstraint(); }
@Test public void populatingUpdaterMustRejectDatasetWhereAdditionsConflictsWithPriorChanges() throws Exception { // Given givenUniqueDataset(); // When Future<?> createConstraintTransaction = applyChangesToPopulatingUpdater( d.getId(), a.getId(), setProperty( d, "x" ), createNode( "x" ) ); // Then observe that our constraint creation failed: try { createConstraintTransaction.get(); Assert.fail( "expected to throw when PopulatingUpdater got duplicates" ); } catch ( ExecutionException ee ) { Throwable cause = ee.getCause(); assertThat( cause, instanceOf( ConstraintViolationException.class ) ); } }
@Test public void populatingConstraintMustAcceptDatasetThatGestUpdatedWithFalseIndexCollisions() throws Exception { // Given givenUniqueDataset(); transaction( setProperty( a, COLLISION_X ), success ); // When Future<?> createConstraintTransaction = applyChangesToPopulatingUpdater( d.getId(), a.getId(), setProperty( d, COLLISION_Y ) ); // Then observe that our constraint was created successfully: createConstraintTransaction.get(); // Future.get() will throw an ExecutionException, if the Runnable threw an exception. }
@Test public void populatingConstraintMustAcceptDatasetThatGetsUpdatedWithDuplicatesThatAreLaterResolved() throws Exception { // Given givenUniqueDataset(); // When Future<?> createConstraintTransaction = applyChangesToPopulatingUpdater( d.getId(), a.getId(), setProperty( d, "b" ), // Cannot touch node 'a' because that one is locked setProperty( b, "c" ), setProperty( c, "d" ) ); // Then observe that our constraint was created successfully: createConstraintTransaction.get(); // Future.get() will throw an ExecutionException, if the Runnable threw an exception. }