@@ -128,9 +128,9 @@ public void testGetPastries() {
128
128
pastries = client. listPastries(" L" );
129
129
assertEquals(2 , pastries. size());
130
130
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" );
134
134
}
135
135
```
136
136
@@ -165,6 +165,9 @@ void testGetPastry() {
165
165
}
166
166
```
167
167
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
+
168
171
## Second Test - Verify the technical conformance of Order Service API
169
172
170
173
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 {
324
327
325
328
// You may also check business conformance.
326
329
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
+
327
334
for (RequestResponsePair pair : pairs) {
328
335
if (" 201" . equals(pair. getResponse(). getStatus())) {
329
336
Map<String , Object > requestMap = mapper. readValue(pair. getRequest(). getContent(), new TypeReference<> () {});
0 commit comments