AcceptorPathMatcher { public static boolean pathAny(JsonNode expectedResult, JsonNode finalResult) { if (finalResult.isNull()) { return false; } if (!finalResult.isArray()) { throw new RuntimeException("Expected an array"); } for (JsonNode element : finalResult) { if (element.equals(expectedResult)) { return true; } } return false; }  static boolean pathAll(JsonNode expectedResult, JsonNode finalResult); static boolean pathAny(JsonNode expectedResult, JsonNode finalResult); static boolean path(JsonNode expectedResult, JsonNode finalResult);  }
@Test public void pathAnyMatcher_SuccessState() throws Exception{ JsonNode expectedResult = mapper.readTree("\"terminated\""); Assert.assertTrue("Expected result not equals final result", new AcceptorPathMatcher().pathAny(expectedResult, mapper.readTree("[\"running\", \"terminated\", \"running\", \"running\"]"))); }
@Test public void pathAnyMatcherFailureState() throws Exception { JsonNode expectedResult = mapper.readTree("\"terminated\""); Assert.assertFalse("Expected result not equals final result", new AcceptorPathMatcher().pathAny(expectedResult, mapper.readTree("[\"running\", \"running\", \"running\", \"running\"]"))); }
@Test public void pathAnyMatcherFinalResultEmptyArray() throws Exception { JsonNode expectedResult = mapper.readTree("\"terminated\""); Assert.assertFalse("Expected result not equals final result", new AcceptorPathMatcher().pathAny(expectedResult, mapper.readTree("[]"))); }
@Test(expected = RuntimeException.class) public void pathAnyMatcherFinalResultNotAnArray() throws Exception{ JsonNode expectedResult = mapper.readTree("\"terminated\""); new AcceptorPathMatcher().pathAny(expectedResult, BooleanNode.TRUE); }
@Test public void pathAnyMatcherNullFinalResult() throws Exception{ JsonNode expectedResult = mapper.readTree("\"terminated\""); Assert.assertFalse("Expected result not equals final result", new AcceptorPathMatcher().pathAny(expectedResult, NullNode.getInstance())); }