use of org.apache.syncope.common.lib.to.NotificationTaskTO in project syncope by apache.
the class NotificationTaskITCase method issueSYNCOPE86.
@Test
public void issueSYNCOPE86() {
// 1. create notification task
String sender = "syncope86@syncope.apache.org";
Pair<String, String> created = createNotificationTask(true, true, TraceLevel.ALL, sender, "Test notification");
// 2. get NotificationTaskTO for user just created
NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
assertNotNull(taskTO);
assertNotNull(taskTO.getNotification());
assertTrue(taskTO.getExecutions().isEmpty());
try {
// 3. execute the generated NotificationTask
execNotificationTask(taskService, taskTO.getKey(), 50);
// 4. verify
taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getKey(), true);
assertNotNull(taskTO);
assertTrue(taskTO.isExecuted());
assertEquals(1, taskTO.getExecutions().size());
} finally {
// Remove execution to make test re-runnable
if (!taskTO.getExecutions().isEmpty()) {
taskService.deleteExecution(taskTO.getExecutions().get(0).getKey());
}
}
}
use of org.apache.syncope.common.lib.to.NotificationTaskTO in project syncope by apache.
the class NotificationTaskITCase method issueSYNCOPE81.
@Test
public void issueSYNCOPE81() {
String sender = "syncope81@syncope.apache.org";
Pair<String, String> created = createNotificationTask(true, true, TraceLevel.ALL, sender, "Test notification");
NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
assertNotNull(taskTO);
assertNotNull(taskTO.getNotification());
assertTrue(taskTO.getExecutions().isEmpty());
// generate an execution in order to verify the deletion of a notification task with one or more executions
execNotificationTask(taskService, taskTO.getKey(), 50);
taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getKey(), true);
assertTrue(taskTO.isExecuted());
assertFalse(taskTO.getExecutions().isEmpty());
taskService.delete(TaskType.NOTIFICATION, taskTO.getKey());
}
use of org.apache.syncope.common.lib.to.NotificationTaskTO 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"));
}
use of org.apache.syncope.common.lib.to.NotificationTaskTO in project syncope by apache.
the class NotificationTaskITCase method notifyByMail.
@Test
public void notifyByMail() throws Exception {
String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
String subject = "Test notification " + getUUIDString();
Pair<String, String> created = createNotificationTask(true, true, TraceLevel.ALL, sender, subject);
NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
assertNotNull(taskTO);
assertNotNull(taskTO.getNotification());
assertTrue(taskTO.getExecutions().isEmpty());
execNotificationTask(taskService, taskTO.getKey(), 50);
assertTrue(verifyMail(sender, subject, created.getRight()));
// verify message body
taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getKey(), true);
assertNotNull(taskTO);
assertTrue(taskTO.isExecuted());
assertNotNull(taskTO.getTextBody());
assertTrue(taskTO.getTextBody().contains("Your email address is " + created.getRight() + "."));
assertTrue(taskTO.getTextBody().contains("Your email address inside a link: " + "http://localhost/?email=" + created.getRight().replaceAll("@", "%40")));
}
use of org.apache.syncope.common.lib.to.NotificationTaskTO in project syncope by apache.
the class NotificationTaskITCase method issueSYNCOPE445.
@Test
public void issueSYNCOPE445() throws Exception {
String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
String subject = "Test notification " + getUUIDString();
Pair<String, String> created = createNotificationTask(true, true, TraceLevel.ALL, sender, subject, "syncope445@syncope.apache.org");
NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
assertNotNull(taskTO);
assertNotNull(taskTO.getNotification());
assertTrue(taskTO.getExecutions().isEmpty());
execNotificationTask(taskService, taskTO.getKey(), 50);
assertTrue(verifyMail(sender, subject, created.getRight()));
// verify task
taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getKey(), true);
assertTrue(taskTO.isExecuted());
assertNotNull(taskTO);
assertTrue(taskTO.getRecipients().contains("syncope445@syncope.apache.org"));
}
Aggregations