diff --git a/src/main/java/it/pagopa/selfcare/pagopa/controller/BrokerController.java b/src/main/java/it/pagopa/selfcare/pagopa/controller/BrokerController.java index c0ba0c7..3a10bcd 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/controller/BrokerController.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/controller/BrokerController.java @@ -12,6 +12,7 @@ import it.pagopa.selfcare.pagopa.model.ProblemJson; import it.pagopa.selfcare.pagopa.service.BrokersService; import it.pagopa.selfcare.pagopa.util.OpenApiTableMetadata; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -32,11 +33,11 @@ public class BrokerController { private final BrokersService brokersService; + @Autowired public BrokerController(BrokersService brokersService) { this.brokersService = brokersService; } - /** * Retreive a paged list of broker related ibans * @param limit number of elements per page diff --git a/src/test/java/it/pagopa/selfcare/pagopa/controller/BrokerControllerTest.java b/src/test/java/it/pagopa/selfcare/pagopa/controller/BrokerControllerTest.java index 4788240..dad6f56 100644 --- a/src/test/java/it/pagopa/selfcare/pagopa/controller/BrokerControllerTest.java +++ b/src/test/java/it/pagopa/selfcare/pagopa/controller/BrokerControllerTest.java @@ -24,6 +24,8 @@ @AutoConfigureMockMvc class BrokerControllerTest { + private static final String PAGE = "page"; + @Autowired private MockMvc mvc; @@ -43,7 +45,9 @@ void setUp() { @Test void exportCreditorInstitutionsWithValidCodeShouldReturn20XAndData() throws Exception { String url = "/brokers/11111/creditor_institutions"; - mvc.perform(get(url).contentType(MediaType.APPLICATION_JSON)) + mvc.perform(get(url) + .param(PAGE, "0") + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType("application/json")); verify(brokersService).getBrokerInstitutions("11111",10,0); @@ -52,7 +56,9 @@ void exportCreditorInstitutionsWithValidCodeShouldReturn20XAndData() throws Exce @Test void exportCreditorInstitutionsWithMissingCodeShouldReturnNotFound() throws Exception { String url = "/brokers/00000/creditor_institutions"; - mvc.perform(get(url).contentType(MediaType.APPLICATION_JSON)) + mvc.perform(get(url) + .param(PAGE, "0") + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isNotFound()) .andExpect(content().contentType("application/json")); verify(brokersService).getBrokerInstitutions("00000",10,0); @@ -61,7 +67,9 @@ void exportCreditorInstitutionsWithMissingCodeShouldReturnNotFound() throws Exce @Test void getBrokerIbansShouldReturn20XAndData() throws Exception { String url = "/brokers/ibans"; - mvc.perform(get(url).contentType(MediaType.APPLICATION_JSON)) + mvc.perform(get(url) + .param(PAGE, "0") + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType("application/json")); verify(brokersService).getBrokersIbans(10,0);