use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class DefaultNotificationServiceIntegrationTest method stateFilterTest.
@Test
@Ignore
public void stateFilterTest() {
IdmIdentityDto identity1 = helper.createIdentity();
IdmIdentityDto identity2 = helper.createIdentity();
IdmIdentityDto identity3 = helper.createIdentity();
IdmIdentityDto identity4 = helper.createIdentity();
List<IdmIdentityDto> identities = Arrays.asList(identity1, identity2, identity3, identity4);
IdmNotificationTemplateDto template = createTestTemplate("TestTemplate6", "testSubject6");
IdmMessageDto message = new IdmMessageDto.Builder().setTemplate(template).build();
notificationManager.send(message, identities);
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setState(NotificationState.ALL);
Page<IdmNotificationLogDto> result = notificationLogService.find(filter, null);
assertEquals("Wrong state ALL", 1, result.getTotalElements());
filter.setState(NotificationState.NOT);
Page<IdmNotificationLogDto> result2 = notificationLogService.find(filter, null);
assertEquals("Wrong state NOT", 1, result2.getTotalElements());
filter.setState(NotificationState.PARTLY);
result = notificationLogService.find(filter, null);
assertEquals("Wrong state PARTLY", 0, result.getTotalElements());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class NotificationSmtpTest method B_sendEmailViaSmtpByWf.
@Test
public void B_sendEmailViaSmtpByWf() throws InterruptedException, BindPortException, OutOfRangePortException {
assertTrue(this.isRunning());
// init observer for this test only
NotificationObserver observer = new NotificationObserver(2);
this.addObserver(observer);
int currentEmails = observer.getEmails().size();
IdmIdentityDto identity = identityService.getByUsername(TO_WF);
if (identity == null) {
identity = helper.createIdentity(TO_WF);
}
identity.setEmail("example@example.tld");
identity = identityService.save(identity);
processInstanceService.startProcess(WF_NAME, null, InitTestData.TEST_USER_1, null, null);
// email is send by apache camel asynchronously
if (observer.getEmails().size() == currentEmails) {
observer.waitForMails();
}
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(identity.getUsername());
filter.setNotificationType(IdmNotificationLog.class);
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
//
assertEquals(2, notifications.size());
assertTrue(this.isRunning());
assertEquals(currentEmails + 2, observer.getEmails().size());
for (EmailModel email : observer.getEmails()) {
assertEquals(FROM, email.getFrom());
assertEquals(identity.getEmail(), email.getTo());
}
// in last test stop smtp server
this.stopSmtpServer();
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class BasicEmailTest method testSendEmailFromWorkflow.
/**
* Send email through {@link EmailNotificationSender}
*/
@Test
public void testSendEmailFromWorkflow() {
// Deploy process - annotation @Deployment can't be used - we need custom behavior to work
InputStream is = this.getClass().getClassLoader().getResourceAsStream("eu/bcvsolutions/idm/workflow/deploy/testEmailer.bpmn20.xml");
WorkflowDeploymentDto deploymentDto = processDeploymentService.create(PROCESS_KEY, "testEmailer.bpmn20.xml", is);
IdmNotificationFilter filter = new IdmNotificationFilter();
assertNotNull(deploymentDto);
filter.setText(EMAIL_TEXT);
filter.setRecipient(EMAIL_RECIPIENT);
assertEquals(0, emailLogService.find(filter, null).getTotalElements());
RuntimeService runtimeService = activitiRule.getRuntimeService();
ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_KEY);
assertEquals(instance.getActivityId(), "endevent");
long count = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_KEY).count();
assertEquals(0, count);
assertEquals(1, emailLogService.find(filter, null).getTotalElements());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class SendNotificationFromTask method sendNotificationGlobalDisabled.
@Test
public void sendNotificationGlobalDisabled() {
configurationService.setValue(WorkflowConfig.SEND_NOTIFICATION_CONFIGURATION_PROPERTY, Boolean.FALSE.toString());
//
IdmIdentityDto identity = createIdentity(WF_TEST_IDENTITY_03);
//
processInstanceService.startProcess(WF_3_DISABLED_PROCESS_KEY, null, InitTestData.TEST_USER_1, null, null);
//
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(identity.getUsername());
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
//
assertEquals(0, notifications.size());
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter in project CzechIdMng by bcvsolutions.
the class SendNotificationFromTask method sendNotificationWithEnabledForm.
@Test
public void sendNotificationWithEnabledForm() {
configurationService.setValue(WorkflowConfig.SEND_NOTIFICATION_CONFIGURATION_PROPERTY, Boolean.TRUE.toString());
//
IdmIdentityDto identity = createIdentity(WF_TEST_IDENTITY_01);
//
processInstanceService.startProcess(WF_1_ENABLED_PROCESS_KEY, null, InitTestData.TEST_USER_1, null, null);
//
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(identity.getUsername());
filter.setNotificationType(IdmNotificationLog.class);
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
//
assertEquals(2, notifications.size());
// two notifications - created + assigned, we didnt know order
if (notifications.get(0).getTopic().equals(CoreModuleDescriptor.TOPIC_WF_TASK_ASSIGNED)) {
assertEquals(CoreModuleDescriptor.TOPIC_WF_TASK_ASSIGNED, notifications.get(0).getTopic());
assertEquals(CoreModuleDescriptor.TOPIC_WF_TASK_CREATED, notifications.get(1).getTopic());
} else {
assertEquals(CoreModuleDescriptor.TOPIC_WF_TASK_CREATED, notifications.get(0).getTopic());
assertEquals(CoreModuleDescriptor.TOPIC_WF_TASK_ASSIGNED, notifications.get(1).getTopic());
}
}
Aggregations