@Test
public void testMockedXpathMatch(){
final HttpServletRequest httpServletRequest = getMockedHttpServletRequest(XML_REQUEST_BODY);
final HttpServletResponse httpServletResponse = getHttpServletResponse();
final RestXPathExpression xPathExpression = new RestXPathExpression();
xPathExpression.setExpression("//request/variable[text()='Value 1']");
final RestMethod restMethod = getMockedRestMethod();
restMethod.getMockResponses().get(0).getXpathExpressions().add(xPathExpression);
restMethod.setResponseStrategy(RestResponseStrategy.XPATH);
final IdentifyRestMethodOutput identifyRestMethodOutput = IdentifyRestMethodOutput.builder()
.restProjectId(PROJECT_ID)
.restApplicationId(APPLICATION_ID)
.restResourceId(RESOURCE_ID)
.restMethodId(METHOD_ID)
.restMethod(restMethod)
.pathParameters(PATH_PARAMETERS)
.build();
when(serviceProcessor.process(any(IdentifyRestMethodInput.class))).thenReturn(identifyRestMethodOutput);
when(httpServletRequest.getRequestURI()).thenReturn(CONTEXT + SLASH + MOCK + SLASH + REST + SLASH + PROJECT +
SLASH + PROJECT_ID + SLASH + APPLICATION + SLASH + APPLICATION_ID + "/method/test");
final ResponseEntity responseEntity = restServiceController.postMethod(PROJECT_ID, APPLICATION_ID, httpServletRequest, httpServletResponse);
Assert.assertEquals(XML_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));
}