Java Code Examples for io.restassured.path.json.JsonPath#getString()
The following examples show how to use
io.restassured.path.json.JsonPath#getString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CrawlTestBase.java From fess with Apache License 2.0 | 6 votes |
protected static void deleteDocuments(final String queryString) { List<String> docIds = new ArrayList<>(); Response response = given().contentType("application/json").param("scroll", "1m").param("q", queryString) .get(getEsUrl() + "/" + DOC_INDEX_NAME + "/" + DOC_TYPE_NAME + "/_search"); JsonPath jsonPath = JsonPath.from(response.asString()); String scrollId = jsonPath.getString("_scroll_id"); while (true) { List<String> resultIds = jsonPath.getList("hits.hits._id"); if (resultIds.size() == 0) { break; } docIds.addAll(resultIds); Map<String, Object> scrollBody = new HashMap<>(); scrollBody.put("scroll", "1m"); scrollBody.put("scroll_id", scrollId); response = given().contentType("application/json").body(scrollBody).get(getEsUrl() + "/_search/scroll"); jsonPath = JsonPath.from(response.asString()); } for (String docId : docIds) { given().contentType("application/json").delete(getEsUrl() + "/" + DOC_INDEX_NAME + "/" + DOC_TYPE_NAME + "/" + docId); } }
Example 2
Source File: BraintreeTest.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Test public void testBraintreeComponent() { String token = RestAssured .get("/braintree/token") .then() .statusCode(200) .extract() .body() .asString(); assertNotNull(token); assertTrue(token.length() > 0); JsonPath saleResult = RestAssured.given() .post("/braintree/sale") .then() .statusCode(200) .extract() .body() .jsonPath(); assertTrue(saleResult.getBoolean("success")); assertNotNull(saleResult.getString("transactionId")); String transactionId = saleResult.getString("transactionId"); JsonPath refundResult = RestAssured.given() .body(transactionId) .post("/braintree/refund") .then() .statusCode(200) .extract() .body() .jsonPath(); assertTrue(refundResult.getBoolean("success")); }
Example 3
Source File: BlogSubResourceTest.java From ddd-architecture-samples with MIT License | 5 votes |
@Test void should_save_blog() { JsonPath jsonPath = createBlog("Test Blog", "Something...", authorId).jsonPath(); UUID createdBlogId = jsonPath.getUUID("id"); String createdBlogSavedAt = jsonPath.getString("savedAt"); given() .contentType(JSON) .body(ImmutableMap.of( "title", "Updated Title", "body", "Updated..." )) .when() .put(buildPath(createdBlogId)) .then() .spec(NO_CONTENT_SPEC); Response response = getBlog(createdBlogId); response .then() .spec(OK_SPEC) .body("id", is(createdBlogId.toString())) .body("title", is("Updated Title")) .body("body", is("Updated...")); String savedAt = response.jsonPath().getString("savedAt"); assertThat(Instant.parse(savedAt)).isAfter(Instant.parse(createdBlogSavedAt)); }
Example 4
Source File: MpMetricTest.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(21) public void testApplicationTagJson() { JsonPath jsonPath = given().header("Accept", APPLICATION_JSON) .when() .options("/metrics/application/purple").jsonPath(); String tags = jsonPath.getString("purple.tags"); assertNotNull(tags); assertTrue(tags.contains("app=myShop")); assertTrue(tags.contains("tier=integration")); }
Example 5
Source File: CrawlTestBase.java From fess with Apache License 2.0 | 5 votes |
protected static String createWebConfig(final Map<String, Object> requestBody) { String response = checkMethodBase(requestBody).put("/api/admin/webconfig/setting").asString(); JsonPath jsonPath = JsonPath.from(response); assertTrue(jsonPath.getBoolean("response.created")); assertEquals(0, jsonPath.getInt("response.status")); return jsonPath.getString("response.id"); }
Example 6
Source File: CrawlTestBase.java From fess with Apache License 2.0 | 5 votes |
protected static String createFileConfig(final Map<String, Object> requestBody) { String response = checkMethodBase(requestBody).put("/api/admin/fileconfig/setting").asString(); JsonPath jsonPath = JsonPath.from(response); assertTrue(jsonPath.getBoolean("response.created")); assertEquals(0, jsonPath.getInt("response.status")); return jsonPath.getString("response.id"); }