Gonzalo Granizo
04/11/2023, 10:24 AM<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>Matt (pactflow.io / pact-js / pact-go)
Gonzalo Granizo
04/11/2023, 10:34 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Gonzalo Granizo
04/11/2023, 10:55 AM@State("get allowed payment methods")Gonzalo Granizo
04/11/2023, 10:57 AMpactbroker:
url: <https://adidascdc.pactflow.io>
auth:
token: ${PACT_AUTH_TOKEN:w6thoBsoU05quJd_sLJNLw}Matt (pactflow.io / pact-js / pact-go)
this used to find the pact
This is just the state annotation.Copy code@State("get allowed payment methods")
Matt (pactflow.io / pact-js / pact-go)
Gonzalo Granizo
04/11/2023, 11:09 AMpackage 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));
}
}Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Gonzalo Granizo
04/11/2023, 11:37 AMGonzalo Granizo
04/11/2023, 11:38 AMGonzalo Granizo
04/11/2023, 11:39 AMjava.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 nullMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Gonzalo Granizo
04/11/2023, 11:50 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
pss-api in the logsGonzalo Granizo
04/11/2023, 12:03 PM