Search in sources :

Example 11 with Notification

use of org.oasis_open.docs.ws_tx.wsat._2006._06.Notification in project ORCID-Source by ORCID.

the class NotificationManagerTest method filterActionedNotificationAlertsTest.

@Test
public void filterActionedNotificationAlertsTest() {
    TargetProxyHelper.injectIntoProxy(notificationManager, "notificationDao", mockNotificationDao);
    when(mockNotificationDao.findByOricdAndId(Matchers.anyString(), Matchers.anyLong())).thenReturn(null);
    List<Notification> notifications = IntStream.range(0, 10).mapToObj(new IntFunction<Notification>() {

        @Override
        public Notification apply(int value) {
            if (value % 3 == 0) {
                NotificationInstitutionalConnection n = new NotificationInstitutionalConnection();
                n.setSource(new Source("0000-0000-0000-0000"));
                n.setPutCode(Long.valueOf(value));
                return n;
            } else {
                NotificationPermission n = new NotificationPermission();
                n.setPutCode(Long.valueOf(value));
                return n;
            }
        }
    }).collect(Collectors.toList());
    assertEquals(10, notifications.size());
    notifications = notificationManager.filterActionedNotificationAlerts(notifications, "some-orcid");
    assertEquals(6, notifications.size());
    for (Notification n : notifications) {
        assertEquals(NotificationType.PERMISSION, n.getNotificationType());
        assertNotNull(n.getPutCode());
        assertThat(n.getPutCode(), not(anyOf(is(Long.valueOf(0)), is(Long.valueOf(3)), is(Long.valueOf(6)), is(Long.valueOf(9)))));
    }
}
Also used : NotificationInstitutionalConnection(org.orcid.model.notification.institutional_sign_in_v2.NotificationInstitutionalConnection) IntFunction(java.util.function.IntFunction) NotificationPermission(org.orcid.jaxb.model.notification.permission_v2.NotificationPermission) Notification(org.orcid.jaxb.model.notification_v2.Notification) Source(org.orcid.jaxb.model.common_v2.Source) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 12 with Notification

use of org.oasis_open.docs.ws_tx.wsat._2006._06.Notification in project narayana by jbosstm.

the class CompletionCoordinatorClient method sendCommit.

/**
 * Send a commit request.
 * @param map addressing context initialised with to and message ID.
 * @param identifier The identifier of the initiator.
 * @throws com.arjuna.webservices.SoapFault For any errors.
 * @throws java.io.IOException for any transport errors.
 */
public void sendCommit(final W3CEndpointReference endpoint, final MAP map, final InstanceIdentifier identifier) throws SoapFault, IOException {
    MAPEndpoint initiator = getCompletionInitiator(endpoint);
    AddressingHelper.installFromFaultTo(map, initiator, identifier);
    CompletionCoordinatorPortType port = getPort(endpoint, map, commitAction);
    Notification commit = new Notification();
    port.commitOperation(commit);
}
Also used : MAPEndpoint(org.jboss.ws.api.addressing.MAPEndpoint) CompletionCoordinatorPortType(org.oasis_open.docs.ws_tx.wsat._2006._06.CompletionCoordinatorPortType) Notification(org.oasis_open.docs.ws_tx.wsat._2006._06.Notification)

Example 13 with Notification

use of org.oasis_open.docs.ws_tx.wsat._2006._06.Notification in project narayana by jbosstm.

the class CompletionInitiatorClient method sendAborted.

/**
 * Send an aborted request.
 * @param map addressing context initialised with to and message ID.
 * @param identifier The identifier of the initiator.
 * @throws com.arjuna.webservices.SoapFault For any errors.
 * @throws java.io.IOException for any transport errors.
 */
public void sendAborted(final W3CEndpointReference participant, final MAP map, final InstanceIdentifier identifier) throws SoapFault, IOException {
    MAPEndpoint coordinator = getCompletionCoordinator(participant);
    AddressingHelper.installFaultTo(map, coordinator, identifier);
    CompletionInitiatorPortType port = getPort(participant, map, abortedAction);
    Notification aborted = new Notification();
    port.abortedOperation(aborted);
}
Also used : MAPEndpoint(org.jboss.ws.api.addressing.MAPEndpoint) CompletionInitiatorPortType(org.oasis_open.docs.ws_tx.wsat._2006._06.CompletionInitiatorPortType) Notification(org.oasis_open.docs.ws_tx.wsat._2006._06.Notification)

Example 14 with Notification

use of org.oasis_open.docs.ws_tx.wsat._2006._06.Notification in project narayana by jbosstm.

the class CompletionInitiatorClient method sendCommitted.

/**
 * Send a committed request.
 * @param map addressing context initialised with to and message ID.
 * @param identifier The identifier of the initiator.
 * @throws com.arjuna.webservices.SoapFault For any errors.
 * @throws java.io.IOException for any transport errors.
 */
public void sendCommitted(final W3CEndpointReference participant, final MAP map, final InstanceIdentifier identifier) throws SoapFault, IOException {
    MAPEndpoint coordinator = getCompletionCoordinator(participant);
    AddressingHelper.installFaultTo(map, coordinator, identifier);
    CompletionInitiatorPortType port = getPort(participant, map, committedAction);
    Notification commited = new Notification();
    port.committedOperation(commited);
}
Also used : MAPEndpoint(org.jboss.ws.api.addressing.MAPEndpoint) CompletionInitiatorPortType(org.oasis_open.docs.ws_tx.wsat._2006._06.CompletionInitiatorPortType) Notification(org.oasis_open.docs.ws_tx.wsat._2006._06.Notification)

Example 15 with Notification

use of org.oasis_open.docs.ws_tx.wsat._2006._06.Notification in project narayana by jbosstm.

the class CompletionCoordinatorTest method testSendAborted.

@Test
public void testSendAborted() throws Exception {
    final String messageId = "123456";
    final String instanceIdentifier = "testSendAborted";
    final W3CEndpointReference completionInitiatorEndpoint = TestUtil.getCompletionInitiatorEndpoint(instanceIdentifier);
    final MAP map = AddressingHelper.createRequestContext(TestUtil.completionInitiatorServiceURI, messageId);
    final TestCompletionInitiatorCallback callback = new TestCompletionInitiatorCallback() {

        public void aborted(final Notification aborted, final MAP map, final ArjunaContext arjunaContext) {
            assertEquals(map.getTo(), TestUtil.completionInitiatorServiceURI);
            assertNull(map.getFrom());
            assertNotNull(map.getFaultTo());
            assertEquals(map.getFaultTo().getAddress(), TestUtil.completionCoordinatorServiceURI);
            assertNotNull(map.getReplyTo());
            assertTrue(AddressingHelper.isNoneReplyTo(map));
            assertNotNull(map.getMessageID());
            assertEquals(map.getMessageID(), messageId);
            assertNotNull(arjunaContext);
            assertEquals(instanceIdentifier, arjunaContext.getInstanceIdentifier().getInstanceIdentifier());
        }
    };
    final CompletionInitiatorProcessor initiator = CompletionInitiatorProcessor.getProcessor();
    initiator.registerCallback(instanceIdentifier, callback);
    try {
        CompletionInitiatorClient.getClient().sendAborted(completionInitiatorEndpoint, map, new InstanceIdentifier("sender"));
        callback.waitUntilTriggered();
    } finally {
        initiator.removeCallback(instanceIdentifier);
    }
    assertTrue(callback.hasTriggered());
    assertFalse(callback.hasFailed());
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) CompletionInitiatorProcessor(com.arjuna.webservices11.wsat.processors.CompletionInitiatorProcessor) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) ArjunaContext(com.arjuna.webservices11.wsarj.ArjunaContext) MAP(org.jboss.ws.api.addressing.MAP) Notification(org.oasis_open.docs.ws_tx.wsat._2006._06.Notification) Test(org.junit.Test)

Aggregations

Notification (org.oasis_open.docs.ws_tx.wsat._2006._06.Notification)28 Notification (org.orcid.jaxb.model.notification_v2.Notification)18 ArjunaContext (com.arjuna.webservices11.wsarj.ArjunaContext)15 MAP (org.jboss.ws.api.addressing.MAP)15 MessageContext (javax.xml.ws.handler.MessageContext)13 Task (com.arjuna.services.framework.task.Task)11 Action (javax.xml.ws.Action)11 MAPEndpoint (org.jboss.ws.api.addressing.MAPEndpoint)11 HashMap (java.util.HashMap)8 Test (org.junit.Test)8 AccessControl (org.orcid.core.security.visibility.aop.AccessControl)6 NotificationAmended (org.orcid.jaxb.model.notification.amended_v2.NotificationAmended)5 NotificationPermission (org.orcid.jaxb.model.notification.permission_v2.NotificationPermission)5 NotificationInstitutionalConnection (org.orcid.model.notification.institutional_sign_in_v2.NotificationInstitutionalConnection)5 ArrayList (java.util.ArrayList)4 NotificationCustom (org.orcid.jaxb.model.notification.custom_v2.NotificationCustom)4 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)4 DBUnitTest (org.orcid.test.DBUnitTest)4 URISyntaxException (java.net.URISyntaxException)3 HashSet (java.util.HashSet)3