use of org.apache.syncope.fit.core.reference.TestNotificationRecipientsProvider in project syncope by apache.
the class NotificationTaskITCase method issueSYNCOPE446.
@Test
public void issueSYNCOPE446() throws Exception {
// 1. Create notification
ImplementationTO recipientsProvider = new ImplementationTO();
recipientsProvider.setKey(TestNotificationRecipientsProvider.class.getSimpleName());
recipientsProvider.setEngine(ImplementationEngine.JAVA);
recipientsProvider.setType(ImplementationType.RECIPIENTS_PROVIDER);
recipientsProvider.setBody(TestNotificationRecipientsProvider.class.getName());
Response response = implementationService.create(recipientsProvider);
recipientsProvider = implementationService.read(recipientsProvider.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
assertNotNull(recipientsProvider);
NotificationTO notification = new NotificationTO();
notification.setTraceLevel(TraceLevel.ALL);
notification.getEvents().add("[LOGIC]:[GroupLogic]:[]:[create]:[SUCCESS]");
String groupName = "group" + getUUIDString();
notification.getAbouts().put(AnyTypeKind.GROUP.name(), SyncopeClient.getGroupSearchConditionBuilder().is("name").equalTo(groupName).query());
notification.setRecipientsFIQL(SyncopeClient.getUserSearchConditionBuilder().inGroups("f779c0d4-633b-4be5-8f57-32eb478a3ca5").query());
notification.setSelfAsRecipient(false);
notification.setRecipientAttrName("email");
notification.getStaticRecipients().add("notificationtest@syncope.apache.org");
notification.setRecipientsProvider(recipientsProvider.getKey());
String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
notification.setSender(sender);
String subject = "Test notification " + getUUIDString();
notification.setSubject(subject);
notification.setTemplate("optin");
notification.setActive(true);
response = notificationService.create(notification);
notification = getObject(response.getLocation(), NotificationService.class, NotificationTO.class);
assertNotNull(notification);
assertEquals(recipientsProvider.getKey(), notification.getRecipientsProvider());
// 2. create group
GroupTO groupTO = new GroupTO();
groupTO.setName(groupName);
groupTO.setRealm("/even/two");
groupTO = createGroup(groupTO).getEntity();
assertNotNull(groupTO);
// 3. verify
NotificationTaskTO taskTO = findNotificationTask(notification.getKey(), 50);
assertNotNull(taskTO);
assertNotNull(taskTO.getNotification());
assertTrue(taskTO.getRecipients().containsAll(new TestNotificationRecipientsProvider().provideRecipients(null)));
NotificationTaskTO foundViaList = taskService.<NotificationTaskTO>search(new TaskQuery.Builder(TaskType.NOTIFICATION).notification(notification.getKey()).build()).getResult().get(0);
assertEquals(taskTO, foundViaList);
execNotificationTask(taskService, taskTO.getKey(), 50);
assertTrue(verifyMail(sender, subject, "notificationtest@syncope.apache.org"));
}
Aggregations