### Question:
ServiceErrorCheck implements ErrorCheck { @Override public ResponseEntity<ApiMessageView> checkError(HttpServletRequest request, Throwable exc) { if (exc instanceof ZuulException) { ZuulException exception = (ZuulException) exc; ApiMessageView messageView = null; if (exc.getCause() instanceof ServiceNotAccessibleException) { Throwable t = ExceptionUtils.getThrowables(exc)[ExceptionUtils.indexOfType(exc, ServiceNotAccessibleException.class)]; messageView = messageService.createMessage("org.zowe.apiml.gateway.serviceUnavailable", ErrorUtils.getGatewayUri(request), t.getCause() ).mapToView(); return ResponseEntity.status(HttpStatus.NOT_FOUND).contentType(MediaType.APPLICATION_JSON_UTF8).body(messageView); } else if (exception.nStatusCode == HttpStatus.NOT_FOUND.value()) { messageView = messageService.createMessage("org.zowe.apiml.common.endPointNotFound", exception.errorCause).mapToView(); return ResponseEntity.status(HttpStatus.NOT_FOUND).contentType(MediaType.APPLICATION_JSON_UTF8).body(messageView); } } return null; }  @Override ResponseEntity<ApiMessageView> checkError(HttpServletRequest request, Throwable exc);  }### Answer:
@Test void givenNotFoundZuulException_whenTheRequestIsProcessed_then404IsReturned() { MockHttpServletRequest request = new MockHttpServletRequest(); ZuulException exc = new ZuulException(new NotFound(), HttpStatus.NOT_FOUND.value(), "serviceId"); request.setAttribute(ErrorUtils.ATTR_ERROR_EXCEPTION, exc); ResponseEntity<ApiMessageView> actualResponse = underTest.checkError(request, exc); assertNotNull(actualResponse); assertEquals(HttpStatus.NOT_FOUND, actualResponse.getStatusCode()); List<ApiMessage> actualMessageList = actualResponse.getBody().getMessages(); assertThat(actualMessageList, hasItem(new ApiMessage("org.zowe.apiml.common.endPointNotFound", MessageType.ERROR, "ZWEAM104E", "The endpoint you are looking for 'serviceId' could not be located"))); }
@Test void givenServiceNotAccessibleException_whenTheRequestIsProcessed_then404IsReturned() { MockHttpServletRequest request = new MockHttpServletRequest(); ZuulException exc = new ZuulException(new ServiceNotAccessibleException("service"), HttpStatus.NOT_FOUND.value(), "serviceId"); request.setAttribute(ErrorUtils.ATTR_ERROR_EXCEPTION, exc); ResponseEntity<ApiMessageView> actualResponse = underTest.checkError(request, exc); assertNotNull(actualResponse); assertEquals(HttpStatus.NOT_FOUND, actualResponse.getStatusCode()); List<ApiMessage> actualMessageList = actualResponse.getBody().getMessages(); assertThat(actualMessageList, hasItem(new ApiMessage("org.zowe.apiml.gateway.serviceUnavailable", MessageType.ERROR, "ZWEAG709E", "Service is not available at URL 'null'. Error returned: 'null'"))); }