From e39f2d587ee67d386c72a066b1e011597d220aaa Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Mon, 13 Jan 2025 18:00:08 +0100 Subject: [PATCH] updated code --- .../controller/TaxonomyControllerTest.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java b/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java index 1458e71..0922bf5 100644 --- a/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java +++ b/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java @@ -9,7 +9,6 @@ import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -17,7 +16,6 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.data.domain.Sort; -import org.springframework.data.domain.Sort.Order; import org.springframework.http.MediaType; import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; @@ -27,32 +25,32 @@ }) @AutoConfigureMockMvc(addFilters = false) class TaxonomyControllerTest { + @Autowired private MockMvc mockMvc; + @MockitoBean private TaxonomyService taxonomyServiceMock; - @InjectMocks - private TaxonomyController taxonomyController; @Test - void getDistinctOrgType () throws Exception { - List orgTypes = new ArrayList(); - orgTypes.add(0, new DistinctOrganizationTypeDTO() { + void getDistinctOrgType() throws Exception { + List orgTypes = new ArrayList<>(); + orgTypes.add(new DistinctOrganizationTypeDTO() { @Override - public String getOrganizationType () { + public String getOrganizationType() { return "test"; } @Override - public String getOrganizationTypeDescription () { + public String getOrganizationTypeDescription() { return "test"; } }); - Mockito.when(taxonomyServiceMock.getDistinctOrganizationType(Sort.by(Order.asc("organizationType")))).thenReturn(orgTypes); + Mockito.when(taxonomyServiceMock.getDistinctOrganizationType(Sort.by(Sort.Order.asc("organizationType")))).thenReturn(orgTypes); mockMvc.perform(get("/taxonomy/custom/getDistinctOrganizationType") - .param("sort","organizationType,ASC") + .param("sort", "organizationType,ASC") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON))