}
}
@Test
public void testOnDelete() throws Exception {
Hive hive = getHive();
ConfigurationReader reader = new ConfigurationReader(Continent.class, WeatherReport.class);
EntityHiveConfig config = reader.getHiveConfiguration();
HiveInterceptorDecorator interceptor = new HiveInterceptorDecorator(config, hive);
WeatherReport report = generateInstance();
Continent asia = new AsiaticContinent();
hive.directory().insertPrimaryIndexKey(report.getContinent());
hive.directory().insertPrimaryIndexKey(asia.getName());
interceptor.postFlush(Arrays.asList(new Object[]{report, asia}).iterator());
assertTrue(hive.directory().doesPrimaryIndexKeyExist(report.getContinent()));
assertTrue(hive.directory().doesResourceIdExist("WeatherReport", report.getReportId()));
assertTrue(hive.directory().doesResourceIdExist("Temperature", report.getTemperature()));
assertTrue(hive.directory().doesPrimaryIndexKeyExist(asia.getName()));
assertTrue(hive.directory().doesSecondaryIndexKeyExist("Continent", "population", asia.getPopulation(), asia.getName()));
interceptor.onDelete(report, null, null, null, null);
interceptor.onDelete(asia, null, null, null, null);
assertFalse(hive.directory().doesResourceIdExist("WeatherReport", report.getReportId()));
// Referenced entity does not get deleted
assertTrue(hive.directory().doesResourceIdExist("Temperature", report.getTemperature()));
assertFalse(hive.directory().doesPrimaryIndexKeyExist(asia.getName()));
assertFalse(hive.directory().doesSecondaryIndexKeyExist("Continent", "population", asia.getPopulation(), asia.getName()));
}