Skip to content

Commit 52a50ce

Browse files
committed
Add a wrap-up on service invocations count
Signed-off-by: Laurent Broudoux <[email protected]>
1 parent cb57035 commit 52a50ce

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

step-4-write-rest-tests.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ public void testGetPastries() {
128128
pastries = client.listPastries("L");
129129
assertEquals(2, pastries.size());
130130

131-
// Check that the mock API has really been invoked.
132-
boolean mockInvoked = microcksEnsemble.getMicrocksContainer().verify("API Pastries", "0.0.1");
133-
assertTrue(mockInvoked, "Mock API not invoked");
131+
// Check that the mock API has really been invoked.
132+
boolean mockInvoked = microcksEnsemble.getMicrocksContainer().verify("API Pastries", "0.0.1");
133+
assertTrue(mockInvoked, "Mock API not invoked");
134134
}
135135
```
136136

@@ -165,6 +165,9 @@ void testGetPastry() {
165165
}
166166
```
167167

168+
This is a super powerful way to ensure that your application logic (caching, no caching, etc.) is correctly implemented and use the
169+
mock endpoints when required 🎉
170+
168171
## Second Test - Verify the technical conformance of Order Service API
169172

170173
The 2nd thing we want to validate is the conformance of the `Order API` we'll expose to consumers. In this section and the next one,
@@ -324,6 +327,10 @@ void testOpenAPIContractAndBusinessConformance() throws Exception {
324327

325328
// You may also check business conformance.
326329
List<RequestResponsePair> pairs = microcksEnsemble.getMicrocksContainer().getMessagesForTestCase(testResult, "POST /orders");
330+
331+
// We need a mapper to deserialize JSON content.
332+
ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
333+
327334
for (RequestResponsePair pair : pairs) {
328335
if ("201".equals(pair.getResponse().getStatus())) {
329336
Map<String, Object> requestMap = mapper.readValue(pair.getRequest().getContent(), new TypeReference<>() {});

0 commit comments

Comments
 (0)