Search in sources :

Example 36 with IdmNotificationLogDto

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

the class DefaultVsRequestServiceIntegrationTest method testNotificationForCreateRequestDiffUid.

@Test
public void testNotificationForCreateRequestDiffUid() {
    String suffix = "_suffix";
    SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
    SysSystemAttributeMappingFilter filterAttribute = new SysSystemAttributeMappingFilter();
    filterAttribute.setSystemId(system.getId());
    SysSystemAttributeMappingDto attributeUid = systemAttributeMappingService.find(filterAttribute, null).getContent().stream().filter(attribute -> attribute.isUid()).findFirst().orElse(null);
    attributeUid.setTransformToResourceScript("return attributeValue+\"" + suffix + "\"");
    attributeUid = systemAttributeMappingService.save(attributeUid);
    String uid = USER_ONE_NAME + suffix;
    this.assignRoleSystem(system, helper.createIdentity(USER_ONE_NAME), ROLE_ONE_NAME);
    // Find created requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setUid(uid);
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    VsRequestDto request = requests.get(0);
    Assert.assertEquals(uid, request.getUid());
    Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
    Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
    VsAccountDto account = accountService.findByUidSystem(uid, system.getId());
    Assert.assertNull("Account must be null, because request was not realized yet!", account);
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setRecipient(USER_IMPLEMENTER_NAME);
    filter.setNotificationType(IdmNotificationLog.class);
    List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
    // 
    assertEquals(1, notifications.size());
    assertEquals(VirtualSystemModuleDescriptor.TOPIC_VS_REQUEST_CREATED, notifications.get(0).getTopic());
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 37 with IdmNotificationLogDto

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

the class DefaultVsRequestServiceIntegrationTest method testNotificationForCreateRequest.

@Test
public void testNotificationForCreateRequest() {
    SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
    this.assignRoleSystem(system, helper.createIdentity(USER_ONE_NAME), ROLE_ONE_NAME);
    // Find created requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setUid(USER_ONE_NAME);
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    VsRequestDto request = requests.get(0);
    Assert.assertEquals(USER_ONE_NAME, request.getUid());
    Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
    Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
    VsAccountDto account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
    Assert.assertNull("Account must be null, because request was not realized yet!", account);
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setRecipient(USER_IMPLEMENTER_NAME);
    filter.setNotificationType(IdmNotificationLog.class);
    List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
    // 
    assertEquals(1, notifications.size());
    assertEquals(VirtualSystemModuleDescriptor.TOPIC_VS_REQUEST_CREATED, notifications.get(0).getTopic());
}
Also used : VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 38 with IdmNotificationLogDto

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

the class DefaultNotificationServiceIntegrationTest method testSendTwoWildCardsWithOwnMessage.

@Test
public void testSendTwoWildCardsWithOwnMessage() {
    String topic = "testTopic-" + System.currentTimeMillis();
    String textTemplate1 = "testMessageTemplate1-" + System.currentTimeMillis();
    String textTemplate2 = "testMessageTemplate2-" + System.currentTimeMillis();
    String textMessage = "testMessageText-" + System.currentTimeMillis();
    // 
    IdmNotificationTemplateDto template1 = new IdmNotificationTemplateDto();
    template1.setName(textTemplate1);
    template1.setCode(textTemplate1);
    template1.setBodyHtml(textTemplate1);
    template1.setBodyText(textTemplate1);
    template1.setSubject(textTemplate1);
    template1 = notificationTemplateService.save(template1);
    // 
    IdmNotificationTemplateDto template2 = new IdmNotificationTemplateDto();
    template2.setName(textTemplate2);
    template2.setCode(textTemplate2);
    template2.setBodyHtml(textTemplate2);
    template2.setBodyText(textTemplate2);
    template2.setSubject(textTemplate2);
    template2 = notificationTemplateService.save(template2);
    // 
    IdmIdentityDto identity = getHelper().createIdentity();
    // create config, for email, topic, template and without level = wildcard
    NotificationConfigurationDto config1 = new NotificationConfigurationDto();
    // topic
    config1.setTopic(topic);
    // template
    config1.setTemplate(template1.getId());
    // email
    config1.setNotificationType(IdmEmailLog.NOTIFICATION_TYPE);
    config1 = notificationConfigurationService.save(config1);
    // 
    // create second config, for console, topic, template and without level = wildcard
    NotificationConfigurationDto config = new NotificationConfigurationDto();
    // same topic
    config.setTopic(topic);
    // different template
    config.setTemplate(template2.getId());
    // console
    config.setNotificationType(IdmConsoleLog.NOTIFICATION_TYPE);
    config = notificationConfigurationService.save(config);
    // 
    List<IdmNotificationLogDto> notifications = notificationManager.send(topic, new IdmMessageDto.Builder().setLevel(// set level
    NotificationLevel.SUCCESS).setHtmlMessage(textMessage).setTextMessage(textMessage).setSubject(textMessage).build(), identity);
    // 
    assertEquals(2, notifications.size());
    // 
    // bouth notifacations has same text
    IdmNotificationLogDto notification1 = notifications.get(0);
    IdmNotificationLogDto notification2 = notifications.get(1);
    // 
    assertEquals(textMessage, notification1.getMessage().getHtmlMessage());
    assertEquals(textMessage, notification1.getMessage().getSubject());
    assertEquals(textMessage, notification1.getMessage().getTextMessage());
    // 
    assertEquals(textMessage, notification2.getMessage().getHtmlMessage());
    assertEquals(textMessage, notification2.getMessage().getSubject());
    assertEquals(textMessage, notification2.getMessage().getTextMessage());
}
Also used : NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 39 with IdmNotificationLogDto

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

the class DefaultNotificationServiceIntegrationTest method testStateFilterTest.

@Test
public void testStateFilterTest() {
    IdmIdentityDto identity1 = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identity2 = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identity3 = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identity4 = getHelper().createIdentity((GuardedString) null);
    List<IdmIdentityDto> identities = Arrays.asList(identity1, identity2, identity3, identity4);
    IdmNotificationTemplateDto template = createTestTemplate();
    IdmMessageDto message = new IdmMessageDto.Builder().setTemplate(template).build();
    notificationManager.send(message, identities);
    // 
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setText(template.getSubject());
    filter.setState(NotificationState.ALL);
    Page<IdmNotificationLogDto> result = notificationLogService.find(filter, null);
    assertEquals(1, result.getTotalElements());
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 40 with IdmNotificationLogDto

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

the class TestSmsNotificationSenderIntegrationTest method testSetParentNotificationState.

@Test
public void testSetParentNotificationState() {
    NotificationConfigurationDto config = new NotificationConfigurationDto();
    config.setTopic(getHelper().createName());
    config.setNotificationType(smsNotificationSender.getType());
    notificationConfigurationService.save(config);
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    // 
    notificationManager.send(config.getTopic(), new IdmMessageDto.Builder().setMessage(getHelper().createName()).build(), identity);
    // check sms log
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setNotificationType(smsNotificationSender.getNotificationType());
    filter.setTopic(config.getTopic());
    List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
    Assert.assertEquals(1, notifications.size());
    Assert.assertNotNull(notifications.get(0).getSent());
    // check parent notification
    filter.setNotificationType(IdmNotificationLog.class);
    notifications = notificationLogService.find(filter, null).getContent();
    Assert.assertEquals(1, notifications.size());
    Assert.assertNotNull(notifications.get(0).getSent());
    Assert.assertEquals(NotificationState.ALL, notifications.get(0).getState());
}
Also used : NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Aggregations

IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)107 Test (org.junit.Test)97 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)93 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)82 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)63 List (java.util.List)40 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)33 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)33 ZonedDateTime (java.time.ZonedDateTime)32 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)28 NotificationConfigurationDto (eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto)28 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)26 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)26 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)26 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)26 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)25 IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)25 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)23 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)20 UUID (java.util.UUID)18