@Test public void testForbiddenPostMessageSuccessfully() throws IntegrationConfigException, IOException, RemoteApiException { IntegrationInstance instance = mockInstance(); mockIntegrationService(); when(authenticationProxy.getSessionToken(INTEGRATION_USER)).thenReturn(TOKEN); Stream resultIM = new Stream(); resultIM.setId(IM); doReturn(resultIM).when(streamService).createIM(INTEGRATION_USER, new Long(USER_ID)); User userInfo = new User(); userInfo.setDisplayName(DISPLAY_NAME); when(usersApi.getUserByUsername(TOKEN, INTEGRATION_USER)).thenReturn(userInfo); exceptionHandler.handleRemoteApiException(new RemoteApiException(403, JSON_403_RESPONSE), instance, INTEGRATION_USER, STREAM); List<String> streams = WebHookConfigurationUtils.getStreams(savedInstance.getOptionalProperties()); assertTrue(streams.isEmpty()); assertEquals( "<messageML>JIRA has been removed from Test Room, I can no longer post messages in Test " + "Room unless I am reconfigured to do so.</messageML>", messagePosted); }
public void handleRemoteApiException(RemoteApiException remoteException, IntegrationInstance instance, String integrationUser, String stream) { int code = remoteException.getCode(); Status status = Status.fromStatusCode(code); String message = logMessage.getMessage(UNABLE_POST_STREAM, stream, String.valueOf(code)); LOGGER.error(message, remoteException); if (isForbiddenError(status, remoteException.getResponseMessage())) { updateStreams(instance, integrationUser, stream); } else if (Status.BAD_REQUEST.equals(status)) { LOGGER.warn(logMessage.getMessage(INVALID_MESSAGE, stream, instance.getInstanceId()), remoteException); } }
IntegrationBridgeExceptionHandler extends ExceptionHandler { public void handleRemoteApiException(RemoteApiException remoteException, IntegrationInstance instance, String integrationUser, String stream) { int code = remoteException.getCode(); Status status = Status.fromStatusCode(code); String message = logMessage.getMessage(UNABLE_POST_STREAM, stream, String.valueOf(code)); LOGGER.error(message, remoteException); if (isForbiddenError(status, remoteException.getResponseMessage())) { updateStreams(instance, integrationUser, stream); } else if (Status.BAD_REQUEST.equals(status)) { LOGGER.warn(logMessage.getMessage(INVALID_MESSAGE, stream, instance.getInstanceId()), remoteException); } } }
IntegrationBridgeExceptionHandler extends ExceptionHandler { public void handleRemoteApiException(RemoteApiException remoteException, IntegrationInstance instance, String integrationUser, String stream) { int code = remoteException.getCode(); Status status = Status.fromStatusCode(code); String message = logMessage.getMessage(UNABLE_POST_STREAM, stream, String.valueOf(code)); LOGGER.error(message, remoteException); if (isForbiddenError(status, remoteException.getResponseMessage())) { updateStreams(instance, integrationUser, stream); } else if (Status.BAD_REQUEST.equals(status)) { LOGGER.warn(logMessage.getMessage(INVALID_MESSAGE, stream, instance.getInstanceId()), remoteException); } }  }
IntegrationBridgeExceptionHandler extends ExceptionHandler { public void handleRemoteApiException(RemoteApiException remoteException, IntegrationInstance instance, String integrationUser, String stream) { int code = remoteException.getCode(); Status status = Status.fromStatusCode(code); String message = logMessage.getMessage(UNABLE_POST_STREAM, stream, String.valueOf(code)); LOGGER.error(message, remoteException); if (isForbiddenError(status, remoteException.getResponseMessage())) { updateStreams(instance, integrationUser, stream); } else if (Status.BAD_REQUEST.equals(status)) { LOGGER.warn(logMessage.getMessage(INVALID_MESSAGE, stream, instance.getInstanceId()), remoteException); } }  @PostConstruct void init(); void handleRemoteApiException(RemoteApiException remoteException,
      IntegrationInstance instance, String integrationUser, String stream); void handleUnexpectedException(Exception e); }
IntegrationBridgeExceptionHandler extends ExceptionHandler { public void handleRemoteApiException(RemoteApiException remoteException, IntegrationInstance instance, String integrationUser, String stream) { int code = remoteException.getCode(); Status status = Status.fromStatusCode(code); String message = logMessage.getMessage(UNABLE_POST_STREAM, stream, String.valueOf(code)); LOGGER.error(message, remoteException); if (isForbiddenError(status, remoteException.getResponseMessage())) { updateStreams(instance, integrationUser, stream); } else if (Status.BAD_REQUEST.equals(status)) { LOGGER.warn(logMessage.getMessage(INVALID_MESSAGE, stream, instance.getInstanceId()), remoteException); } }  @PostConstruct void init(); void handleRemoteApiException(RemoteApiException remoteException,
      IntegrationInstance instance, String integrationUser, String stream); void handleUnexpectedException(Exception e);  }