From 83dd6522c97cc8db4f8348650b48c3e1269ddd7a Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Wed, 4 Oct 2023 04:25:48 +0000 Subject: [PATCH] fixes Issue with Junit --- .../web/controllers/CustomerControllerTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/CustomerControllerTest.java b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/CustomerControllerTest.java index 83d19dbe3..d4349130e 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/CustomerControllerTest.java +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/web/controllers/CustomerControllerTest.java @@ -3,6 +3,7 @@ import static com.example.hibernatecache.utils.AppConstants.PROFILE_TEST; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.Matchers.hasSize; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.doNothing; @@ -114,10 +115,13 @@ void shouldReturn400WhenCreateNewCustomerWithoutFirstName() throws Exception { .andExpect(status().isBadRequest()) .andExpect(header().string("Content-Type", is("application/problem+json"))) .andExpect(jsonPath("$.type", is("about:blank"))) - .andExpect(jsonPath("$.title", is("Bad Request"))) + .andExpect(jsonPath("$.title", is("Constraint Violation"))) .andExpect(jsonPath("$.status", is(400))) .andExpect(jsonPath("$.detail", is("Invalid request content."))) .andExpect(jsonPath("$.instance", is("/api/customers"))) + .andExpect(jsonPath("$.violations", hasSize(1))) + .andExpect(jsonPath("$.violations[0].field", is("firstName"))) + .andExpect(jsonPath("$.violations[0].message", is("FirstName cannot be empty"))) .andReturn(); }