use of com.icodici.universa.node2.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)))));
}
}
use of com.icodici.universa.node2.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);
}
use of com.icodici.universa.node2.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);
}
use of com.icodici.universa.node2.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);
}
use of com.icodici.universa.node2.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());
}
Aggregations