public static List<String> validateJson(JsonNode schemaNode, JsonNode jsonNode) {
      try {
         return JsonSchemaValidator.validateJson(schemaNode, jsonNode);
      } catch (ProcessingException e) {
         log.debug("Got a ProcessingException while trying to interpret schemaNode as a real schema");
         List<String> errors = new ArrayList<>();
         errors.add("schemaNode does not seem to represent a valid Json schema");
         return errors;
      }
   }
@Test
   void testValidateJson() {
      String schemaText;
      String queryText = "{\n" + "  hero {\n" + "    name\n" + "    email\n" + "    family\n" + "    affiliate\n"
            + "    movies {\n" + "      title\n" + "    }\n" + "  }\n" + "}";
      String responseText = "{\n" + "  \"data\": {\n" + "    \"hero\": {\n" + "      \"name\": \"Iron Man\",\n"
            + "      \"email\": \"tony@stark.inc\",\n" + "      \"family\": \"MARVEL\",\n"
            + "      \"affiliate\": \"DC\",\n" + "      \"movies\": [\n" + "        {\"title\": \"Iron Man 1\"},\n"
            + "        {\"title\": \"Iron Man 2\"},\n" + "        {\"title\": \"Iron Man 3\"}\n" + "      ]\n"
            + "    }\n" + "  }\n" + "}";
      String badResponseText = "{\n" + "  \"data\": {\n" + "    \"hero\": {\n" + "      \"name\": \"Iron Man\",\n"
            + "      \"family\": \"MARVEL\",\n" + "      \"affiliate\": \"DC\",\n" + "      \"movies\": [\n"
            + "        {\"title\": \"Iron Man 1\"},\n" + "        {\"title\": \"Iron Man 2\"},\n"
            + "        {\"title\": \"Iron Man 3\"}\n" + "      ]\n" + "    }\n" + "  }\n" + "}";

      ObjectMapper mapper = new ObjectMapper();

      JsonNode responseSchema = null;
      List<String> validationErrors = null;
      try {
         // Load schema from file.
         schemaText = FileUtils
               .readFileToString(new File("target/test-classes/io/github/microcks/util/graphql/basic-heroes.graphql"));
         // Build JsonSchema for response.
         responseSchema = GraphQLSchemaValidator.buildResponseJsonSchema(schemaText, queryText);
         // Validate a correct response.
         validationErrors = GraphQLSchemaValidator.validateJson(responseSchema, mapper.readTree(responseText));
      } catch (Exception e) {
         fail("Exception should not be thrown");
      }
      assertTrue(validationErrors.isEmpty());

      try {
         // Validate a bad response with missing email.
         validationErrors = GraphQLSchemaValidator.validateJson(responseSchema, mapper.readTree(badResponseText));
      } catch (Exception e) {
         fail("Exception should not be thrown");
      }
      assertEquals(1, validationErrors.size());
      assertEquals("object has missing required properties ([\"email\"])", validationErrors.get(0));
   }