ConfigurationServiceImpl implements ConfigurationManagementService { @PUT @Override public Response updateConfiguration(PlatformConfiguration config) { try { RequestValidationUtil.validateUpdateConfiguration(config); DeviceMgtAPIUtils.getPlatformConfigurationManagementService().saveConfiguration(config, MDMAppConstants.RegistryConstants.GENERAL_CONFIG_RESOURCE_PATH); DeviceMgtAPIUtils.scheduleTaskService(DeviceMgtAPIUtils.getNotifierFrequency(config)); PlatformConfiguration updatedConfig = DeviceMgtAPIUtils.getPlatformConfigurationManagementService(). getConfiguration(MDMAppConstants.RegistryConstants.GENERAL_CONFIG_RESOURCE_PATH); return Response.ok().entity(updatedConfig).build(); } catch (ConfigurationManagementException e) { String msg = "Error occurred while updating the general platform configuration"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } }  @GET @Override Response getConfiguration(@HeaderParam("If-Modified-Since") String ifModifiedSince); @PUT @Override Response updateConfiguration(PlatformConfiguration config);  }
@Test(description = "This method tests the updateConfiguration method under negative conditions.", dependsOnMethods = {"testGetConfigurationWithSuccessConditions"}) public void testUpdateConfigurationUnderNegativeConditions() throws ConfigurationManagementException { Mockito.reset(platformConfigurationManagementService); PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getPlatformConfigurationManagementService")) .toReturn(platformConfigurationManagementService); Mockito.doThrow(new ConfigurationManagementException()).when(platformConfigurationManagementService) .saveConfiguration(Mockito.any(), Mockito.any()); Response response = configurationManagementService.updateConfiguration(platformConfiguration); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), "updateConfiguration request succeeded with in-valid parameters"); }