### Question:
DefaultRegionWidgetService implements RegionWidgetService { @Override @Transactional public RegionWidget saveRegionWidgetCollapsedState(String regionWidgetId, boolean collapsed) { RegionWidget regionWidget = getValidRegionWidget(regionWidgetId); regionWidget.setCollapsed(collapsed); return saveRegionWidget(regionWidget); } @Autowired  DefaultRegionWidgetService(RegionWidgetRepository regionWidgetRepository); @Override RegionWidget getRegionWidget(String regionWidgetId); @Override SearchResult<RegionWidget> getAll(); @Override SearchResult<RegionWidget> getLimitedList(int offset, int pageSize); @Override @Transactional RegionWidget saveRegionWidget(RegionWidget regionWidget); @Override @Synchronized(discriminator = "'RegionWidget'", id = "#regionWidgetId") @Transactional List<RegionWidgetPreference> saveRegionWidgetPreferences(String regionWidgetId,
                                                                    List<RegionWidgetPreference> preferences); @Override @Synchronized(discriminator = "'RegionWidget'", id = "#regionWidgetId") @Transactional RegionWidgetPreference saveRegionWidgetPreference(String regionWidgetId, RegionWidgetPreference preference); @Override @Transactional RegionWidget saveRegionWidgetCollapsedState(String regionWidgetId, boolean collapsed);  }### Answer:
@Test public void saveRegionWidgetCollapsedState() { final boolean COLLAPSED = true; RegionWidget regionWidget = new RegionWidgetImpl(VALID_REGION_WIDGET_ID); expect(regionWidgetRepository.get(VALID_REGION_WIDGET_ID)).andReturn(regionWidget); regionWidget.setCollapsed(COLLAPSED); expect(regionWidgetRepository.save(regionWidget)).andReturn(regionWidget); replay(regionWidgetRepository); assertThat(regionWidgetService.saveRegionWidgetCollapsedState(VALID_REGION_WIDGET_ID, COLLAPSED).isCollapsed(), is(COLLAPSED)); }
@Test(expected=IllegalArgumentException.class) public void saveRegionWidgetCollapsedState_invalidWidgetId() { final boolean COLLAPSED = true; expect(regionWidgetRepository.get(INVALID_REGION_WIDGET_ID)).andReturn(null); replay(regionWidgetRepository); regionWidgetService.saveRegionWidgetCollapsedState(INVALID_REGION_WIDGET_ID, COLLAPSED); }