Search in sources :

Example 1 with PactVerifyProvider

use of au.com.dius.pact.provider.PactVerifyProvider in project customer-service by wenqiglantz.

the class CustomerEventsPublishPactVerificationTest method publishCustomerWasDeleted.

@PactVerifyProvider("valid CustomerWasDeleted from provider")
public String publishCustomerWasDeleted() throws Exception {
    String customerId = "595eed0c-eff5-4278-90ad-b952f18dbee8";
    CustomerWasDeleted event = CustomerWasDeleted.builder().customerId(customerId).status(CustomerStatus.DELETED).build();
    context.checking(new Expectations() {

        {
            oneOf(customerService).deleteCustomer(customerId);
        }
    });
    customerService.deleteCustomer(customerId);
    String eventString = objectMapper.writeValueAsString(event);
    return eventString;
}
Also used : Expectations(org.jmock.Expectations) CustomerWasDeleted(com.github.wenqiglantz.service.customerservice.data.event.CustomerWasDeleted) PactVerifyProvider(au.com.dius.pact.provider.PactVerifyProvider)

Example 2 with PactVerifyProvider

use of au.com.dius.pact.provider.PactVerifyProvider in project customer-service by wenqiglantz.

the class CustomerEventsPublishPactVerificationTest method publishCustomerWasUpdated.

@PactVerifyProvider("valid CustomerWasUpdated from provider")
public String publishCustomerWasUpdated() throws Exception {
    CustomerInfo customerInfo = CustomerInfo.builder().customerId("595eed0c-eff5-4278-90ad-b952f18dbee8").firstName("test123").lastName("last").build();
    CustomerWasUpdated event = CustomerWasUpdated.builder().customerId("595eed0c-eff5-4278-90ad-b952f18dbee8").firstName("test123").lastName("last").status(CustomerStatus.UPDATED).build();
    context.checking(new Expectations() {

        {
            oneOf(customerService).updateCustomer(customerInfo.getCustomerId(), customerInfo);
        }
    });
    customerService.updateCustomer(customerInfo.getCustomerId(), customerInfo);
    String eventString = objectMapper.writeValueAsString(event);
    return eventString;
}
Also used : Expectations(org.jmock.Expectations) CustomerInfo(com.github.wenqiglantz.service.customerservice.data.CustomerInfo) CustomerWasUpdated(com.github.wenqiglantz.service.customerservice.data.event.CustomerWasUpdated) PactVerifyProvider(au.com.dius.pact.provider.PactVerifyProvider)

Example 3 with PactVerifyProvider

use of au.com.dius.pact.provider.PactVerifyProvider in project EcommerceApp by teixeira-fernando.

the class CreateShipmentProviderPact method verifyMessageForOrderJson.

@PactVerifyProvider("Order in Json format")
public String verifyMessageForOrderJson() {
    try {
        String id = "1";
        String productName = "Samsung TV Led";
        Integer quantity = 50;
        Category category = Category.ELECTRONICS;
        Order order = new Order("1", new ArrayList<>());
        order.getProducts().add(new Product(id, productName, quantity, category));
        String body = mapper.writeValueAsString(order);
        return body;
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : Order(com.ecommerceapp.shop.model.Order) Category(com.ecommerceapp.inventory.model.Category) Product(com.ecommerceapp.inventory.model.Product) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) PactVerifyProvider(au.com.dius.pact.provider.PactVerifyProvider)

Example 4 with PactVerifyProvider

use of au.com.dius.pact.provider.PactVerifyProvider in project pay-connector by alphagov.

the class QueueMessageContractTest method verifyUserEmailCollectedEvent.

@PactVerifyProvider("a user email collected message")
public String verifyUserEmailCollectedEvent() throws JsonProcessingException {
    ChargeEntity charge = aValidChargeEntity().withEmail("test@example.org").build();
    UserEmailCollected userEmailCollected = new UserEmailCollected(charge.getServiceId(), charge.getGatewayAccount().isLive(), resourceId, UserEmailCollectedEventDetails.from(charge), ZonedDateTime.now());
    return userEmailCollected.toJsonString();
}
Also used : ChargeEntityFixture.aValidChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity) ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) UserEmailCollected(uk.gov.pay.connector.events.model.charge.UserEmailCollected) PactVerifyProvider(au.com.dius.pact.provider.PactVerifyProvider)

Example 5 with PactVerifyProvider

use of au.com.dius.pact.provider.PactVerifyProvider in project pay-connector by alphagov.

the class QueueMessageContractTest method verifyRefundedEvent.

@PactVerifyProvider("a refund succeeded message")
public String verifyRefundedEvent() throws JsonProcessingException {
    String gatewayTransactionId = RandomStringUtils.randomAlphanumeric(14);
    ChargeEntity chargeEntity = aValidChargeEntity().build();
    Charge charge = Charge.from(chargeEntity);
    RefundHistory refundHistory = aValidRefundHistoryEntity().withStatus(RefundStatus.REFUNDED.getValue()).withGatewayTransactionId(gatewayTransactionId).build();
    RefundSucceeded refundSucceeded = RefundSucceeded.from(charge, refundHistory);
    return refundSucceeded.toJsonString();
}
Also used : ChargeEntityFixture.aValidChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity) ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) Charge(uk.gov.pay.connector.charge.model.domain.Charge) RefundSucceeded(uk.gov.pay.connector.events.model.refund.RefundSucceeded) RefundHistory(uk.gov.pay.connector.refund.model.domain.RefundHistory) PactVerifyProvider(au.com.dius.pact.provider.PactVerifyProvider)

Aggregations

PactVerifyProvider (au.com.dius.pact.provider.PactVerifyProvider)22 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)12 ChargeEntityFixture.aValidChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity)12 ChargeEventEntity (uk.gov.pay.connector.chargeevent.model.domain.ChargeEventEntity)5 ChargeEventEntityFixture.aValidChargeEventEntity (uk.gov.pay.connector.pact.ChargeEventEntityFixture.aValidChargeEventEntity)5 StripePayout (uk.gov.pay.connector.gateway.stripe.json.StripePayout)4 Expectations (org.jmock.Expectations)3 Charge (uk.gov.pay.connector.charge.model.domain.Charge)3 RefundHistory (uk.gov.pay.connector.refund.model.domain.RefundHistory)3 CustomerInfo (com.github.wenqiglantz.service.customerservice.data.CustomerInfo)2 ExternalMetadata (uk.gov.service.payments.commons.model.charge.ExternalMetadata)2 Category (com.ecommerceapp.inventory.model.Category)1 Product (com.ecommerceapp.inventory.model.Product)1 Order (com.ecommerceapp.shop.model.Order)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 CustomerWasCreated (com.github.wenqiglantz.service.customerservice.data.event.CustomerWasCreated)1 CustomerWasDeleted (com.github.wenqiglantz.service.customerservice.data.event.CustomerWasDeleted)1 CustomerWasUpdated (com.github.wenqiglantz.service.customerservice.data.event.CustomerWasUpdated)1 DisputeCreatedEventDetails (uk.gov.pay.connector.events.eventdetails.dispute.DisputeCreatedEventDetails)1 CancelledByUser (uk.gov.pay.connector.events.model.charge.CancelledByUser)1