@Test
public void testMockedJsonPathMatch(){
final HttpServletRequest httpServletRequest = getMockedHttpServletRequest(JSON_REQUEST_BODY);
final HttpServletResponse httpServletResponse = getHttpServletResponse();
final RestJsonPathExpression restJsonPathExpression = new RestJsonPathExpression();
restJsonPathExpression.setExpression("$.request[?(@.variable == 'Value 1')]");
final RestMethod restMethod = getMockedRestMethod();
restMethod.getMockResponses().get(0).getJsonPathExpressions().add(restJsonPathExpression);
restMethod.setResponseStrategy(RestResponseStrategy.JSON_PATH);
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));
}