Search in sources :

Example 11 with IdmNotificationTemplateDto

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

the class IdmNotificationConfigurationFilterTest method createTemplate.

/**
 * Creates and returns notification template
 *
 * @return
 */
private IdmNotificationTemplateDto createTemplate(String name, String code, String subject) {
    IdmNotificationTemplateDto templ = new IdmNotificationTemplateDto();
    templ.setName(name);
    templ.setCode(code);
    templ.setSubject(subject);
    return idmNotificationTemplateService.save(templ);
}
Also used : IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)

Example 12 with IdmNotificationTemplateDto

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

the class DefaultIdmNotificationTemplateServiceIntegrationTest method redeployExistTemplate.

@Test
public void redeployExistTemplate() {
    String backupFolder = "/tmp/idm_test_backup/";
    // 
    configurationService.setValue(DefaultIdmNotificationTemplateService.BACKUP_FOLDER_CONFIG, backupFolder);
    // 
    IdmNotificationTemplateDto testTemplate = notificationTemplateService.getByCode(TEST_TEMPLATE);
    Assert.assertNotNull(testTemplate);
    assertEquals(TEST_TEMPLATE, testTemplate.getCode());
    // 
    // redeploy
    IdmNotificationTemplateDto testTemplateNew = notificationTemplateService.redeploy(testTemplate);
    // 
    // after redeploy must be id same
    assertEquals(testTemplateNew.getId(), testTemplate.getId());
    configurationService.setValue(DefaultIdmNotificationTemplateService.BACKUP_FOLDER_CONFIG, null);
}
Also used : IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 13 with IdmNotificationTemplateDto

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

the class DefaultIdmNotificationTemplateServiceIntegrationTest method redeployWithBackupFolder.

@Test
public void redeployWithBackupFolder() {
    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());
    // 
    try {
        IdmNotificationTemplateDto newDto = notificationTemplateService.redeploy(testTemplate);
        assertEquals(testTemplate.getCode(), newDto.getCode());
        // 
        DateTime date = new DateTime();
        DecimalFormat decimalFormat = new DecimalFormat("00");
        directory = new File(backupFolder + "templates/" + date.getYear() + decimalFormat.format(date.getMonthOfYear()) + decimalFormat.format(date.getDayOfMonth()) + "/");
        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(testTemplate.getCode()));
    } catch (Exception e) {
        fail();
    }
    configurationService.setValue(DefaultIdmNotificationTemplateService.BACKUP_FOLDER_CONFIG, null);
}
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) IOException(java.io.IOException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 14 with IdmNotificationTemplateDto

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

the class DefaultIdmNotificationTemplateServiceIntegrationTest method redeployWithoutBackupFolder.

@Test
public void redeployWithoutBackupFolder() {
    String backupPath = configurationService.getValue(DefaultIdmNotificationTemplateService.BACKUP_FOLDER_CONFIG);
    if (backupPath != null) {
        configurationService.setValue(DefaultIdmNotificationTemplateService.BACKUP_FOLDER_CONFIG, null);
    }
    // 
    IdmNotificationTemplateDto testTemplate = notificationTemplateService.getByCode(TEST_TEMPLATE);
    Assert.assertNotNull(testTemplate);
    assertEquals(TEST_TEMPLATE, testTemplate.getCode());
    // 
    try {
        notificationTemplateService.redeploy(testTemplate);
        fail();
    } catch (Exception e) {
        assertTrue(e instanceof ResultCodeException);
        ResultCodeException resultCode = (ResultCodeException) e;
        assertEquals(resultCode.getError().getError().getStatusEnum(), CoreResultCode.BACKUP_FOLDER_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 15 with IdmNotificationTemplateDto

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

the class DefaultIdmNotificationTemplateServiceIntegrationTest method initTest.

@Test
public void initTest() {
    IdmNotificationTemplateDto template = notificationTemplateService.getByCode(TEST_TEMPLATE);
    assertNotNull(template);
    assertEquals(TEST_TEMPLATE, template.getCode());
}
Also used : IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

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