use of com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration in project cia by Hack23.
the class ApplicationConfigurationServiceITest method checkValueOrLoadDefaultPropertyAlreadyExistSameValueTest.
/**
* Check value or load default property already exist same value test.
*
* @throws Exception
* the exception
*/
@Test
public void checkValueOrLoadDefaultPropertyAlreadyExistSameValueTest() throws Exception {
final ApplicationConfiguration checkValueOrLoadDefault = applicationConfigurationService.checkValueOrLoadDefault("checkValueOrLoadDefaultPropertyAlreadyExistSameValueTest property", "checkValueOrLoadDefaultPropertyAlreadyExistSameValueTest should be set to true/false", ConfigurationGroup.AUTHORIZATION, ApplicationConfigurationServiceITest.class.getSimpleName(), "ApplicationConfigurationService ITest", "FunctionalIntegrationTest", "checkValueOrLoadDefaultPropertyAlreadyExistSameValueTest", "true");
final ApplicationConfiguration checkValueOrLoadDefault2 = applicationConfigurationService.checkValueOrLoadDefault("checkValueOrLoadDefaultPropertyAlreadyExistSameValueTest property", "checkValueOrLoadDefaultPropertyAlreadyExistSameValueTest should be set to true/false", ConfigurationGroup.AUTHORIZATION, ApplicationConfigurationServiceITest.class.getSimpleName(), "ApplicationConfigurationService ITest", "FunctionalIntegrationTest", "checkValueOrLoadDefaultPropertyAlreadyExistSameValueTest", "true");
assertEquals("Expect the config to use the first set value", checkValueOrLoadDefault, checkValueOrLoadDefault2);
}
use of com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration in project cia by Hack23.
the class AbstractServiceFunctionalIntegrationTest method restoreMailConfiguration.
/**
* Restore mail configuration.
*
* @param createTestApplicationSession
* the create test application session
* @param dumbster
* the dumbster
*/
protected final void restoreMailConfiguration(final CreateApplicationSessionRequest createTestApplicationSession, final SimpleSmtpServer dumbster) {
final ApplicationConfiguration sendEmail = applicationConfigurationService.checkValueOrLoadDefault("Email configuration send emails", "Send email", ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), "Send email", "Responsible for sending email", "application.email.send.email", "false");
final ApplicationConfiguration smtpPort = applicationConfigurationService.checkValueOrLoadDefault("Email configuration smtp port", "Smtp port", ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), "Smtp port", "Responsible for sending email", "application.email.smtp.port", "587");
updateApplicationConfiguration(createTestApplicationSession, sendEmail, "false");
updateApplicationConfiguration(createTestApplicationSession, smtpPort, "587");
dumbster.stop();
}
use of com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration 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.model.internal.application.system.impl.ApplicationConfiguration 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());
}
use of com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration in project cia by Hack23.
the class EmailServiceImpl method getMailSender.
/**
* Gets the mail sender.
*
* @return the mail sender
*/
private JavaMailSender getMailSender() {
final JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
final ApplicationConfiguration smtpHostConfig = applicationConfigurationService.checkValueOrLoadDefault(EMAIL_CONFIGURATION_SMTP_HOST, SMTP_HOST, ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), SMTP_HOST, RESPONSIBLE_FOR_SENDING_EMAIL, APPLICATION_EMAIL_SMTP_HOST, "localhost");
final ApplicationConfiguration smtpPort = applicationConfigurationService.checkValueOrLoadDefault(EMAIL_CONFIGURATION_SMTP_PORT, SMTP_PORT, ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), SMTP_PORT, RESPONSIBLE_FOR_SENDING_EMAIL, APPLICATION_EMAIL_SMTP_PORT, "587");
final ApplicationConfiguration smtpUsername = applicationConfigurationService.checkValueOrLoadDefault(EMAIL_CONFIGURATION_SMTP_USERNAME, SMTP_USERNAME, ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), SMTP_USERNAME, RESPONSIBLE_FOR_SENDING_EMAIL, APPLICATION_EMAIL_SMTP_USERNAME, "username");
final ApplicationConfiguration smtpPassword = applicationConfigurationService.checkValueOrLoadDefault(EMAIL_CONFIGURATION_SMTP_SECRET, SMTP_SECRET, ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), SMTP_SECRET, RESPONSIBLE_FOR_SENDING_EMAIL, APPLICATION_EMAIL_SMTP_SECRET, "password");
final ApplicationConfiguration smtpAuth = applicationConfigurationService.checkValueOrLoadDefault(EMAIL_CONFIGURATION_SMTP_AUTH, SMTP_AUTH, ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), SMTP_AUTH, RESPONSIBLE_FOR_SENDING_EMAIL, APPLICATION_EMAIL_SMTP_AUTH, "true");
final ApplicationConfiguration smtpStartTlsEnable = applicationConfigurationService.checkValueOrLoadDefault(EMAIL_CONFIGURATION_SMTP_STARTTLS_ENABLE, SMTP_STARTTLS_ENABLE, ConfigurationGroup.EXTERNAL_SERVICES, EmailServiceImpl.class.getSimpleName(), SMTP_STARTTLS_ENABLE, RESPONSIBLE_FOR_SENDING_EMAIL, APPLICATION_EMAIL_SMTP_STARTTLS_ENABLE, "true");
javaMailSender.setHost(smtpHostConfig.getPropertyValue());
javaMailSender.setPort(Integer.parseInt(smtpPort.getPropertyValue()));
javaMailSender.setUsername(smtpUsername.getPropertyValue());
javaMailSender.setPassword(smtpPassword.getPropertyValue());
final Properties javaMailProperties = new Properties();
javaMailProperties.setProperty(MAIL_SMTP_AUTH, smtpAuth.getPropertyValue());
javaMailProperties.setProperty(MAIL_SMTP_STARTTLS_ENABLE, smtpStartTlsEnable.getPropertyValue());
javaMailSender.setJavaMailProperties(javaMailProperties);
return javaMailSender;
}
Aggregations