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