### Question:
LegacyConfigManagement extends ConfigManagementSupport { public void executeUpdate(int resourceId, Configuration configuration) throws PluginContainerException { ConfigurationFacet facet = loadConfigurationFacet(resourceId, WRITE); ConfigurationUpdateReport report = new ConfigurationUpdateReport(configuration); facet.updateResourceConfiguration(report); if (ConfigurationUpdateStatus.SUCCESS == report.getStatus()) { return; } if (ConfigurationUpdateStatus.INPROGRESS == report.getStatus()) { throw new UpdateInProgressException(); } if (ConfigurationUpdateStatus.FAILURE == report.getStatus()) { throw new ConfigurationUpdateException(report.getErrorMessage()); } }  Configuration executeLoad(int resourceId); void executeUpdate(int resourceId, Configuration configuration);  }### Answer:
@Test public void facetShouldBeCalledToUpdateStructured() throws Exception { final Configuration config = new Configuration(); final ConfigurationUpdateReport updateReport = new ConfigurationUpdateReport(config); final boolean isDaemonThread = false; context.checking(new Expectations() {{ atLeast(1).of(componentService).getComponent(resourceId, ConfigurationFacet.class, FacetLockType.WRITE, ConfigManagement.FACET_METHOD_TIMEOUT, isDaemonThread, onlyIfStarted); will(returnValue(facet)); oneOf(facet).updateResourceConfiguration(with(matchingUpdateReport(updateReport))); will(updateReportTo(SUCCESS)); }}); configMgmt.executeUpdate(resourceId, config); }
@Test(expectedExceptions = UpdateInProgressException.class) public void exceptionShouldBeThrownWhenUpdateDoesNotComplete() throws Exception { final Configuration config = new Configuration(); final ConfigurationUpdateReport updateReport = new ConfigurationUpdateReport(config); final boolean isDaemonThread = false; context.checking(new Expectations() {{ atLeast(1).of(componentService).getComponent(resourceId, ConfigurationFacet.class, FacetLockType.WRITE, ConfigManagement.FACET_METHOD_TIMEOUT, isDaemonThread, onlyIfStarted); will(returnValue(facet)); oneOf(facet).updateResourceConfiguration(with(matchingUpdateReport(updateReport))); will(updateReportTo(INPROGRESS)); }}); configMgmt.executeUpdate(resourceId, config); }
@Test(expectedExceptions = ConfigurationUpdateException.class) public void exceptionShouldBeThrownWhenUpdateFails() throws Exception { final Configuration config = new Configuration(); final ConfigurationUpdateReport updateReport = new ConfigurationUpdateReport(config); final boolean isDaemonThread = false; context.checking(new Expectations() {{ atLeast(1).of(componentService).getComponent(resourceId, ConfigurationFacet.class, FacetLockType.WRITE, ConfigManagement.FACET_METHOD_TIMEOUT, isDaemonThread, onlyIfStarted); will(returnValue(facet)); oneOf(facet).updateResourceConfiguration(with(matchingUpdateReport(updateReport))); will(updateReportTo(FAILURE)); }}); configMgmt.executeUpdate(resourceId, config); }