@Override public String requestBody(String resolvedExtensionVersion) { return messageHandlerMap.get(resolvedExtensionVersion).requestMessageForNotify(data); }
@Override public List<String> onSuccess(String responseBody, Map<String, String> responseHeaders, String resolvedExtensionVersion) { return messageHandlerMap.get(resolvedExtensionVersion).responseMessageForNotificationsInterestedIn(responseBody); } });
@Override public Result onSuccess(String responseBody, Map<String, String> responseHeaders, String resolvedExtensionVersion) { return messageHandlerMap.get(resolvedExtensionVersion).responseMessageForNotify(responseBody); } });
@Test public void shouldTalkToPluginToNotify() throws Exception { Result response = new Result(); String notificationName = "notification-name"; String jsonResponse = "json-response"; StageNotificationData stageNotificationData = new StageNotificationData(new Stage(), BuildCause.createWithEmptyModifications(), "group"); when(jsonMessageHandler().requestMessageForNotify(stageNotificationData)).thenReturn(jsonResponse); when(jsonMessageHandler().responseMessageForNotify(RESPONSE_BODY)).thenReturn(response); Result deserializedResponse = notificationExtension.notify(PLUGIN_ID, notificationName, stageNotificationData); assertRequest(requestArgumentCaptor.getValue(), NOTIFICATION_EXTENSION, apiVersion(), notificationName, jsonResponse); verify(jsonMessageHandler()).responseMessageForNotify(RESPONSE_BODY); assertSame(response, deserializedResponse); }
@Test public void shouldTalkToPluginToGetNotificationsInterestedIn() throws Exception { List<String> response = asList("pipeline-status", "stage-status"); when(jsonMessageHandler().responseMessageForNotificationsInterestedIn(RESPONSE_BODY)).thenReturn(response); List<String> deserializedResponse = notificationExtension.getNotificationsOfInterestFor(PLUGIN_ID); assertRequest(requestArgumentCaptor.getValue(), NOTIFICATION_EXTENSION, apiVersion(), NotificationExtension.REQUEST_NOTIFICATIONS_INTERESTED_IN, null); verify(jsonMessageHandler()).responseMessageForNotificationsInterestedIn(RESPONSE_BODY); assertSame(response, deserializedResponse); }