DatabaseRepositoryImpl extends AbstractCRUDRepository<Database> implements DatabaseRepository { @Override public boolean exists(Identifier identifier) { if (identifier == null || identifier.isEmpty()) { return false; } BoundStatement bs = new BoundStatement(existStmt); bs.bind(identifier.getDatabaseName()); return (getSession().execute(bs).one().getLong(0) > 0); } DatabaseRepositoryImpl(Session session); @Override Database create(Database entity); @Override Database update(Database entity); @Override List<Database> readAll(); @Override List<Database> readAll(Identifier id); @Override boolean exists(Identifier identifier); @Override Database read(Identifier identifier); @Override void delete(Database entity); @Override void delete(Identifier identifier);  }
@Test public void testExists() { System.out.println("exists"); Database entity = Fixtures.createTestDatabase(); DatabaseRepository instance = new DatabaseRepositoryImpl(f.getSession()); boolean result = instance.exists(entity.getId()); assertEquals(false, result); instance.create(entity); result = instance.exists(entity.getId()); assertEquals(true, result); }