### Question:
MongoDbRegionRepository implements RegionRepository { @Override public void delete(Region item) { Page page; if(item.getId() == null) { throw new IllegalStateException("Unidentifiable region (null id)"); } else { page = getPageByRegionId(item.getId()); removeRegion(page, item); } template.save(page); }  @Override Class<? extends Region> getType(); @Override Region get(String  id); @Override Region save(Region item); @Override void delete(Region item); @Override List<Region> getAll(); @Override List<Region> getLimitedList(int offset, int pageSize); @Override int getCountAll(); MongoPageOperations getTemplate(); void setTemplate(MongoPageOperations template);  }### Answer:
@Test public void delete(){ Page page = new PageImpl("1234L"); List<Region> regions = Lists.newArrayList(); Region item = new RegionImpl("1111L"); regions.add(item); page.setRegions(regions); expect(template.findOne(new Query(Criteria.where("regions").elemMatch(Criteria.where("_id").is("1111L"))))).andReturn(page); expect(template.save(isA(Page.class))).andReturn(page); replay(template); repo.delete(item); }
@Test (expected = IllegalStateException.class) public void delete_null(){ Page page = new PageImpl("1234L"); List<Region> regions = Lists.newArrayList(); Region item = new RegionImpl(); regions.add(item); page.setRegions(regions); repo.delete(item); }