IndexRepositoryImpl extends AbstractCRUDRepository<Index> implements IndexRepository { @Override public void delete(Identifier id) { BoundStatement bs = new BoundStatement(deleteStmt); bindIdentifier(bs, id); getSession().execute(bs); try { Cache c = CacheFactory.getCache("index"); String key = id.getDatabaseName() + ":" + id.getTableName(); synchronized (CacheSynchronizer.getLockingObject(key, Index.class)) { List<Index> currentIndex = this.readAll(id); if (!currentIndex.isEmpty()) { Element e = new Element(key, currentIndex); c.put(e); } else { c.put(null); } } } catch (Exception e) { logger.error("Could not update index cache upon index delete.", e); } cascadeDelete(new IndexIdentifier(id)); } 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 testDelete() { System.out.println("delete"); Index entity = Fixtures.createTestIndexOneField(); f.insertIndex(entity); IndexRepositoryImpl instance = new IndexRepositoryImpl(f.getSession()); instance.delete(entity); boolean expectedExceptionThrown = false; try { instance.read(entity.getId()); } catch (ItemNotFoundException e) { expectedExceptionThrown = true; } assertTrue("Expected exception not thrown", expectedExceptionThrown); assertFalse("ITable was not deleted.", iTableRepo.iTableExists(entity)); }