AcceptorPathMatcher { public static boolean pathAll(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 false; } } return true; }  static boolean pathAll(JsonNode expectedResult, JsonNode finalResult); static boolean pathAny(JsonNode expectedResult, JsonNode finalResult); static boolean path(JsonNode expectedResult, JsonNode finalResult);  }
@Test public void pathAllMatcher_SuccessState() throws Exception{ JsonNode expectedResult = mapper.readTree("\"running\""); Assert.assertTrue("Expected result not equals final result", new AcceptorPathMatcher().pathAll(expectedResult, mapper.readTree("[\"running\", \"running\", \"running\", \"running\"]"))); }
@Test public void pathAllMatcher_FailureState() throws Exception{ JsonNode expectedResult = mapper.readTree("\"running\""); Assert.assertFalse("Expected result not equals final result", new AcceptorPathMatcher().pathAll(expectedResult, mapper.readTree("[\"running\", \"terminated\", \"running\", \"running\"]"))); }
@Test public void pathAllMatcher_FinalResultEmptyArray_ReturnsTrue() throws Exception{ JsonNode expectedResult = mapper.readTree("\"running\""); Assert.assertTrue(new AcceptorPathMatcher().pathAll(expectedResult, mapper.readTree("[]"))); }
@Test(expected = RuntimeException.class) public void pathAllMatcher_FinalResultNotAnArray_ThrowsRunTimeException() throws Exception{ JsonNode expectedResult = mapper.readTree("\"running\""); new AcceptorPathMatcher().pathAll(expectedResult, mapper.readTree("\"running\"")); }