for(SoapMockResponse mockResponse : mockResponses){ if(mockResponse.getId().equals(soapOperation.getDefaultMockResponseId())){ soapOperation.setDefaultResponseName(mockResponse.getName()); defaultXpathMockResponseFound = true; break;
@Test public void testMockedXpathDefaultResponse(){ // Input final HttpServletRequest httpServletRequest = getMockedHttpServletRequest(REQUEST_BODY); final HttpServletResponse httpServletResponse = getHttpServletResponse(); final SoapOperation soapOperation = getSoapOperation(); soapOperation.setDefaultResponseName("Mocked response"); soapOperation.setDefaultMockResponseId("MockResponseId"); soapOperation.setResponseStrategy(SoapResponseStrategy.XPATH_INPUT); final IdentifySoapOperationOutput identifySoapOperationOutput = IdentifySoapOperationOutput.builder() .projectId(PROJECT_ID) .portId(SOAP_PORT_ID) .operationId(SOAP_OPERATION_ID) .operation(soapOperation) .build(); when(serviceProcessor.process(any(IdentifySoapOperationInput.class))).thenReturn(identifySoapOperationOutput); when(httpServletRequest.getRequestURI()).thenReturn(CONTEXT + SLASH + MOCK + SLASH + SOAP + SLASH + PROJECT + SLASH + PROJECT_ID + SLASH + SOAP_PORT_ID); final ResponseEntity responseEntity = soapServiceController.postMethod(PROJECT_ID, httpServletRequest, httpServletResponse); Assert.assertEquals(RESPONSE_BODY, responseEntity.getBody()); Assert.assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); Assert.assertEquals(true, responseEntity.getHeaders().containsKey(CONTENT_TYPE_HEADER)); Assert.assertEquals(true, responseEntity.getHeaders().containsKey(ACCEPT_HEADER)); Assert.assertEquals(APPLICATION_XML, responseEntity.getHeaders().get(CONTENT_TYPE_HEADER).get(0)); Assert.assertEquals(APPLICATION_XML, responseEntity.getHeaders().get(ACCEPT_HEADER).get(0)); }