Examples of JSONPath


Examples of com.facebook.presto.operator.scalar.JsonPath

            throws Exception
    {
        for (String value : jsonValues) {
            for (String pattern : jsonPatterns) {
                assertExecute(generateExpression("json_extract(%s, %s)", value, pattern),
                        value == null || pattern == null ? null : JsonFunctions.jsonExtract(Slices.copiedBuffer(value, UTF_8), new JsonPath(pattern)));
                assertExecute(generateExpression("json_extract_scalar(%s, %s)", value, pattern),
                        value == null || pattern == null ? null : JsonFunctions.jsonExtractScalar(Slices.copiedBuffer(value, UTF_8), new JsonPath(pattern)));

                assertExecute(generateExpression("json_extract(%s, %s || '')", value, pattern),
                        value == null || pattern == null ? null : JsonFunctions.jsonExtract(Slices.copiedBuffer(value, UTF_8), new JsonPath(pattern)));
                assertExecute(generateExpression("json_extract_scalar(%s, %s || '')", value, pattern),
                        value == null || pattern == null ? null : JsonFunctions.jsonExtractScalar(Slices.copiedBuffer(value, UTF_8), new JsonPath(pattern)));
            }
        }

        assertExecute("json_array_contains('[1, 2, 3]', 2)", true);
        assertExecute("json_array_contains('[2.5]', 2.5)", true);
View Full Code Here

Examples of com.jayway.jsonpath.JsonPath

    }

    @Test
    public void read_store_book_1() throws Exception {

        JsonPath path = JsonPath.compile("$.store.book[1]");

        Map map = path.read(DOCUMENT);

        assertEquals("Evelyn Waugh", map.get("author"));
    }
View Full Code Here

Examples of com.jayway.jsonpath.JsonPath

        assertEquals("Evelyn Waugh", map.get("author"));
    }

    @Test
    public void read_store_book_wildcard() throws Exception {
        JsonPath path = JsonPath.compile("$.store.book[*]");

        List<Object> list = path.read(DOCUMENT);
        Assertions.assertThat(list.size()).isEqualTo(4);

    }
View Full Code Here

Examples of com.jayway.jsonpath.JsonPath

    @Path("/validate")
    @Produces(MediaType.APPLICATION_JSON)
    public Response validate(@QueryParam("path") String path) {
        int result = -1;
        try {
            JsonPath compiled = JsonPath.compile(path);
            result = compiled.isDefinite() ? 0 : 1;
        } catch (Exception e) {
        }
        return Response.ok(Collections.singletonMap("result", result)).build();
    }
View Full Code Here

Examples of com.jayway.jsonpath.JsonPath

  }

  public SpinJsonTreePathQuery jsonPath(String expression) {
    ensureNotNull("expression", expression);
    try {
      JsonPath query = JsonPath.compile(expression);
      return new SpinJsonJacksonPathQuery(this, query, dataFormat);
    } catch(InvalidPathException pex) {
      throw LOG.unableToCompileJsonPathExpression(expression, pex);
    } catch(IllegalArgumentException aex) {
      throw LOG.unableToCompileJsonPathExpression(expression, aex);
View Full Code Here

Examples of com.jayway.restassured.path.json.JsonPath

    verifyDeploymentValues(mockDeployment, content);
    verifyDeploymentLink(mockDeployment, content);
  }

  private void verifyDeploymentValues(Deployment mockDeployment, String responseContent) {
    JsonPath path = from(responseContent);
    String returnedId = path.get("id");
    String returnedName = path.get("name");
    Date returnedDeploymentTime = DateTimeUtil.parseDate(path.<String>get("deploymentTime"));

    assertEquals(mockDeployment.getId(), returnedId);
    assertEquals(mockDeployment.getName(), returnedName);
    assertEquals(mockDeployment.getDeploymentTime(), returnedDeploymentTime);
  }
View Full Code Here

Examples of com.jayway.restassured.path.json.JsonPath

  }

  private void verifyDeploymentResource(Resource mockDeploymentResource, Response response) {
    String content = response.asString();

    JsonPath path = from(content);
    String returnedId = path.get("id");
    String returnedName = path.get("name");
    String returnedDeploymentId = path.get("deploymentId");

    assertEquals(mockDeploymentResource.getId(), returnedId);
    assertEquals(mockDeploymentResource.getName(), returnedName);
    assertEquals(mockDeploymentResource.getDeploymentId(), returnedDeploymentId);
  }
View Full Code Here

Examples of com.jayway.restassured.path.json.JsonPath

    verifyTaskCommentValues(mockTaskComment, content);
    verifyTaskCommentLink(mockTaskComment, content);
  }

  private void verifyTaskCommentValues(Comment mockTaskComment, String responseContent) {
    JsonPath path = from(responseContent);
    String returnedId = path.get("id");
    String returnedUserId = path.get("userId");
    String returnedTaskId = path.get("taskId");
    Date returnedTime = DateTimeUtil.parseDate(path.<String>get("time"));
    String returnedFullMessage = path.get("message");

    assertEquals(mockTaskComment.getId(), returnedId);
    assertEquals(mockTaskComment.getTaskId(), returnedTaskId);
    assertEquals(mockTaskComment.getUserId(), returnedUserId);
    assertEquals(mockTaskComment.getTime(), returnedTime);
View Full Code Here

Examples of com.jayway.restassured.path.json.JsonPath

    verifyTaskAttachmentValues(mockTaskAttachment, content, urlExist);
    verifyTaskAttachmentLink(mockTaskAttachment, content);
  }

  private void verifyTaskAttachmentValues(Attachment mockTaskAttachment, String responseContent, boolean urlExist) {
    JsonPath path = from(responseContent);
    String returnedId = path.get("id");
    String returnedTaskId = path.get("taskId");
    String returnedName = path.get("name");
    String returnedType = path.get("type");
    String returnedDescription = path.get("description");
    String returnedUrl = path.get("url");

    Attachment mockAttachment = mockTaskAttachments.get(0);

    assertEquals(mockAttachment.getId(), returnedId);
    assertEquals(mockAttachment.getTaskId(), returnedTaskId);
View Full Code Here

Examples of com.jayway.restassured.path.json.JsonPath

        }
    }

    @Test
    public void testListPlugins() throws Exception {
        JsonPath json = given()
            .header(acceptJson)
            .parameter("name", "dummy")
            .expect()
            .statusCode(200)
            .log().ifError()
            .when()
            .get("/plugins").jsonPath();

        List<Map<String, Object>> results = json.get();

        assert results != null;
        assert results.size() == 1;

        Map<String, Object> platformPlugin = results.get(0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.