use of org.apache.syncope.common.lib.to.NotificationTaskTO in project syncope by apache.
the class NotificationTaskITCase method notifyByMailEmptyAbout.
@Test
public void notifyByMailEmptyAbout() throws Exception {
String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
String subject = "Test notification " + getUUIDString();
Pair<String, String> created = createNotificationTask(true, false, TraceLevel.ALL, sender, subject);
NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
assertNotNull(taskTO);
assertTrue(taskTO.getExecutions().isEmpty());
execNotificationTask(taskService, taskTO.getKey(), 50);
assertTrue(verifyMail(sender, subject, created.getRight()));
}
use of org.apache.syncope.common.lib.to.NotificationTaskTO in project syncope by apache.
the class PushTaskITCase method issueSYNCOPE648.
@Test
public void issueSYNCOPE648() {
// 1. Create Push Task
PushTaskTO task = new PushTaskTO();
task.setName("Test create Push");
task.setActive(true);
task.setResource(RESOURCE_NAME_LDAP);
task.setSourceRealm(SyncopeConstants.ROOT_REALM);
task.getFilters().put(AnyTypeKind.USER.name(), SyncopeClient.getUserSearchConditionBuilder().is("username").equalTo("_NO_ONE_").query());
task.getFilters().put(AnyTypeKind.GROUP.name(), SyncopeClient.getGroupSearchConditionBuilder().is("name").equalTo("citizen").query());
task.setMatchingRule(MatchingRule.IGNORE);
task.setUnmatchingRule(UnmatchingRule.IGNORE);
Response response = taskService.create(TaskType.PUSH, task);
PushTaskTO actual = getObject(response.getLocation(), TaskService.class, PushTaskTO.class);
assertNotNull(actual);
// 2. Create notification
NotificationTO notification = new NotificationTO();
notification.setTraceLevel(TraceLevel.FAILURES);
notification.getEvents().add("[PushTask]:[group]:[resource-ldap]:[matchingrule_ignore]:[SUCCESS]");
notification.getEvents().add("[PushTask]:[group]:[resource-ldap]:[unmatchingrule_ignore]:[SUCCESS]");
notification.getStaticRecipients().add("issueyncope648@syncope.apache.org");
notification.setSelfAsRecipient(false);
notification.setRecipientAttrName("email");
notification.setSender("syncope648@syncope.apache.org");
String subject = "Test notification";
notification.setSubject(subject);
notification.setTemplate("optin");
notification.setActive(true);
Response responseNotification = notificationService.create(notification);
notification = getObject(responseNotification.getLocation(), NotificationService.class, NotificationTO.class);
assertNotNull(notification);
execProvisioningTask(taskService, TaskType.PUSH, actual.getKey(), 50, false);
NotificationTaskTO taskTO = findNotificationTask(notification.getKey(), 50);
assertNotNull(taskTO);
}
use of org.apache.syncope.common.lib.to.NotificationTaskTO in project syncope by apache.
the class AbstractTaskITCase method findNotificationTask.
protected NotificationTaskTO findNotificationTask(final String notification, final int maxWaitSeconds) {
int i = 0;
int maxit = maxWaitSeconds;
NotificationTaskTO notificationTask = null;
do {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
PagedResult<NotificationTaskTO> tasks = taskService.search(new TaskQuery.Builder(TaskType.NOTIFICATION).notification(notification).build());
if (!tasks.getResult().isEmpty()) {
notificationTask = tasks.getResult().get(0);
}
i++;
} while (notificationTask == null && i < maxit);
if (notificationTask == null) {
fail("Timeout when looking for notification tasks from notification " + notification);
}
return notificationTask;
}
Aggregations