@Test (enabled = false) public void testHandleResponseInterceptor_Authorization() { boolean isValid = false; IntuitResponse intuitResponse = (IntuitResponse) intuitMessage.getResponseElements().getResponse(); intuitResponse.getFault().setType("Authorization"); HandleResponseInterceptor interceptor = new HandleResponseInterceptor(); try { interceptor.execute(intuitMessage); } catch (FMSException e) { if (e instanceof AuthorizationException) { isValid = true; } } Assert.assertTrue(isValid); }
@Override public void execute(IntuitMessage intuitMessage) throws FMSException { LOG.debug("Enter HandleResponseInterceptor..."); IntuitResponse intuitResponse = null; ResponseElements responseElements = intuitMessage.getResponseElements(); if(responseElements.getResponse() instanceof TaxService) { LOG.debug("Tax Service Response" ); } else if(responseElements.getResponse() instanceof EntitlementsResponse) { LOG.debug("Entitlements Response" ); } else{ intuitResponse = (IntuitResponse) responseElements.getResponse(); } if (intuitResponse != null && intuitResponse.getFault() != null) { Fault fault = intuitResponse.getFault(); if (fault.getType().equalsIgnoreCase("Validation")) { throw new ValidationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Service")) { throw new ServiceException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("AuthenticationFault")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Authentication")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("ApplicationAuthenticationFailed")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Authorization")) { throw new AuthorizationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("AuthorizationFault")) { throw new AuthorizationException(fault.getError()); } else { throw new FMSException(fault.getError()); } } else if (intuitResponse == null) { StatusLine statusLine = responseElements.getStatusLine(); String responseMessage = statusLine.getReasonPhrase(); int status = responseElements.getStatusCode(); if (responseMessage == null) { responseMessage = Integer.toString(status); } if (status == HTTP_ERROR_400) { throw new BadRequestException(responseMessage); } else if (status == HTTP_ERROR_401) { throw new InvalidTokenException(responseMessage); } else if (status == HTTP_ERROR_403) { throw new InvalidRequestException(responseMessage); } else if (status == HTTP_ERROR_404) { throw new InvalidRequestException(responseMessage); } else if (status == HTTP_ERROR_500) { throw new InternalServiceException(responseMessage); } else if (status == HTTP_ERROR_503) { throw new ServiceUnavailableException(responseMessage); } else if (status == HTTP_ERROR_429) { throw new ServiceException(responseMessage); } } LOG.debug("Exit HandleResponseInterceptor."); }
HandleResponseInterceptor implements Interceptor { @Override public void execute(IntuitMessage intuitMessage) throws FMSException { LOG.debug("Enter HandleResponseInterceptor..."); IntuitResponse intuitResponse = null; ResponseElements responseElements = intuitMessage.getResponseElements(); if(responseElements.getResponse() instanceof TaxService) { LOG.debug("Tax Service Response" ); } else if(responseElements.getResponse() instanceof EntitlementsResponse) { LOG.debug("Entitlements Response" ); } else{ intuitResponse = (IntuitResponse) responseElements.getResponse(); } if (intuitResponse != null && intuitResponse.getFault() != null) { Fault fault = intuitResponse.getFault(); if (fault.getType().equalsIgnoreCase("Validation")) { throw new ValidationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Service")) { throw new ServiceException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("AuthenticationFault")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Authentication")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("ApplicationAuthenticationFailed")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Authorization")) { throw new AuthorizationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("AuthorizationFault")) { throw new AuthorizationException(fault.getError()); } else { throw new FMSException(fault.getError()); } } else if (intuitResponse == null) { StatusLine statusLine = responseElements.getStatusLine(); String responseMessage = statusLine.getReasonPhrase(); int status = responseElements.getStatusCode(); if (responseMessage == null) { responseMessage = Integer.toString(status); } if (status == HTTP_ERROR_400) { throw new BadRequestException(responseMessage); } else if (status == HTTP_ERROR_401) { throw new InvalidTokenException(responseMessage); } else if (status == HTTP_ERROR_403) { throw new InvalidRequestException(responseMessage); } else if (status == HTTP_ERROR_404) { throw new InvalidRequestException(responseMessage); } else if (status == HTTP_ERROR_500) { throw new InternalServiceException(responseMessage); } else if (status == HTTP_ERROR_503) { throw new ServiceUnavailableException(responseMessage); } else if (status == HTTP_ERROR_429) { throw new ServiceException(responseMessage); } } LOG.debug("Exit HandleResponseInterceptor."); } }
HandleResponseInterceptor implements Interceptor { @Override public void execute(IntuitMessage intuitMessage) throws FMSException { LOG.debug("Enter HandleResponseInterceptor..."); IntuitResponse intuitResponse = null; ResponseElements responseElements = intuitMessage.getResponseElements(); if(responseElements.getResponse() instanceof TaxService) { LOG.debug("Tax Service Response" ); } else if(responseElements.getResponse() instanceof EntitlementsResponse) { LOG.debug("Entitlements Response" ); } else{ intuitResponse = (IntuitResponse) responseElements.getResponse(); } if (intuitResponse != null && intuitResponse.getFault() != null) { Fault fault = intuitResponse.getFault(); if (fault.getType().equalsIgnoreCase("Validation")) { throw new ValidationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Service")) { throw new ServiceException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("AuthenticationFault")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Authentication")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("ApplicationAuthenticationFailed")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Authorization")) { throw new AuthorizationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("AuthorizationFault")) { throw new AuthorizationException(fault.getError()); } else { throw new FMSException(fault.getError()); } } else if (intuitResponse == null) { StatusLine statusLine = responseElements.getStatusLine(); String responseMessage = statusLine.getReasonPhrase(); int status = responseElements.getStatusCode(); if (responseMessage == null) { responseMessage = Integer.toString(status); } if (status == HTTP_ERROR_400) { throw new BadRequestException(responseMessage); } else if (status == HTTP_ERROR_401) { throw new InvalidTokenException(responseMessage); } else if (status == HTTP_ERROR_403) { throw new InvalidRequestException(responseMessage); } else if (status == HTTP_ERROR_404) { throw new InvalidRequestException(responseMessage); } else if (status == HTTP_ERROR_500) { throw new InternalServiceException(responseMessage); } else if (status == HTTP_ERROR_503) { throw new ServiceUnavailableException(responseMessage); } else if (status == HTTP_ERROR_429) { throw new ServiceException(responseMessage); } } LOG.debug("Exit HandleResponseInterceptor."); }  }
HandleResponseInterceptor implements Interceptor { @Override public void execute(IntuitMessage intuitMessage) throws FMSException { LOG.debug("Enter HandleResponseInterceptor..."); IntuitResponse intuitResponse = null; ResponseElements responseElements = intuitMessage.getResponseElements(); if(responseElements.getResponse() instanceof TaxService) { LOG.debug("Tax Service Response" ); } else if(responseElements.getResponse() instanceof EntitlementsResponse) { LOG.debug("Entitlements Response" ); } else{ intuitResponse = (IntuitResponse) responseElements.getResponse(); } if (intuitResponse != null && intuitResponse.getFault() != null) { Fault fault = intuitResponse.getFault(); if (fault.getType().equalsIgnoreCase("Validation")) { throw new ValidationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Service")) { throw new ServiceException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("AuthenticationFault")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Authentication")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("ApplicationAuthenticationFailed")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Authorization")) { throw new AuthorizationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("AuthorizationFault")) { throw new AuthorizationException(fault.getError()); } else { throw new FMSException(fault.getError()); } } else if (intuitResponse == null) { StatusLine statusLine = responseElements.getStatusLine(); String responseMessage = statusLine.getReasonPhrase(); int status = responseElements.getStatusCode(); if (responseMessage == null) { responseMessage = Integer.toString(status); } if (status == HTTP_ERROR_400) { throw new BadRequestException(responseMessage); } else if (status == HTTP_ERROR_401) { throw new InvalidTokenException(responseMessage); } else if (status == HTTP_ERROR_403) { throw new InvalidRequestException(responseMessage); } else if (status == HTTP_ERROR_404) { throw new InvalidRequestException(responseMessage); } else if (status == HTTP_ERROR_500) { throw new InternalServiceException(responseMessage); } else if (status == HTTP_ERROR_503) { throw new ServiceUnavailableException(responseMessage); } else if (status == HTTP_ERROR_429) { throw new ServiceException(responseMessage); } } LOG.debug("Exit HandleResponseInterceptor."); }  @Override void execute(IntuitMessage intuitMessage); }
HandleResponseInterceptor implements Interceptor { @Override public void execute(IntuitMessage intuitMessage) throws FMSException { LOG.debug("Enter HandleResponseInterceptor..."); IntuitResponse intuitResponse = null; ResponseElements responseElements = intuitMessage.getResponseElements(); if(responseElements.getResponse() instanceof TaxService) { LOG.debug("Tax Service Response" ); } else if(responseElements.getResponse() instanceof EntitlementsResponse) { LOG.debug("Entitlements Response" ); } else{ intuitResponse = (IntuitResponse) responseElements.getResponse(); } if (intuitResponse != null && intuitResponse.getFault() != null) { Fault fault = intuitResponse.getFault(); if (fault.getType().equalsIgnoreCase("Validation")) { throw new ValidationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Service")) { throw new ServiceException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("AuthenticationFault")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Authentication")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("ApplicationAuthenticationFailed")) { throw new AuthenticationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("Authorization")) { throw new AuthorizationException(fault.getError()); } else if (fault.getType().equalsIgnoreCase("AuthorizationFault")) { throw new AuthorizationException(fault.getError()); } else { throw new FMSException(fault.getError()); } } else if (intuitResponse == null) { StatusLine statusLine = responseElements.getStatusLine(); String responseMessage = statusLine.getReasonPhrase(); int status = responseElements.getStatusCode(); if (responseMessage == null) { responseMessage = Integer.toString(status); } if (status == HTTP_ERROR_400) { throw new BadRequestException(responseMessage); } else if (status == HTTP_ERROR_401) { throw new InvalidTokenException(responseMessage); } else if (status == HTTP_ERROR_403) { throw new InvalidRequestException(responseMessage); } else if (status == HTTP_ERROR_404) { throw new InvalidRequestException(responseMessage); } else if (status == HTTP_ERROR_500) { throw new InternalServiceException(responseMessage); } else if (status == HTTP_ERROR_503) { throw new ServiceUnavailableException(responseMessage); } else if (status == HTTP_ERROR_429) { throw new ServiceException(responseMessage); } } LOG.debug("Exit HandleResponseInterceptor."); }  @Override void execute(IntuitMessage intuitMessage);  }