diff --git a/src/test/java/org/isf/agetype/rest/AgeTypeControllerTest.java b/src/test/java/org/isf/agetype/rest/AgeTypeControllerTest.java index ebaac187b..448ed7d9e 100644 --- a/src/test/java/org/isf/agetype/rest/AgeTypeControllerTest.java +++ b/src/test/java/org/isf/agetype/rest/AgeTypeControllerTest.java @@ -31,6 +31,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import org.isf.agetype.data.AgeTypeHelper; import org.isf.agetype.dto.AgeTypeDTO; @@ -61,7 +62,7 @@ public class AgeTypeControllerTest { @Mock private AgeTypeBrowserManager ageTypeManagerMock; - private AgeTypeMapper ageTypeMapper = new AgeTypeMapper(); + private final AgeTypeMapper ageTypeMapper = new AgeTypeMapper(); private MockMvc mockMvc; @@ -120,7 +121,7 @@ public void testUpdateAgeType_200() throws Exception { MvcResult result = this.mockMvc .perform(put(request) .contentType(MediaType.APPLICATION_JSON) - .content(AgeTypeHelper.asJsonString(body)) + .content(Objects.requireNonNull(AgeTypeHelper.asJsonString(body))) ) .andDo(log()) .andExpect(status().is2xxSuccessful()) @@ -157,6 +158,7 @@ public void testGetAgeTypeByIndex_200() throws Exception { String request = "/agetypes/{index}"; int index = 10; AgeType ageType = AgeTypeHelper.setup(index); + AgeTypeDTO ageTypeDTO = ageTypeMapper.map2DTO(ageType); when(ageTypeManagerMock.getTypeByCode(index)) .thenReturn(ageType); @@ -166,7 +168,7 @@ public void testGetAgeTypeByIndex_200() throws Exception { .andDo(log()) .andExpect(status().is2xxSuccessful()) .andExpect(status().isOk()) - .andExpect(content().string(containsString(AgeTypeHelper.getObjectMapper().writeValueAsString(ageType)))) + .andExpect(content().string(containsString(AgeTypeHelper.getObjectMapper().writeValueAsString(ageTypeDTO)))) .andReturn(); LOGGER.debug("result: {}", result); diff --git a/src/test/java/org/isf/exam/rest/ExamControllerTest.java b/src/test/java/org/isf/exam/rest/ExamControllerTest.java index c0559f2e9..117d4627a 100644 --- a/src/test/java/org/isf/exam/rest/ExamControllerTest.java +++ b/src/test/java/org/isf/exam/rest/ExamControllerTest.java @@ -144,7 +144,7 @@ class UpdateExamTests { @Test @DisplayName("Should update an exam with associated examrows") - @WithMockUser(username = "admin", authorities = { "exams.update", "examrows.create", "examrows.delete" }) + @WithMockUser(username = "admin", authorities = { "exams.create", "exams.update", "examrows.create", "examrows.delete" }) void shouldUpdateExamWithRows() throws Exception { ExamWithRowsDTO payload = ExamHelper.generateExamWithRowsDTO(); Exam exam = examMapper.map2Model(payload.exam()); @@ -166,7 +166,7 @@ void shouldUpdateExamWithRows() throws Exception { @Test @DisplayName("Should fail to update exam procedure 1 with rows when default result doesn't match") - @WithMockUser(username = "admin", authorities = { "exams.update", "examrows.create", "examrows.delete" }) + @WithMockUser(username = "admin", authorities = { "exams.create", "exams.update", "examrows.create", "examrows.delete" }) void shouldFailToUpdateExamWithInvalidDefaultResult() throws Exception { ExamDTO examDTO = ExamHelper.generateExam(); examDTO.setDefaultResult("IRES"); @@ -189,7 +189,7 @@ void shouldFailToUpdateExamWithInvalidDefaultResult() throws Exception { @Test @DisplayName("Should fail to update exam code in body doesn't match") - @WithMockUser(username = "admin", authorities = { "exams.update", "examrows.create", "examrows.delete" }) + @WithMockUser(username = "admin", authorities = { "exams.create", "exams.update", "examrows.create", "examrows.delete" }) void shouldFailToUpdateExamWhenCodeInBodyDoesntMatch() throws Exception { var result = mvc.perform( put("/exams/{code}", "DD").contentType(MediaType.APPLICATION_JSON)