Page toPageValue = new PageImpl();
toPageValue.setRegions(new ArrayList<Region>());
toPageValue.getRegions().add(originalRegion);
toPageValue.getRegions().add(targetRegion);
Region region = new RegionImpl();
region.setLocked(false);
region.setRegionWidgets(Lists.<RegionWidget>newArrayList());
RegionWidget regionWidget = new RegionWidgetImpl(VALID_REGION_WIDGET_ID);
regionWidget.setRegion(region);
region.getRegionWidgets().add(regionWidget);
expect(pageRepository.get(TO_PAGE_ID)).andReturn(toPageValue);
expect(regionWidgetRepository.get(WIDGET_ID)).andReturn(regionWidget).times(2);
expect(regionRepository.save(originalRegion)).andReturn(originalRegion);
expect(regionRepository.save(region)).andReturn(region);
replay(pageRepository, regionWidgetRepository, regionRepository);
RegionWidget updatedRegionWidget = pageService.moveRegionWidgetToPage(VALID_REGION_WIDGET_ID, TO_PAGE_ID);
verify(pageRepository);
verify(regionWidgetRepository);
verifyPositions(0, regionWidget, true);
assertThat(region.getRegionWidgets().isEmpty(), is(true));
}