### Question:
ItemConfiguration { public boolean hasIndexForQuery(final AttributeQuery attributeQuery) { String indexName; if (CompoundAttributeQuery.class.isAssignableFrom(attributeQuery.getClass())) { final CompoundAttributeQuery compoundAttributeQuery = (CompoundAttributeQuery) attributeQuery; indexName = compoundName(attributeQuery.getAttributeName(), compoundAttributeQuery.getSupportingAttributeName()); } else { indexName = attributeQuery.getAttributeName(); } return hasIndexOn(indexName); } ItemConfiguration(final Class<? extends Item> itemClass, final String tableName);  ItemConfiguration(final Class<? extends Item> itemClass, final String tableName,
            final PrimaryKeyDefinition primaryKeyDefinition); void registerIndexes(final Collection<IndexDefinition> indexDefinitions); void registerUniqueConstraints(final Collection<UniqueConstraint> uniqueConstraints); boolean hasIndexOn(final String propertyName); ItemId getItemId(final Item item); Class<? extends Item> itemClass(); String tableName(); PrimaryKeyDefinition primaryKeyDefinition(); Collection<PropertyDescriptor> propertyDescriptors(); Collection<IndexDefinition> indexDefinitions(); Collection<UniqueConstraint> uniqueConstraints(); boolean hasIndexForQuery(final AttributeQuery attributeQuery); PropertyDescriptor getPropertyDescriptor(final String propertyName); String indexNameForQuery(final AttributeQuery attributeQuery);  }### Answer:
@Test public void shouldReturnHasIndexForQuery_withAttributeQueryOnPrimaryKey() throws Exception { final Class<? extends Item> itemClass = StubItem.class; final String tableName = randomString(10); final ItemConfiguration itemConfiguration = new ItemConfiguration(itemClass, tableName); final Condition condition = new Condition(randomEnum(Operators.class), randomString()); final AttributeQuery attributeQuery = new AttributeQuery("id", condition); final boolean hasIndexForQuery = itemConfiguration.hasIndexForQuery(attributeQuery); assertTrue(hasIndexForQuery); }
@Test public void shouldNotReturnHasIndexForQuery_withAttributeQuery() throws Exception { final Class<? extends Item> itemClass = StubItem.class; final String tableName = randomString(10); final ItemConfiguration itemConfiguration = new ItemConfiguration(itemClass, tableName); final String propertyName = "stringProperty"; final Condition condition = new Condition(randomEnum(Operators.class), randomString()); final AttributeQuery attributeQuery = new AttributeQuery(propertyName, condition); final boolean hasIndexForQuery = itemConfiguration.hasIndexForQuery(attributeQuery); assertFalse(hasIndexForQuery); }
@Test public void shouldNotReturnHasIndexForQuery_withCompositeAttributeQuery() throws Exception { final Class<? extends Item> itemClass = StubItem.class; final String tableName = randomString(10); final ItemConfiguration itemConfiguration = new ItemConfiguration(itemClass, tableName); final String stringPropertyName = "stringProperty"; final String integerPropertyName = "integerProperty"; final Condition condition = new Condition(randomEnum(Operators.class), randomString()); final CompoundAttributeQuery compundAttributeQuery = new CompoundAttributeQuery(stringPropertyName, condition, integerPropertyName, condition); final boolean hasIndexForQuery = itemConfiguration.hasIndexForQuery(compundAttributeQuery); assertFalse(hasIndexForQuery); }