IndexRepositoryImpl extends AbstractCRUDRepository<Index> implements IndexRepository { @Override public Index read(Identifier identifier) { if (identifier == null || identifier.isEmpty()) { return null; } BoundStatement bs = new BoundStatement(readStmt); bindIdentifier(bs, identifier); Index response = marshalRow(getSession().execute(bs).one()); if (response == null) { throw new ItemNotFoundException("ID not found: " + identifier.toString()); } return response; } IndexRepositoryImpl(Session session); @Override boolean exists(Identifier identifier); @Override Index read(Identifier identifier); @Override Index create(Index entity); @Override void markActive(Index entity); @Override Index update(Index entity); @Override void delete(Identifier id); @Override void delete(Index entity); @Override List<Index> readAll(Identifier id); @Override List<Index> readAll(); @Override List<Index> readAllCached(Identifier id); @Override long countAll(Identifier id);  }
@Test public void testReadById() { System.out.println("readById"); Index testIndex = Fixtures.createTestIndexOneField(); Identifier identifier = testIndex.getId(); IndexRepositoryImpl instance = new IndexRepositoryImpl(f.getSession()); boolean expectedExceptionThrown = false; try { instance.read(identifier); } catch (ItemNotFoundException e) { expectedExceptionThrown = true; } assertTrue("Expected exception not thrown", expectedExceptionThrown); f.insertIndex(testIndex); Index result = instance.read(identifier); assertEquals(testIndex, result); }