### Question:
MongoDbRegionWidgetRepository implements RegionWidgetRepository { @Override public void delete(RegionWidget item) { Page page = getPageByRegionWidgetId(item.getId()); replaceOrRemoveWidget(page, item, false); template.save(page); }  @Override Class<? extends RegionWidget> getType(); @Override RegionWidget get(String id); @Override RegionWidget save(RegionWidget item); @Override void delete(RegionWidget item); @Override List<RegionWidget> getAll(); @Override List<RegionWidget> getLimitedList(int offset, int pageSize); @Override int getCountAll(); void setTemplate(MongoPageOperations template);  }### Answer:
@Test public void delete_Null() { RegionWidgetImpl item = new RegionWidgetImpl(); String id = "123"; item.setId(id); Page page = new PageImpl(); page.setRegions(new ArrayList<Region>()); expect(template.findOne(getQuery(id))).andReturn(page); replay(template); thrown.expect(IllegalStateException.class); thrown.expectMessage("Widget does not exist in parent page regions"); widgetRepository.delete(item); }
@Test public void delete_DifferentId() { RegionWidgetImpl widget = new RegionWidgetImpl(); Region region = new RegionImpl(); Page page = new PageImpl(); page.setRegions(Arrays.asList(region)); region.setRegionWidgets(Arrays.<RegionWidget>asList(widget)); widget.setId("345345"); RegionWidgetImpl item = new RegionWidgetImpl(); String id = "4344"; item.setId(id); expect(template.findOne(getQuery(id))).andReturn(page); replay(template); thrown.expect(IllegalStateException.class); thrown.expectMessage("Widget does not exist in parent page regions"); widgetRepository.delete(item); }