Search in sources :

Example 11 with ApplicationConfiguration

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);
}
Also used : ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration) Test(org.junit.Test)

Example 12 with ApplicationConfiguration

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();
}
Also used : EmailServiceImpl(com.hack23.cia.service.impl.email.EmailServiceImpl) ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)

Example 13 with ApplicationConfiguration

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());
}
Also used : UpdateApplicationConfigurationRequest(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest) UpdateApplicationConfigurationResponse(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse)

Example 14 with ApplicationConfiguration

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());
}
Also used : UpdateApplicationConfigurationRequest(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest) CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) UpdateApplicationConfigurationResponse(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse) ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Example 15 with ApplicationConfiguration

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;
}
Also used : JavaMailSenderImpl(org.springframework.mail.javamail.JavaMailSenderImpl) Properties(java.util.Properties) ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)

Aggregations

ApplicationConfiguration (com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)14 Date (java.util.Date)4 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)3 UpdateApplicationConfigurationRequest (com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest)3 UpdateApplicationConfigurationResponse (com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Secured (org.springframework.security.access.annotation.Secured)3 ApplicationActionEvent (com.hack23.cia.model.internal.application.system.impl.ApplicationActionEvent)2 CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)2 EmailServiceImpl (com.hack23.cia.service.impl.email.EmailServiceImpl)2 List (java.util.List)2 SimpleSmtpServer (com.dumbster.smtp.SimpleSmtpServer)1 IndicatorElement (com.hack23.cia.model.external.worldbank.indicators.impl.IndicatorElement)1 ApplicationSession (com.hack23.cia.model.internal.application.system.impl.ApplicationSession)1 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)1 RegisterUserResponse (com.hack23.cia.service.api.action.application.RegisterUserResponse)1 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)1 PageItemPropertyClickListener (com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener)1 UpdateApplicationConfigurationClickListener (com.hack23.cia.web.impl.ui.application.views.pageclicklistener.UpdateApplicationConfigurationClickListener)1