João Luiz Vieira
11/09/2022, 10:29 PMau.com.dius.pact.provider:spring:4.3.16
). A have a few tests working, but when I try to test a controller that has a Pageable
as a parameter, I get.
1.1) Request processing failed; nested exception is java.lang.IllegalStateException: No primary or single unique constructor found for interface org.springframework.data.domain.Pageable
I am already using the messageConverters
of the MockMvcTarget
but I could not find an argument resolver of sorts. One solution would be to break down the pageable in the values, but I was trying to avoid that. Any ideas on how to fix this error with pageable as a parameter? (code in the first comments of the thread)João Luiz Vieira
11/09/2022, 10:30 PM@GetMapping("/integrations-config/search")
public CollectionModel<?> search(@RequestParam String param1,
@RequestParam String param2,
Pageable pageable) {
return //some logic
}
João Luiz Vieira
11/09/2022, 10:31 PM@RunWith(SpringRestPactRunner.class)
@Provider("my-service")
@PactBroker(url = "<https://pact-brokers.tools.mydomain.com>")
@PactFilter(value = "^\\/integrations-config\\/.*", filter = InteractionFilter.ByRequestPath.class)
public class SampleControllerProviderContractTest {
@TestTarget
public final MockMvcTarget target = new MockMvcTarget();
@Mock
private IntegrationConfigService integrationConfigService;
@Mock
private IntegrationConfigRepository integrationConfigRepository;
@InjectMocks
private IntegrationConfigController integrationConfigController = new IntegrationConfigController(integrationConfigRepository);
@Before
public void before() {
MockitoAnnotations.initMocks(this);
target.setControllers(integrationConfigController);
}
@State("my state")
public void stateForX() {
//my mocks
}
}
João Luiz Vieira
12/21/2022, 8:09 PM