List<Country> dummyCountries = dummyLoad.getCountries();
Assert.assertEquals(2, dummyCountries.size());
// assert that the cache contains the expected entry
Assert.assertEquals("countries cache now loaded with 1 entry", 1, cachedBeanCountriesCache.size());
CachedManyIds dummyEntry = (CachedManyIds) cachedBeanCountriesCache.get(dummyLoad.getId());
Assert.assertNotNull(dummyEntry);
Assert.assertEquals("2 ids in the entry", 2, dummyEntry.getIdList().size());
Assert.assertTrue(dummyEntry.getIdList().contains("NZ"));
Assert.assertTrue(dummyEntry.getIdList().contains("AU"));
// act - this should invalidate our cache entry
OCachedBean update = new OCachedBean();
update.setId(cachedBean.getId());
update.setName("modified");
update.getCountries().add(Ebean.find(Country.class, "AU"));
Ebean.update(update);
Assert.assertEquals("countries entry still there (but updated)", 1, cachedBeanCountriesCache.size());
CachedManyIds cachedManyIds = (CachedManyIds) cachedBeanCountriesCache.get(update.getId());
// assert cache updated
Assert.assertEquals(1, cachedManyIds.getIdList().size());
Assert.assertFalse(cachedManyIds.getIdList().contains("NZ"));
Assert.assertTrue(cachedManyIds.getIdList().contains("AU"));
// assert countries good
OCachedBean result = Ebean.find(OCachedBean.class, cachedBean.getId());
Assert.assertEquals(1, result.getCountries().size());