Search in sources :

Example 16 with NotificationTO

use of org.apache.syncope.common.lib.to.NotificationTO 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 17 with NotificationTO

use of org.apache.syncope.common.lib.to.NotificationTO in project syncope by apache.

the class NotificationServiceImpl method create.

@Override
public Response create(final NotificationTO notificationTO) {
    NotificationTO created = logic.create(notificationTO);
    URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
    return Response.created(location).header(RESTHeaders.RESOURCE_KEY, created.getKey()).build();
}
Also used : NotificationTO(org.apache.syncope.common.lib.to.NotificationTO) URI(java.net.URI)

Aggregations

NotificationTO (org.apache.syncope.common.lib.to.NotificationTO)17 Test (org.junit.jupiter.api.Test)11 Response (javax.ws.rs.core.Response)8 NotificationService (org.apache.syncope.common.rest.api.service.NotificationService)7 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)6 NotificationTaskTO (org.apache.syncope.common.lib.to.NotificationTaskTO)2 Notification (org.apache.syncope.core.persistence.api.entity.Notification)2 URI (java.net.URI)1 ParseException (java.text.ParseException)1 Matcher (java.util.regex.Matcher)1 StringUtils (org.apache.commons.lang3.StringUtils)1 SyncopeConstants (org.apache.syncope.common.lib.SyncopeConstants)1 GroupTO (org.apache.syncope.common.lib.to.GroupTO)1 ImplementationTO (org.apache.syncope.common.lib.to.ImplementationTO)1 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)1 PushTaskTO (org.apache.syncope.common.lib.to.PushTaskTO)1 UserTO (org.apache.syncope.common.lib.to.UserTO)1 AnyTypeKind (org.apache.syncope.common.lib.types.AnyTypeKind)1 ClientExceptionType (org.apache.syncope.common.lib.types.ClientExceptionType)1 TaskQuery (org.apache.syncope.common.rest.api.beans.TaskQuery)1