Search in sources :

Example 1 with IdmNotificationRecipientFilter

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

the class IdmNotificationRecipientControllerTest method testFindByIdentityRecipient.

@Test
public void testFindByIdentityRecipient() {
    IdmNotificationRecipientDto recipentOne = createDto();
    // other
    createDto();
    // 
    IdmNotificationRecipientFilter filter = new IdmNotificationRecipientFilter();
    filter.setIdentityRecipient(recipentOne.getIdentityRecipient());
    List<IdmNotificationRecipientDto> attachments = find(filter);
    Assert.assertEquals(1, attachments.size());
    Assert.assertTrue(attachments.stream().anyMatch(r -> r.getId().equals(recipentOne.getId())));
}
Also used : IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) IdmNotificationRecipientFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationRecipientFilter) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) IdmNotificationLogService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService) List(java.util.List) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) IdmNotificationRecipientFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationRecipientFilter) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 2 with IdmNotificationRecipientFilter

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

the class IdmNotificationRecipientControllerTest method testFindByNotification.

@Test
public void testFindByNotification() {
    IdmNotificationRecipientDto recipentOne = createDto();
    // other
    createDto();
    // 
    IdmNotificationRecipientFilter filter = new IdmNotificationRecipientFilter();
    filter.setNotification(recipentOne.getNotification());
    List<IdmNotificationRecipientDto> attachments = find(filter);
    Assert.assertEquals(1, attachments.size());
    Assert.assertTrue(attachments.stream().anyMatch(r -> r.getId().equals(recipentOne.getId())));
}
Also used : IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) IdmNotificationRecipientFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationRecipientFilter) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) IdmNotificationLogService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService) List(java.util.List) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) IdmNotificationRecipientFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationRecipientFilter) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 3 with IdmNotificationRecipientFilter

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

the class IdmNotificationRecipientControllerTest method testFindByRealRecipient.

@Test
public void testFindByRealRecipient() {
    IdmNotificationRecipientDto recipentOne = createDto();
    // other
    createDto();
    // 
    IdmNotificationRecipientFilter filter = new IdmNotificationRecipientFilter();
    filter.setRealRecipient(recipentOne.getRealRecipient());
    List<IdmNotificationRecipientDto> attachments = find(filter);
    Assert.assertEquals(1, attachments.size());
    Assert.assertTrue(attachments.stream().anyMatch(r -> r.getId().equals(recipentOne.getId())));
}
Also used : IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) IdmNotificationRecipientFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationRecipientFilter) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) IdmNotificationLogService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService) List(java.util.List) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) IdmNotificationRecipientFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationRecipientFilter) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 4 with IdmNotificationRecipientFilter

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

the class IdmNotificationRecipientController method toFilter.

@Override
protected IdmNotificationRecipientFilter toFilter(MultiValueMap<String, Object> parameters) {
    IdmNotificationRecipientFilter filter = new IdmNotificationRecipientFilter(parameters, getParameterConverter());
    filter.setIdentityRecipient(getParameterConverter().toEntityUuid(parameters, IdmNotificationRecipientFilter.PARAMETER_IDENTITY_RECIPIENT, IdmIdentityDto.class));
    // 
    return filter;
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmNotificationRecipientFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationRecipientFilter)

Example 5 with IdmNotificationRecipientFilter

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

the class DefaultRptReportManagerIntegrationTest method testSendConfiguredRedirectNotificationAfterEnd.

@Test
public void testSendConfiguredRedirectNotificationAfterEnd() throws Exception {
    IdmIdentityDto identity = getHelper().createIdentity();
    String recipient = getHelper().createName() + "@test-bcvsolutions.eu";
    NotificationConfigurationDto config = createConfig(recipient, true);
    // 
    try {
        // report is sent to logged identity by default
        getHelper().login(identity);
        // 
        RptReportDto report = new RptReportDto();
        report.setExecutorName(TestReportExecutor.REPORT_NAME);
        IdmFormDto filter = new IdmFormDto();
        TestReportExecutor testReportExecutor = context.getAutowireCapableBeanFactory().createBean(TestReportExecutor.class);
        IdmFormDefinitionDto definition = testReportExecutor.getFormDefinition();
        IdmFormValueDto topic = new IdmFormValueDto(definition.getMappedAttributeByCode(AbstractReportExecutor.PROPERTY_TOPIC_REPORT_GENERATE_SUCCESS));
        topic.setValue(config.getTopic());
        filter.getValues().add(topic);
        filter.setFormDefinition(definition.getId());
        report.setFilter(filter);
        report = manager.generate(report);
        UUID reportId = report.getId();
        Assert.assertNotNull(reportId);
        Assert.assertNotNull(report.getData());
        // 
        try (InputStream is = attachmentManager.getAttachmentData(report.getData())) {
            Assert.assertEquals(mapper.writeValueAsString(TestReportExecutor.identities), IOUtils.toString(is));
        }
        reportService.delete(report);
        attachmentManager.deleteAttachments(report);
        // 
        // test notification is sent
        IdmNotificationFilter notificationFilter = new IdmNotificationFilter();
        notificationFilter.setTopic(config.getTopic());
        notificationFilter.setRecipient(identity.getUsername());
        notificationFilter.setNotificationType(IdmNotificationLog.class);
        List<IdmNotificationLogDto> notifications = notificationService.find(notificationFilter, null).getContent();
        Assert.assertTrue(notifications.isEmpty());
        // 
        IdmNotificationRecipientFilter recipientFilter = new IdmNotificationRecipientFilter();
        recipientFilter.setRealRecipient(recipient);
        List<IdmNotificationRecipientDto> recipients = notificationRecipientService.find(recipientFilter, null).getContent();
        Assert.assertFalse(recipients.isEmpty());
        Assert.assertEquals(config.getTopic(), notificationService.get(recipients.get(0).getNotification()).getTopic());
    } finally {
        logout();
    }
}
Also used : NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto) InputStream(java.io.InputStream) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) IdmNotificationRecipientFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationRecipientFilter) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmNotificationRecipientFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationRecipientFilter)9 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)8 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)7 IdmNotificationRecipientDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto)7 Test (org.junit.Test)7 NotificationLevel (eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel)5 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)5 IdmNotificationLogService (eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService)5 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5 List (java.util.List)5 Assert (org.junit.Assert)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 AbstractReadWriteDtoController (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController)4 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)4 NotificationConfigurationDto (eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto)3 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)3 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)3 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)2 IdmFormDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto)2 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)2