Hi all! Im having an issue with pact integration t...
# general
g
Hi all! Im having an issue with pact integration that i wasn't having before, suddenly this error appeared and configuration on provider test seems correct so i don't know why its not getting the pact from pactflow
<http://au.com|au.com>.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify
Provider: pss-paymentMethod-api
Source: Pact Broker <https://adidascdc.pactflow.io>
m
What selectors are you using?
g
what do you mean by selectors? 😅
m
Can you please share your provider code setup? That will help
(selectors TL;DR - they tell the broker which pacts to find and verify)
g
this used to find the pact
Copy code
@State("get allowed payment methods")
and for pactbroker im only using this
Copy code
pactbroker:
  url: <https://adidascdc.pactflow.io>
  auth:
    token: ${PACT_AUTH_TOKEN:w6thoBsoU05quJd_sLJNLw}
m
this used to find the pact
Copy code
@State("get allowed payment methods")
This is just the state annotation.
can you please share the wider java class?
g
Copy code
package com.adidas.pays.orchestration.service.rest.pact;

import static org.mockito.ArgumentMatchers.any;

import au.com.dius.pact.provider.junit5.PactVerificationContext;
import au.com.dius.pact.provider.junitsupport.Provider;
import au.com.dius.pact.provider.junitsupport.State;
import au.com.dius.pact.provider.junitsupport.loader.PactBroker;
import au.com.dius.pact.provider.spring.junit5.PactVerificationSpringProvider;
import au.com.dius.pact.provider.spring.junit5.WebTestClientTarget;
import lombok.SneakyThrows;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.util.ResourceUtils;
import org.springframework.validation.beanvalidation.SpringValidatorAdapter;
import reactor.core.publisher.Mono;

import com.adidas.pays.orchestration.service.dto.response.checkout.regular.AllowedPaymentMethodsResponse;
import com.adidas.pays.orchestration.service.rest.PaymentOrderController;

@Provider("pss-paymentMethod-api")
@PactBroker
class PaymentOrderControllerVerifyPactTest extends AbstractVerifyPactTest {

  @Autowired
  PaymentOrderController paymentOrderController;

  @Override
  @BeforeEach
  protected void beforeEach(PactVerificationContext context) {
    super.beforeEach(context);
    client = WebTestClient.bindToController(paymentOrderController)
        .controllerAdvice(exceptionAdvice)
        .validator(new SpringValidatorAdapter(validator))
        .build();
    context.setTarget(new WebTestClientTarget(client));
  }

  @TestTemplate
  @ExtendWith(PactVerificationSpringProvider.class)
  void verifyPact(PactVerificationContext context) {
    context.verifyInteraction();
  }

  @State("get allowed payment methods")
  void getAllowedPaymentMethods() {
    Mockito.when(allowedPaymentMethodsService.allowedPaymentMethods(any()))
        .thenReturn(buildAllowedPaymentMethods());
  }

  @SneakyThrows
  private Mono<AllowedPaymentMethodsResponse> buildAllowedPaymentMethods() {
    return Mono.just(objectMapper.readValue(
        ResourceUtils.getFile("classpath:pacts/allowed-payment-methods-response.json"),
        AllowedPaymentMethodsResponse.class));
  }

}
m
hmm
looks like you’re using the default selectors - that’s probably OK but not ideal
ignoring that for now, could you please set the log levels to debug, and share the output here? (please redact any important info)
g
2023-04-11 133418.758 DEBUG [orchestration-service, ] 80318 --- [ main] h.i.i.PoolingHttpClientConnectionManager : ep-0000000003 connection released [route: {s}->https://adidascdc.pactflow.io:443][total available: 1; route allocated: 1 of 5; total allocated: 1 of 25]
could this mean that there's 1 pact available?
i also tried putting tag @IgnoreNoPactsToVerify and i get this:
java.lang.NullPointerException: Cannot invoke "<http://au.com|au.com>.dius.pact.provider.junit5.PactVerificationContext.setTarget(<http://au.com|au.com>.dius.pact.provider.junit5.TestTarget)" because "context" is null
m
mmm, not sure about that last exception sorry - that might be a question for #C9UN99H24
as for the logs, that doesn’t seem like a problem - any chance you could get the entire test run log?
g
this is the full log
m
thanks, but i’ve just deleted it, as you didn’t redact the token
(I have a copy locally, but please be careful going forward)
Are you sure that’s the right log? I’m seeing a request for
pss-api
in the logs
g
thanks for your help Matt! we created a new pact in pactflow with a tag and now specifying the tag in the provider its working 🙂
👍 1