### Question:
IntegrityValidator { public void validateTransactionStartKnowledge( long lastCommittedTxWhenTransactionStarted ) throws TransactionFailureException { long latestConstraintIntroducingTx = neoStores.getMetaDataStore().getLatestConstraintIntroducingTx(); if ( lastCommittedTxWhenTransactionStarted < latestConstraintIntroducingTx ) { throw new TransactionFailureException( Status.Transaction.ConstraintsChanged, "Database constraints have changed (txId=%d) after this transaction (txId=%d) started, " + "which is not yet supported. Please retry your transaction to ensure all " + "constraints are executed.", latestConstraintIntroducingTx, lastCommittedTxWhenTransactionStarted ); } } IntegrityValidator( NeoStores neoStores, IndexingService indexes ); void validateNodeRecord( NodeRecord record ); void validateTransactionStartKnowledge( long lastCommittedTxWhenTransactionStarted ); void validateSchemaRule( SchemaRule schemaRule );  }### Answer:
@Test public void transactionsStartedBeforeAConstraintWasCreatedAreDisallowed() { NeoStores store = mock( NeoStores.class ); MetaDataStore metaDataStore = mock( MetaDataStore.class ); when( store.getMetaDataStore() ).thenReturn( metaDataStore ); IndexingService indexes = mock( IndexingService.class ); when( metaDataStore.getLatestConstraintIntroducingTx() ).thenReturn( 10L ); IntegrityValidator validator = new IntegrityValidator( store, indexes ); try { validator.validateTransactionStartKnowledge( 1 ); fail( "Should have thrown integrity error." ); } catch ( Exception e ) { } }