@@ -169,27 +169,24 @@ void deleteCustomer_ok200() throws Exception {
169169 void createCustomer_badJson_notReadable () throws Exception {
170170 var malformed = "{ \" name\" : \" John\" , \" email\" : }" ; // invalid JSON
171171
172- mvc .perform (
173- post ("/v1/customers" )
174- .contentType (MediaType .APPLICATION_JSON )
175- .content (malformed ))
176- .andExpect (status ().isBadRequest ())
177- .andExpect (content ().contentType (MediaType .APPLICATION_JSON ))
178- .andExpect (jsonPath ("$.message" ).value ("BAD_REQUEST" ))
179- .andExpect (jsonPath ("$.data.code" ).value ("VALIDATION_FAILED" ))
180- .andExpect (jsonPath ("$.data.violations" ).isArray ());
172+ mvc .perform (post ("/v1/customers" ).contentType (MediaType .APPLICATION_JSON ).content (malformed ))
173+ .andExpect (status ().isBadRequest ())
174+ .andExpect (content ().contentType (MediaType .APPLICATION_JSON ))
175+ .andExpect (jsonPath ("$.message" ).value ("BAD_REQUEST" ))
176+ .andExpect (jsonPath ("$.data.code" ).value ("VALIDATION_FAILED" ))
177+ .andExpect (jsonPath ("$.data.violations" ).isArray ());
181178 }
182179
183180 @ Test
184181 @ DisplayName ("GET /v1/customers/{id} -> 400 Bad Request on @Min violation (id=0)" )
185182 void getCustomer_constraintViolation_min () throws Exception {
186183 mvc .perform (get ("/v1/customers/{id}" , 0 )) // @Min(1) violated
187- .andExpect (status ().isBadRequest ())
188- .andExpect (content ().contentType (MediaType .APPLICATION_JSON ))
189- .andExpect (jsonPath ("$.message" ).value ("BAD_REQUEST" ))
190- .andExpect (jsonPath ("$.data.code" ).value ("VALIDATION_FAILED" ))
191- .andExpect (jsonPath ("$.data.violations" ).isArray ())
192- .andExpect (jsonPath ("$.data.violations[0].message" ).exists ());
184+ .andExpect (status ().isBadRequest ())
185+ .andExpect (content ().contentType (MediaType .APPLICATION_JSON ))
186+ .andExpect (jsonPath ("$.message" ).value ("BAD_REQUEST" ))
187+ .andExpect (jsonPath ("$.data.code" ).value ("VALIDATION_FAILED" ))
188+ .andExpect (jsonPath ("$.data.violations" ).isArray ())
189+ .andExpect (jsonPath ("$.data.violations[0].message" ).exists ());
193190 }
194191
195192 @ Test
@@ -198,11 +195,11 @@ void getCustomer_internalServerError_generic() throws Exception {
198195 when (customerService .getCustomer (1 )).thenThrow (new RuntimeException ("Boom" ));
199196
200197 mvc .perform (get ("/v1/customers/{id}" , 1 ))
201- .andExpect (status ().isInternalServerError ())
202- .andExpect (content ().contentType (MediaType .APPLICATION_JSON ))
203- .andExpect (jsonPath ("$.message" ).value ("INTERNAL_ERROR" ))
204- .andExpect (jsonPath ("$.data.code" ).value ("INTERNAL_ERROR" ))
205- .andExpect (jsonPath ("$.data.message" ).value ("Boom" ));
198+ .andExpect (status ().isInternalServerError ())
199+ .andExpect (content ().contentType (MediaType .APPLICATION_JSON ))
200+ .andExpect (jsonPath ("$.message" ).value ("INTERNAL_ERROR" ))
201+ .andExpect (jsonPath ("$.data.code" ).value ("INTERNAL_ERROR" ))
202+ .andExpect (jsonPath ("$.data.message" ).value ("Boom" ));
206203 }
207204
208205 @ AfterEach
0 commit comments