### Question:
AttributeQuery extends AbstractQuery { public <T extends Item> Class<?> getAttributeType(final Class<T> itemClass) { return getAttributeType(attributeName, itemClass); } AttributeQuery(final String attributeName, final Condition condition); String getAttributeName(); Class<?> getAttributeType(final Class<T> itemClass); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }### Answer:
@Test public void shouldGetAttributeType_withItemClass() { final String attributeName = "id"; final Condition mockCondition = mock(Condition.class); final AttributeQuery attributeQuery = new AttributeQuery(attributeName, mockCondition); final Class<?> attributeType = attributeQuery.getAttributeType(StubItem.class); assertEquals(String.class, attributeType); }
@Test public void shouldNotGetAttributeType_withAttributeNotInItemClass() { final String attributeName = randomString(10); final Condition mockCondition = mock(Condition.class); final AttributeQuery attributeQuery = new AttributeQuery(attributeName, mockCondition); NonExistentAttributeException expectedException = null; try { attributeQuery.getAttributeType(StubItem.class); } catch (final NonExistentAttributeException e) { expectedException = e; } assertNotNull(expectedException); assertTrue(expectedException.getMessage().contains(attributeName)); assertTrue(expectedException.getMessage().contains(StubItem.class.getCanonicalName())); }