Search in sources :

Example 81 with IdmNotificationTemplateDto

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

the class NotificationTemplateBackupBulkActionIntegrationTest method processBulkActionByIds.

@Test
public void processBulkActionByIds() throws IOException {
    IdmNotificationTemplateDto template = templateService.getByCode(TEST_TEMPLATE);
    Set<UUID> templates = new HashSet<UUID>();
    templates.add(template.getId());
    template.setSubject(CHANGED_TEST_DESC);
    IdmNotificationTemplateDto templateOne = templateService.save(template);
    assertEquals(templateOne.getSubject(), CHANGED_TEST_DESC);
    IdmBulkActionDto bulkAction = this.findBulkAction(IdmNotificationTemplate.class, NotificationTemplateBackupBulkAction.NAME);
    bulkAction.setIdentifiers(templates);
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 1l, null, null);
    testBackupFileContent(templateOne, loggedUser.getUsername());
    // test attachment is created for LRT
    IdmLongRunningTaskDto task = longRunningTaskManager.getLongRunningTask(processAction.getLongRunningTaskId());
    List<IdmAttachmentDto> attachments = attachmentManager.getAttachments(task, null).getContent();
    Assert.assertEquals(1, attachments.size());
    try (InputStream attachmentData = attachmentManager.getAttachmentData(attachments.get(0).getId())) {
        Assert.assertNotNull(attachmentData);
        // save
        File zipFile = attachmentManager.createTempFile();
        Files.copy(attachmentData, zipFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
        // and extract file
        Path zipFolder = attachmentManager.createTempDirectory(null);
        ZipUtils.extract(zipFile, zipFolder.toString());
        // 
        File[] listFiles = zipFolder.toFile().listFiles();
        Assert.assertEquals(1, listFiles.length);
        Assert.assertEquals(String.format("%s.xml", templateOne.getCode()), listFiles[0].getName());
    }
}
Also used : IdmAttachmentDto(eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto) Path(java.nio.file.Path) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) InputStream(java.io.InputStream) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) UUID(java.util.UUID) File(java.io.File) HashSet(java.util.HashSet) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 82 with IdmNotificationTemplateDto

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

the class NotificationTemplateRedeployBulkActionIntegrationTest method prevalidationBulkActionByIds.

@Test
public void prevalidationBulkActionByIds() {
    IdmNotificationTemplateDto template1 = templateService.getByCode(TEST_TEMPLATE);
    IdmBulkActionDto bulkAction = this.findBulkAction(IdmNotificationTemplate.class, NotificationTemplateRedeployBulkAction.NAME);
    bulkAction.getIdentifiers().add(template1.getId());
    // None info results
    ResultModels resultModels = bulkActionManager.prevalidate(bulkAction);
    List<ResultModel> results = resultModels.getInfos();
    Assert.assertEquals(2, results.size());
    Assert.assertTrue(results.stream().anyMatch(n -> n.getStatusEnum().equals(CoreResultCode.BACKUP_FOLDER_FOUND.toString())));
    Assert.assertTrue(results.stream().anyMatch(n -> n.getStatusEnum().equals(CoreResultCode.DEPLOY_TEMPLATE_FOLDER_FOUND.toString())));
}
Also used : ResultModels(eu.bcvsolutions.idm.core.api.dto.ResultModels) Recoverable(eu.bcvsolutions.idm.core.api.service.Recoverable) Autowired(org.springframework.beans.factory.annotation.Autowired) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) IdmNotificationTemplateFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationTemplateFilter) HashSet(java.util.HashSet) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) After(org.junit.After) Assert.fail(org.junit.Assert.fail) Before(org.junit.Before) IdmNotificationTemplate(eu.bcvsolutions.idm.core.notification.entity.IdmNotificationTemplate) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Set(java.util.Set) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) UUID(java.util.UUID) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) File(java.io.File) List(java.util.List) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) IdmNotificationTemplateService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationTemplateService) Assert(org.junit.Assert) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) Assert.assertEquals(org.junit.Assert.assertEquals) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) ResultModels(eu.bcvsolutions.idm.core.api.dto.ResultModels) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 83 with IdmNotificationTemplateDto

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

the class NotificationTemplateDeleteBulkActionIntegrationTest method processBulkActionByIds.

@Test
public void processBulkActionByIds() {
    templateService.init();
    IdmNotificationTemplateDto template1 = templateService.getByCode(TEST_TEMPLATE);
    IdmNotificationTemplateDto template2 = templateService.getByCode(TEST_TEMPLATE_TWO);
    template1.setUnmodifiable(false);
    template2.setUnmodifiable(false);
    template1 = templateService.save(template1);
    template2 = templateService.save(template2);
    Set<UUID> templates = new HashSet<UUID>();
    templates.add(template1.getId());
    templates.add(template2.getId());
    IdmBulkActionDto bulkAction = this.findBulkAction(IdmNotificationTemplate.class, NotificationTemplateDeleteBulkAction.NAME);
    bulkAction.setIdentifiers(templates);
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 2l, null, null);
    for (UUID id : templates) {
        IdmNotificationTemplateDto templateDto = templateService.get(id);
        assertNull(templateDto);
    }
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) UUID(java.util.UUID) HashSet(java.util.HashSet) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 84 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)

Example 85 with IdmNotificationTemplateDto

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

the class DefaultIdmNotificationTemplateService method toDto.

@Override
protected IdmNotificationTemplateDto toDto(IdmNotificationTemplateType type, IdmNotificationTemplateDto template) {
    if (template == null) {
        template = new IdmNotificationTemplateDto();
    }
    // 
    if (type == null) {
        return template;
    }
    // transform type to DTO
    template.setCode(type.getCode());
    template.setName(type.getName());
    template.setBodyHtml(type.getBodyHtml());
    template.setBodyText(type.getBodyText());
    template.setModule(type.getModuleId());
    template.setSubject(type.getSubject());
    template.setUnmodifiable(type.isSystemTemplate());
    template.setParameter(type.getParameter());
    template.setSender(type.getSender());
    return template;
}
Also used : IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)

Aggregations

IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)87 Test (org.junit.Test)68 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)53 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)42 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)42 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)31 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)23 NotificationConfigurationDto (eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto)19 Transactional (org.springframework.transaction.annotation.Transactional)18 DefaultAttachmentManagerIntegrationTest (eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest)17 NotificationLevel (eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel)14 IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)13 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)12 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)11 UUID (java.util.UUID)9 AbstractBulkActionTest (eu.bcvsolutions.idm.test.api.AbstractBulkActionTest)8 ZonedDateTime (java.time.ZonedDateTime)8 IdmNotificationDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationDto)7 IdmNotificationTemplateService (eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationTemplateService)7 HashSet (java.util.HashSet)7