### Question:
MongoDbRegionWidgetRepository implements RegionWidgetRepository { @Override public RegionWidget get(String id) { Page page = getPageByRegionWidgetId(id); return getRegionWidgetById(page, id); }  @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 get_DifferentId() { String id = "234"; Page page = new PageImpl(); Region region = new RegionImpl(); RegionWidgetImpl widget = new RegionWidgetImpl(); widget.setId("123"); page.setRegions(Arrays.asList(region)); region.setPage(page); region.setRegionWidgets(Arrays.<RegionWidget>asList(widget)); widget.setRegion(region); expect(template.findOne(getQuery(id))).andReturn(page); replay(template); RegionWidget result = widgetRepository.get(id); assertNull(result); }
@Test public void get_Valid() { String id = "123"; Page found = new MongoDbPage(); Region region = new RegionImpl(); found.setRegions(Arrays.asList(region)); RegionWidgetImpl widget = new RegionWidgetImpl(); region.setRegionWidgets(Arrays.<RegionWidget>asList(widget)); widget.setId("123"); expect(template.findOne(getQuery(id))).andReturn(found); replay(template); assertThat(widget, is(sameInstance(widgetRepository.get(id)))); }
@Test public void get_Null() { String id = "321"; Page found = new MongoDbPage(); found.setRegions(new ArrayList<Region>()); expect(template.findOne(getQuery(id))).andReturn(found); replay(template); assertNull(widgetRepository.get(id)); }