Search in sources :

Example 26 with IdmNotificationTemplateDto

use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.

the class IdmMessageDtoUnitTest method testTemplate.

@Test
public void testTemplate() {
    IdmNotificationTemplateDto template = new IdmNotificationTemplateDto();
    template.setSubject(PARAMETER_SUBJECT);
    template.setBodyText(PARAMETER_TEXT);
    IdmMessageDto message = new IdmMessageDto.Builder().setTemplate(template).build();
    // 
    Assert.assertEquals(PARAMETER_SUBJECT, message.getSubject());
    Assert.assertEquals(PARAMETER_TEXT, message.getTextMessage());
    Assert.assertEquals(PARAMETER_TEXT, message.getHtmlMessage());
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest) Test(org.junit.Test)

Example 27 with IdmNotificationTemplateDto

use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmNotificationTemplateServiceIntegrationTest method redeployNewTemplate.

@Test
public void redeployNewTemplate() {
    IdmNotificationTemplateDto template = new IdmNotificationTemplateDto();
    String name = "temp_" + System.currentTimeMillis();
    template.setCode(name);
    template.setName(name);
    template.setBodyText(name);
    template.setSubject(name);
    template = notificationTemplateService.save(template);
    // check exception
    try {
        notificationTemplateService.redeploy(template);
        fail();
    } catch (Exception e) {
        assertTrue(e instanceof ResultCodeException);
        ResultCodeException resultCode = (ResultCodeException) e;
        assertEquals(resultCode.getError().getError().getStatusEnum(), CoreResultCode.NOTIFICATION_TEMPLATE_XML_FILE_NOT_FOUND.name());
    }
}
Also used : ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) IOException(java.io.IOException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 28 with IdmNotificationTemplateDto

use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmNotificationTemplateServiceIntegrationTest method initFromMultipleLocations.

@Test
public void initFromMultipleLocations() {
    IdmNotificationTemplateDto templateTwo = notificationTemplateService.getByCode(TEST_TEMPLATE_TWO);
    IdmNotificationTemplateDto templateOverride = notificationTemplateService.getByCode(TEST_TEMPLATE_OVERRIDE);
    assertNotNull(templateTwo);
    assertNotNull(templateOverride);
    assertEquals(TEST_TEMPLATE_TWO, templateTwo.getCode());
    assertEquals(TEST_TEMPLATE_OVERRIDE, templateOverride.getCode());
    // 
    assertEquals("CzechIdM - test isOverriden", templateOverride.getSubject());
    assertEquals("isOverriden", templateOverride.getBodyHtml().trim());
}
Also used : IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 29 with IdmNotificationTemplateDto

use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmNotificationTemplateServiceIntegrationTest method redeployExistTemplateAndCheckBackup.

@Test
public void redeployExistTemplateAndCheckBackup() {
    // check if exist directory and remove it with all files in
    String backupFolder = "/tmp/idm_test_backup/";
    // 
    File directory = new File(backupFolder);
    if (directory.exists() && directory.isDirectory()) {
        try {
            FileUtils.deleteDirectory(directory);
        } catch (IOException e) {
            fail();
        }
    }
    // 
    configurationService.setValue(DefaultIdmNotificationTemplateService.BACKUP_FOLDER_CONFIG, backupFolder);
    // 
    IdmNotificationTemplateDto testTemplate = notificationTemplateService.getByCode(TEST_TEMPLATE);
    Assert.assertNotNull(testTemplate);
    assertEquals(TEST_TEMPLATE, testTemplate.getCode());
    // 
    IdmNotificationTemplateDto testTemplateNew = notificationTemplateService.redeploy(testTemplate);
    // 
    assertEquals(testTemplateNew.getId(), testTemplate.getId());
    // 
    // after redeploy check directory
    DateTime date = new DateTime();
    DecimalFormat decimalFormat = new DecimalFormat("00");
    directory = new File(backupFolder + "templates/" + date.getYear() + decimalFormat.format(date.getMonthOfYear()) + decimalFormat.format(date.getDayOfMonth()) + "/");
    assertTrue(directory.exists());
    assertTrue(directory.isDirectory());
    // 
    File[] files = directory.listFiles();
    assertEquals(1, files.length);
    File backup = files[0];
    assertTrue(backup.exists());
    assertTrue(backup.getName().contains(InitTestData.TEST_USER_1));
    assertTrue(backup.getName().contains(testTemplateNew.getCode()));
}
Also used : DecimalFormat(java.text.DecimalFormat) IOException(java.io.IOException) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) File(java.io.File) DateTime(org.joda.time.DateTime) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 30 with IdmNotificationTemplateDto

use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningBreakConfigService method getGlobalBreakConfiguration.

@Override
public SysProvisioningBreakConfigDto getGlobalBreakConfiguration(ProvisioningEventType eventType) {
    SysProvisioningBreakConfigDto globalConfig = new SysProvisioningBreakConfigDto();
    Boolean disable = provisioningBreakConfiguration.getDisabled(eventType);
    if (disable == null) {
        // global provisioning break configuration isn't set
        return null;
    }
    globalConfig.setDisabled(disable);
    globalConfig.setDisableLimit(provisioningBreakConfiguration.getDisableLimit(eventType));
    globalConfig.setGlobalConfiguration(Boolean.TRUE);
    // 
    IdmNotificationTemplateDto disabledTemplate = provisioningBreakConfiguration.getDisableTemplate(eventType);
    if (disabledTemplate != null) {
        globalConfig.setDisableTemplate(disabledTemplate.getId());
        globalConfig.setDisableTemplateEmbedded(disabledTemplate);
    }
    // 
    IdmNotificationTemplateDto warningTemplate = provisioningBreakConfiguration.getWarningTemplate(eventType);
    if (warningTemplate != null) {
        globalConfig.setWarningTemplate(warningTemplate.getId());
        globalConfig.setWarningTemplateEmbedded(warningTemplate);
    }
    // 
    globalConfig.setOperationType(eventType);
    globalConfig.setPeriod(provisioningBreakConfiguration.getPeriod(eventType));
    // global provisioning break hasn't system id, don't save global config
    globalConfig.setSystem(null);
    globalConfig.setWarningLimit(provisioningBreakConfiguration.getWarningLimit(eventType));
    globalConfig.setTrimmed(true);
    return globalConfig;
}
Also used : SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)

Aggregations

IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)32 Test (org.junit.Test)22 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)20 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)13 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)11 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)8 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)7 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)5 NotificationConfigurationDto (eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto)5 Transactional (org.springframework.transaction.annotation.Transactional)5 IOException (java.io.IOException)4 DateTime (org.joda.time.DateTime)3 SysProvisioningBreakConfigDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto)2 IdmNotificationDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationDto)2 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)2 ApiOperation (io.swagger.annotations.ApiOperation)2 File (java.io.File)2 DecimalFormat (java.text.DecimalFormat)2 ResponseEntity (org.springframework.http.ResponseEntity)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2