Skip to content

Commit

Permalink
Fix $.size()
Browse files Browse the repository at this point in the history
  • Loading branch information
tkobayas committed Nov 30, 2023
1 parent 1d203da commit 47516c7
Show file tree
Hide file tree
Showing 19 changed files with 146 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private void sendQuestionnaire(String id) {
.get("/tasks")
.then()
.statusCode(200)
.body("$.size", is(1))
.body("size()", is(1))
.body("[0].name", is("Questionnaire"))
.extract()
.path("[0].id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testDealsRest() {
given().accept(ContentType.JSON)
.when().get("/deals")
.then().statusCode(200)
.body("$.size()", is(1))
.body("size()", is(1))
.body("[0].id", is(dealId))
.body("[0].name", is(deal));

Expand All @@ -68,7 +68,7 @@ public void testDealsRest() {
String dealReviewId = given().accept(ContentType.JSON)
.when().get("/dealreviews")
.then().statusCode(200)
.body("$.size()", is(1))
.body("size()", is(1))
.body("[0].id", notNullValue())
.body("[0].deal", is(deal))
.extract().path("[0].id");
Expand All @@ -77,7 +77,7 @@ public void testDealsRest() {
String taskId = given().accept(ContentType.JSON)
.when().get("/dealreviews/{uuid}/tasks?user=john", dealReviewId)
.then().statusCode(200)
.body("$.size", is(1))
.body("size()", is(1))
.body("[0].name", is("review"))
.body("[0].parameters.deal", is(deal))
.extract().path("[0].id");
Expand All @@ -93,12 +93,12 @@ public void testDealsRest() {
//verify no deals to review
given().accept(ContentType.JSON)
.when().get("/dealreviews")
.then().statusCode(200).body("$.size()", is(0));
.then().statusCode(200).body("size()", is(0));

//verify no deals
given().accept(ContentType.JSON)
.when().get("/deals")
.then().statusCode(200).body("$.size()", is(0));
.then().statusCode(200).body("size()", is(0));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testDealsRest() {
given().accept(ContentType.JSON)
.when().get("/deals")
.then().statusCode(200)
.body("$.size()", is(1))
.body("size()", is(1))
.body("[0].id", is(dealId))
.body("[0].name", is(deal));

Expand All @@ -62,7 +62,7 @@ public void testDealsRest() {
String dealReviewId = given().accept(ContentType.JSON)
.when().get("/dealreviews")
.then().statusCode(200)
.body("$.size()", is(1))
.body("size()", is(1))
.body("[0].id", notNullValue())
.body("[0].deal", is(deal))
.extract().path("[0].id");
Expand All @@ -71,7 +71,7 @@ public void testDealsRest() {
String taskId = given().accept(ContentType.JSON)
.when().get("/dealreviews/{uuid}/tasks?user=john", dealReviewId)
.then().statusCode(200)
.body("$.size", is(1))
.body("size()", is(1))
.body("[0].name", is("review"))
.body("[0].parameters.deal", is(deal))
.extract().path("[0].id");
Expand All @@ -87,11 +87,11 @@ public void testDealsRest() {
//verify no deals to review
given().accept(ContentType.JSON)
.when().get("/dealreviews")
.then().statusCode(200).body("$.size()", is(0));
.then().statusCode(200).body("size()", is(0));

//verify no deals
given().accept(ContentType.JSON)
.when().get("/deals")
.then().statusCode(200).body("$.size()", is(0));
.then().statusCode(200).body("size()", is(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void testDealsRest() {
// test getting the created deal
given().accept(ContentType.JSON)
.when().get("/deals")
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(1), "[0].id", is(dealId));
.then().log().ifValidationFails().statusCode(200).body("size()", is(1), "[0].id", is(dealId));

// test getting order by id
given().accept(ContentType.JSON)
Expand All @@ -55,12 +55,12 @@ public void testDealsRest() {
// get deals for review
String dealReviewId = given().accept(ContentType.JSON)
.when().get("/dealreviews")
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(1)).body("[0].id", notNullValue()).extract().path("[0].id");
.then().log().ifValidationFails().statusCode(200).body("size()", is(1)).body("[0].id", notNullValue()).extract().path("[0].id");

// get task for john
String taskId = given().accept(ContentType.JSON)
.when().get("/dealreviews/{uuid}/tasks?user=john", dealReviewId)
.then().log().ifValidationFails().statusCode(200).body("$.size", is(1)).extract().path("[0].id");
.then().log().ifValidationFails().statusCode(200).body("size()", is(1)).extract().path("[0].id");

// complete review task
given().contentType(ContentType.JSON).accept(ContentType.JSON).body("{\"review\" : \"very good work\"}")
Expand All @@ -70,11 +70,11 @@ public void testDealsRest() {
//verify no deals to review
given().accept(ContentType.JSON)
.when().get("/dealreviews")
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(0));
.then().log().ifValidationFails().statusCode(200).body("size()", is(0));

//verify no deals
given().accept(ContentType.JSON)
.when().get("/deals")
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(0));
.then().log().ifValidationFails().statusCode(200).body("size()", is(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void testDealsRest() {
// test getting the created deal
given().accept(ContentType.JSON)
.when().get("/deals")
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(1), "[0].id", is(dealId));
.then().log().ifValidationFails().statusCode(200).body("size()", is(1), "[0].id", is(dealId));

// test getting order by id
given().accept(ContentType.JSON)
Expand All @@ -52,12 +52,12 @@ public void testDealsRest() {
// get deals for review
String dealReviewId = given().accept(ContentType.JSON)
.when().get("/dealreviews")
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(1)).body("[0].id", notNullValue()).extract().path("[0].id");
.then().log().ifValidationFails().statusCode(200).body("size()", is(1)).body("[0].id", notNullValue()).extract().path("[0].id");

// get task for john
String taskId = given().accept(ContentType.JSON)
.when().get("/dealreviews/{uuid}/tasks?user=john", dealReviewId)
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(1)).extract().path("[0].id");
.then().log().ifValidationFails().statusCode(200).body("size()", is(1)).extract().path("[0].id");

// complete review task
given().contentType(ContentType.JSON).accept(ContentType.JSON).body("{\"review\" : \"very good work\"}")
Expand All @@ -67,11 +67,11 @@ public void testDealsRest() {
//verify no deals to review
given().accept(ContentType.JSON)
.when().get("/dealreviews")
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(0));
.then().log().ifValidationFails().statusCode(200).body("size()", is(0));

//verify no deals
given().accept(ContentType.JSON)
.when().get("/deals")
.then().log().ifValidationFails().statusCode(200).body("$.size()", is(0));
.then().log().ifValidationFails().statusCode(200).body("size()", is(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void testOrdersRest() {

// test getting the created order
given().accept(ContentType.JSON).when().get("/orders").then().statusCode(200)
.body("$.size()", is(1), "[0].id", is(firstCreatedId));
.body("size()", is(1), "[0].id", is(firstCreatedId));

// test getting order by id
given()
Expand Down Expand Up @@ -115,7 +115,7 @@ public void testOrdersRest() {
.get("/orders")
.then()
.statusCode(200)
.body("$.size()", is(1), "[0].id", is(secondCreatedId));
.body("size()", is(1), "[0].id", is(secondCreatedId));

// delete second before finishing
given()
Expand All @@ -131,7 +131,7 @@ public void testOrdersRest() {
.get("/orders")
.then()
.statusCode(200)
.body("$.size()", is(0));
.body("size()", is(0));
}

@Test
Expand All @@ -153,7 +153,7 @@ public void testOrdersWithErrorRest() {

// test getting the created order
given().accept(ContentType.JSON).when().get("/orders").then().statusCode(200)
.body("$.size()", is(1), "[0].id", is(firstCreatedId));
.body("size()", is(1), "[0].id", is(firstCreatedId));

// test retrieving error info using process management addon
given().accept(ContentType.JSON).when().get("/management/processes/demo.orders/instances/" + firstCreatedId + "/error").then()
Expand All @@ -174,7 +174,7 @@ public void testOrdersWithErrorRest() {
given().accept(ContentType.JSON).when().delete("/orders/" + firstCreatedId).then().statusCode(200);
// get all orders make sure there is zero
given().accept(ContentType.JSON).when().get("/orders").then().statusCode(200)
.body("$.size()", is(0));
.body("size()", is(0));
}

@Test
Expand All @@ -188,15 +188,15 @@ public void testOrdersWithOrderItemsRest() {

// test getting the created order
given().accept(ContentType.JSON).when().get("/orders").then().statusCode(200)
.body("$.size()", is(1), "[0].id", is(firstCreatedId));
.body("size()", is(1), "[0].id", is(firstCreatedId));

// test getting order by id
given().accept(ContentType.JSON).when().get("/orders/" + firstCreatedId).then()
.statusCode(200).body("id", is(firstCreatedId));

// test getting order items subprocess
String orderItemsId = given().accept(ContentType.JSON).when().get("/orderItems").then().statusCode(200)
.body("$.size()", is(1)).extract().path("[0].id");
.body("size()", is(1)).extract().path("[0].id");

// test getting order items by id
given().accept(ContentType.JSON).when().get("/orderItems/" + orderItemsId).then()
Expand All @@ -209,7 +209,7 @@ public void testOrdersWithOrderItemsRest() {
.get("/orderItems/" + orderItemsId + "/tasks?user=john")
.then()
.statusCode(200)
.body("$.size", is(1))
.body("size()", is(1))
.body("[0].name", is("Verify order"))
.extract()
.path("[0].id");
Expand All @@ -228,11 +228,11 @@ public void testOrdersWithOrderItemsRest() {

// get all orders make sure there is zero
given().accept(ContentType.JSON).when().get("/orders").then().statusCode(200)
.body("$.size()", is(0));
.body("size()", is(0));

// get all order items make sure there is zero
given().accept(ContentType.JSON).when().get("/orderItems").then().statusCode(200)
.body("$.size()", is(0));
.body("size()", is(0));
}

@Test
Expand All @@ -246,15 +246,15 @@ public void testOrdersWithOrderItemsAbortedRest() {

// test getting the created order
given().accept(ContentType.JSON).when().get("/orders").then().statusCode(200)
.body("$.size()", is(1), "[0].id", is(firstCreatedId));
.body("size()", is(1), "[0].id", is(firstCreatedId));

// test getting order by id
given().accept(ContentType.JSON).when().get("/orders/" + firstCreatedId).then()
.statusCode(200).body("id", is(firstCreatedId));

// test getting order items subprocess
String orderItemsId = given().accept(ContentType.JSON).when().get("/orderItems?businessKey=ORD-0001").then().statusCode(200)
.body("$.size()", is(1)).extract().path("[0].id");
.body("size()", is(1)).extract().path("[0].id");

// test getting order items by id
given().accept(ContentType.JSON).when().get("/orderItems/" + orderItemsId).then()
Expand All @@ -267,19 +267,19 @@ public void testOrdersWithOrderItemsAbortedRest() {
.get("/orderItems/" + orderItemsId + "/tasks?user=john")
.then()
.statusCode(200)
.body("$.size", is(1))
.body("size()", is(1))
.body("[0].name", is("Verify order"));

// test deleting order items
given().accept(ContentType.JSON).when().delete("/orderItems/" + orderItemsId).then().statusCode(200);

// get all orders make sure there is zero
given().accept(ContentType.JSON).when().get("/orders").then().statusCode(200)
.body("$.size()", is(0));
.body("size()", is(0));

// get all order items make sure there is zero
given().accept(ContentType.JSON).when().get("/orderItems").then().statusCode(200)
.body("$.size()", is(0));
.body("size()", is(0));
}

@Test
Expand All @@ -293,7 +293,7 @@ public void testCreateAndUpdateOrders() {
assertNotNull(id);
// get all orders make sure there is one
given().accept(ContentType.JSON).when().get("/orders").then().statusCode(200)
.body("$.size()", is(1));
.body("size()", is(1));

// get order by its custom ID and test
given().accept(ContentType.JSON).body(orderPayload).when().get("/orders/{id}", id).then()
Expand All @@ -310,13 +310,13 @@ public void testCreateAndUpdateOrders() {

// get all orders make sure there is one
given().accept(ContentType.JSON).when().get("/orders").then().statusCode(200)
.body("$.size()", is(1));
.body("size()", is(1));

// test deleting order items by custom ID
given().accept(ContentType.JSON).when().delete("/orders/{id}", id).then().statusCode(200);

// get all orders make sure there is zero
given().accept(ContentType.JSON).when().get("/orders").then().statusCode(200)
.body("$.size()", is(0));
.body("size()", is(0));
}
}
Loading

0 comments on commit 47516c7

Please sign in to comment.