Search in sources :

Example 11 with NotificationTaskTO

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()));
}
Also used : NotificationTaskTO(org.apache.syncope.common.lib.to.NotificationTaskTO) Test(org.junit.jupiter.api.Test)

Example 12 with NotificationTaskTO

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);
}
Also used : Response(javax.ws.rs.core.Response) NotificationTO(org.apache.syncope.common.lib.to.NotificationTO) PushTaskTO(org.apache.syncope.common.lib.to.PushTaskTO) NotificationService(org.apache.syncope.common.rest.api.service.NotificationService) NotificationTaskTO(org.apache.syncope.common.lib.to.NotificationTaskTO) Test(org.junit.jupiter.api.Test)

Example 13 with NotificationTaskTO

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;
}
Also used : TaskQuery(org.apache.syncope.common.rest.api.beans.TaskQuery) NotificationTaskTO(org.apache.syncope.common.lib.to.NotificationTaskTO)

Aggregations

NotificationTaskTO (org.apache.syncope.common.lib.to.NotificationTaskTO)13 Test (org.junit.jupiter.api.Test)9 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)3 PushTaskTO (org.apache.syncope.common.lib.to.PushTaskTO)3 Response (javax.ws.rs.core.Response)2 ExecTO (org.apache.syncope.common.lib.to.ExecTO)2 NotificationTO (org.apache.syncope.common.lib.to.NotificationTO)2 PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)2 PullTaskTO (org.apache.syncope.common.lib.to.PullTaskTO)2 SchedTaskTO (org.apache.syncope.common.lib.to.SchedTaskTO)2 TaskTO (org.apache.syncope.common.lib.to.TaskTO)2 TaskType (org.apache.syncope.common.lib.types.TaskType)2 TaskQuery (org.apache.syncope.common.rest.api.beans.TaskQuery)2 NotificationService (org.apache.syncope.common.rest.api.service.NotificationService)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1