### Question:
InMemoryDatabaseTemplate extends AbstractDatabaseTemplate implements Resettable { @Override public <T extends Item> T read(final ItemId itemId, final Class<T> itemClass) throws NonExistentItemException { final SerializedItem serializedItem = getItemMap(getItemTableName(itemClass)).get(itemId); if (serializedItem == null) { throw new NonExistentItemException("Item with identifier [" + itemId.value() + "] did not exist"); } final T item = serializedItem.getEntity(itemClass); if (itemClass.isAssignableFrom(item.getClass())) { return item; } throw new NonExistentItemException("Item with identifier [" + itemId.value() + "] did not exist"); } InMemoryDatabaseTemplate(final DatabaseSchemaHolder databaseSchemaHolder); @Override T read(final ItemId itemId, final Class<T> itemClass); @Override T create(final T item,
            final PersistenceExceptionHandler<?>... persistenceExceptionHandlers); @SuppressWarnings("unchecked") @Override T update(final T item,
            final PersistenceExceptionHandler<?>... persistenceExceptionHandlers); @Override void delete(final Item item, final PersistenceExceptionHandler<?>... persistenceExceptionHandlers); @Override Collection<T> fetch(final Query query, final Class<T> itemClass); @Override GeneratedKeyHolder generateKeys(final SequenceKeyGenerator sequenceKeyGenerator); @Override void reset();  }### Answer:
@Test public void shouldNotReadBack_withUnknownId() { final InMemoryDatabaseTemplate databaseTemplate = new InMemoryDatabaseTemplate(databaseSchemaHolder); final ItemId unknownId = new ItemId(randomId()); NonExistentItemException expectedException = null; try { databaseTemplate.read(unknownId, StubItem.class); } catch (final NonExistentItemException e) { expectedException = e; } assertNotNull(expectedException); }
@Test public void shouldNotReadBack_withUnknownCompoundPk() { final InMemoryDatabaseTemplate databaseTemplate = new InMemoryDatabaseTemplate(databaseSchemaHolder); final ItemId unknownId = new ItemId(randomId(), randomId()); NonExistentItemException expectedException = null; try { databaseTemplate.read(unknownId, StubItem.class); } catch (final NonExistentItemException e) { expectedException = e; } assertNotNull(expectedException); }