Skip to content

Commit 34456ae

Browse files
committed
feature of associating Warehouses: unit tests / code coverage
1 parent 5a31a22 commit 34456ae

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.fulfilment.application.monolith.rules;
2+
3+
import com.fulfilment.application.monolith.products.Product;
4+
import com.fulfilment.application.monolith.stores.Store;
5+
import com.fulfilment.application.monolith.warehouses.domain.models.Warehouse;
6+
import io.quarkus.test.junit.QuarkusTest;
7+
import org.junit.jupiter.api.Test;
8+
9+
import static io.restassured.RestAssured.given;
10+
import static io.restassured.http.ContentType.JSON;
11+
import static org.hamcrest.CoreMatchers.containsString;
12+
import static org.hamcrest.core.IsNot.not;
13+
14+
@QuarkusTest
15+
public class RulesEndpointTest {
16+
17+
@Test
18+
public void testCrudProduct() {
19+
final String path = "rules";
20+
21+
// List all, should have all 3 products the database has initially:
22+
given()
23+
.when()
24+
.get(path)
25+
.then()
26+
.statusCode(200);
27+
28+
//Create
29+
Store store = new Store();
30+
store.id=2L;
31+
Warehouse warehouse = new Warehouse();
32+
warehouse.businessUnitCode="MWH.012";
33+
Product product = new Product();
34+
product.id=2L;
35+
FulfillmentRule newRule = new FulfillmentRule(null, warehouse,store, product);
36+
given()
37+
.when()
38+
.contentType(JSON)
39+
.body(newRule)
40+
.post(path)
41+
.then()
42+
.statusCode(200);
43+
44+
given()
45+
.when()
46+
.get(path)
47+
.then()
48+
.statusCode(200)
49+
.body(containsString("MWH.012"));
50+
51+
given()
52+
.when()
53+
.contentType(JSON)
54+
.body(newRule)
55+
.post(path)
56+
.then()
57+
.statusCode(409);
58+
59+
given()
60+
.when()
61+
.delete(path + "/5")
62+
.then()
63+
.statusCode(404);
64+
65+
given()
66+
.when()
67+
.delete(path + "/1")
68+
.then()
69+
.statusCode(204);
70+
71+
given()
72+
.when()
73+
.get(path)
74+
.then()
75+
.statusCode(200)
76+
.body(not(containsString("MWH.012")));
77+
78+
}
79+
80+
}

0 commit comments

Comments
 (0)