use of com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse in project cia by Hack23.
the class UpdateApplicationConfigurationService method processService.
@Override
@Secured({ "ROLE_ADMIN" })
public UpdateApplicationConfigurationResponse processService(final UpdateApplicationConfigurationRequest serviceRequest) {
final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
final UpdateApplicationConfigurationResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
final UserAccount userAccount = getUserAccountFromSecurityContext();
if (userAccount != null) {
eventRequest.setUserId(userAccount.getUserId());
}
UpdateApplicationConfigurationResponse response;
final ApplicationConfiguration applicationConfiguration = applicationConfigurationDAO.load(serviceRequest.getApplicationConfigurationId());
if (applicationConfiguration != null) {
eventRequest.setElementId(serviceRequest.getApplicationConfigurationId().toString());
applicationConfiguration.setConfigTitle(serviceRequest.getConfigTitle());
applicationConfiguration.setConfigDescription(serviceRequest.getConfigDescription());
applicationConfiguration.setComponentTitle(serviceRequest.getComponentTitle());
applicationConfiguration.setComponentDescription(serviceRequest.getComponentDescription());
applicationConfiguration.setPropertyValue(serviceRequest.getPropertyValue());
applicationConfigurationDAO.persist(applicationConfiguration);
response = new UpdateApplicationConfigurationResponse(ServiceResult.SUCCESS);
} else {
response = new UpdateApplicationConfigurationResponse(ServiceResult.FAILURE);
}
eventRequest.setApplicationMessage(response.getResult().toString());
createApplicationEventService.processService(eventRequest);
return response;
}
use of com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse in project cia by Hack23.
the class AbstractServiceFunctionalIntegrationTest method updateApplicationConfiguration.
/**
* Update application configuration.
*
* @param createTestApplicationSession
* the create test application session
* @param applicationConfiguration
* the application configuration
* @param propertyValue
* the property value
*/
private void updateApplicationConfiguration(final CreateApplicationSessionRequest createTestApplicationSession, final ApplicationConfiguration applicationConfiguration, final String propertyValue) {
final UpdateApplicationConfigurationRequest serviceRequest = new UpdateApplicationConfigurationRequest();
serviceRequest.setApplicationConfigurationId(applicationConfiguration.getHjid());
serviceRequest.setSessionId(createTestApplicationSession.getSessionId());
serviceRequest.setComponentDescription(applicationConfiguration.getComponentDescription());
serviceRequest.setConfigDescription(applicationConfiguration.getConfigDescription());
serviceRequest.setConfigTitle(applicationConfiguration.getConfigTitle());
serviceRequest.setComponentTitle(applicationConfiguration.getComponentTitle());
serviceRequest.setPropertyValue(propertyValue);
final UpdateApplicationConfigurationResponse response = (UpdateApplicationConfigurationResponse) applicationManager.service(serviceRequest);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
}
use of com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse in project cia by Hack23.
the class UpdateApplicationConfigurationServiceITest method successTest.
/**
* Success test.
*
* @throws Exception
* the exception
*/
@Test
public void successTest() throws Exception {
setAuthenticatedAdminuser();
final CreateApplicationSessionRequest createTestApplicationSession = createTestApplicationSession();
final String randomUUID = UUID.randomUUID().toString();
final ApplicationConfiguration applicationConfigurationToUpdate = applicationConfigurationService.checkValueOrLoadDefault("UpdateApplicationRequestTest property", "UpdateApplicationRequestTest should be set to true/false", ConfigurationGroup.AUTHORIZATION, UpdateApplicationConfigurationServiceITest.class.getSimpleName(), "UpdateApplicationConfigurationService ITest", "FunctionalIntegrationTest", "UpdateApplicationRequestTest." + randomUUID, "true");
final UpdateApplicationConfigurationRequest serviceRequest = new UpdateApplicationConfigurationRequest();
serviceRequest.setApplicationConfigurationId(applicationConfigurationToUpdate.getHjid());
serviceRequest.setSessionId(createTestApplicationSession.getSessionId());
serviceRequest.setComponentDescription("componentDescription");
serviceRequest.setConfigDescription("configDescription");
serviceRequest.setConfigTitle("configTitle");
serviceRequest.setComponentTitle("componentTitle");
serviceRequest.setPropertyValue("false");
final UpdateApplicationConfigurationResponse response = (UpdateApplicationConfigurationResponse) applicationManager.service(serviceRequest);
assertNotNull(EXPECT_A_RESULT, response);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
final ApplicationConfiguration applicationConfigurationUpdated = applicationConfigurationService.checkValueOrLoadDefault("UpdateApplicationRequestTest property", "UpdateApplicationRequestTest should be set to true/false", ConfigurationGroup.AUTHORIZATION, UpdateApplicationConfigurationServiceITest.class.getSimpleName(), "UpdateApplicationConfigurationService ITest", "FunctionalIntegrationTest", "UpdateApplicationRequestTest." + randomUUID, "true");
assertEquals("false", applicationConfigurationUpdated.getPropertyValue());
assertEquals("configTitle", applicationConfigurationUpdated.getConfigTitle());
assertEquals("configDescription", applicationConfigurationUpdated.getConfigDescription());
assertEquals("componentTitle", applicationConfigurationUpdated.getComponentTitle());
assertEquals("componentDescription", applicationConfigurationUpdated.getComponentDescription());
}
Aggregations