### Question:
ExplicitIndexTransactionStateImpl implements ExplicitIndexTransactionState, IndexCommandFactory { @Override public boolean checkIndexExistence( IndexEntityType entityType, String indexName, Map<String,String> config ) { Map<String, String> configuration = indexConfigStore.get( entityType.entityClass(), indexName ); if ( configuration == null ) { return false; } String providerName = configuration.get( IndexManager.PROVIDER ); IndexImplementation provider = providerLookup.getProviderByName( providerName ); assertConfigMatches( provider, indexName, configuration, config ); return true; } ExplicitIndexTransactionStateImpl( IndexConfigStore indexConfigStore,
            ExplicitIndexProvider explicitIndexProvider ); @Override ExplicitIndex nodeChanges( String indexName ); @Override ExplicitIndex relationshipChanges( String indexName ); @Override void extractCommands( Collection<StorageCommand> target ); @Override void addNode( String indexName, long id, String key, Object value ); @Override void addRelationship( String indexName, long id, String key, Object value,
            long startNode, long endNode ); @Override void removeNode( String indexName, long id,
            String keyOrNull, Object valueOrNull ); @Override void removeRelationship( String indexName, long id,
            String keyOrNull, Object valueOrNull ); @Override void deleteIndex( IndexEntityType entityType, String indexName ); @Override void createIndex( IndexEntityType entityType, String indexName, Map<String, String> config ); @Override boolean hasChanges(); @Override boolean checkIndexExistence( IndexEntityType entityType, String indexName, Map<String,String> config ); @Override void close();  }### Answer:
@Test public void shouldReportIndexExists() { ExplicitIndexTransactionStateImpl state = newExplicitIndexTxState(); boolean nodeExists = state.checkIndexExistence( IndexEntityType.Node, "name", null ); boolean relExists = state.checkIndexExistence( IndexEntityType.Relationship, "name", null ); assertTrue( nodeExists ); assertTrue( relExists ); }
@Test public void shouldReportIndexExistsWithMatchingConfiguration() { ExplicitIndexTransactionStateImpl state = newExplicitIndexTxState(); when( provider.configMatches( anyMap(), anyMap() ) ).thenReturn( true ); boolean nodeExists = state.checkIndexExistence( IndexEntityType.Node, "name", config ); boolean relExists = state.checkIndexExistence( IndexEntityType.Node, "name", config ); assertTrue( nodeExists ); assertTrue( relExists ); }
@Test public void shouldThrowOnIndexExistsWithMismatchingConfiguration() { ExplicitIndexTransactionStateImpl state = newExplicitIndexTxState(); when( provider.configMatches( anyMap(), anyMap() ) ).thenReturn( false ); try { state.checkIndexExistence( IndexEntityType.Node, "name", config ); fail( "Should've failed" ); } catch ( IllegalArgumentException e ) { } try { state.checkIndexExistence( IndexEntityType.Node, "name", config ); fail( "Should have failed" ); } catch ( IllegalArgumentException e ) { } }
@Test public void shouldReportIndexDoesNotExist() { ExplicitIndexTransactionStateImpl state = newExplicitIndexTxState(); when( indexConfigStore.get( any( Class.class ), anyString() ) ).thenReturn( null ); boolean exists = state.checkIndexExistence( IndexEntityType.Relationship, "name", null ); assertFalse( exists ); }