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);
}
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);
}
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);
}
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());
}
}
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());
}
Aggregations