@Test public void testCheckConditionShouldPassWhenJsonHasProperParameter() throws Exception { givenExpectations("Wilma", "$.name"); givenWilmaRequest("{\"name\":\"Wilma\",\"age\":\"20\"}"); boolean matches = underTest.checkCondition(request, parameters); assertTrue(matches); }
@Override public boolean checkCondition(final WilmaHttpRequest request, final ParameterList parameters) { String expected = parameters.get(EXPECTED_KEY); String path = parameters.get(JSONPATH_KEY); boolean equals; try { String actualValue = JsonPath.read(request.getBody(), path); equals = evaluate(expected, actualValue); } catch (Exception e) { logger.debug("Request body isn't of JSON format, message:" + request.getWilmaMessageLoggerId(), e); equals = false; } return equals; }
JsonPathChecker implements ConditionChecker { @Override public boolean checkCondition(final WilmaHttpRequest request, final ParameterList parameters) { String expected = parameters.get(EXPECTED_KEY); String path = parameters.get(JSONPATH_KEY); boolean equals; try { String actualValue = JsonPath.read(request.getBody(), path); equals = evaluate(expected, actualValue); } catch (Exception e) { logger.debug("Request body isn't of JSON format, message:" + request.getWilmaMessageLoggerId(), e); equals = false; } return equals; } }
JsonPathChecker implements ConditionChecker { @Override public boolean checkCondition(final WilmaHttpRequest request, final ParameterList parameters) { String expected = parameters.get(EXPECTED_KEY); String path = parameters.get(JSONPATH_KEY); boolean equals; try { String actualValue = JsonPath.read(request.getBody(), path); equals = evaluate(expected, actualValue); } catch (Exception e) { logger.debug("Request body isn't of JSON format, message:" + request.getWilmaMessageLoggerId(), e); equals = false; } return equals; }  }
JsonPathChecker implements ConditionChecker { @Override public boolean checkCondition(final WilmaHttpRequest request, final ParameterList parameters) { String expected = parameters.get(EXPECTED_KEY); String path = parameters.get(JSONPATH_KEY); boolean equals; try { String actualValue = JsonPath.read(request.getBody(), path); equals = evaluate(expected, actualValue); } catch (Exception e) { logger.debug("Request body isn't of JSON format, message:" + request.getWilmaMessageLoggerId(), e); equals = false; } return equals; }  @Override boolean checkCondition(final WilmaHttpRequest request, final ParameterList parameters); }
JsonPathChecker implements ConditionChecker { @Override public boolean checkCondition(final WilmaHttpRequest request, final ParameterList parameters) { String expected = parameters.get(EXPECTED_KEY); String path = parameters.get(JSONPATH_KEY); boolean equals; try { String actualValue = JsonPath.read(request.getBody(), path); equals = evaluate(expected, actualValue); } catch (Exception e) { logger.debug("Request body isn't of JSON format, message:" + request.getWilmaMessageLoggerId(), e); equals = false; } return equals; }  @Override boolean checkCondition(final WilmaHttpRequest request, final ParameterList parameters);  }