From 0a15fc0fc595b7e06fe69f7e5e5b08eb39a44389 Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Tue, 19 Aug 2025 11:08:05 +0200 Subject: [PATCH 01/15] [CC-2673] Add wero method. - fix authorize method trying to create payment method twice. --- src/main/java/com/unzer/payment/Unzer.java | 23 ++++++-- .../payment/paymenttypes/PaymentTypeEnum.java | 1 + .../com/unzer/payment/paymenttypes/Wero.java | 24 +++++++++ .../unzer/payment/service/PaymentService.java | 6 ++- .../integration/paymenttypes/WeroTest.java | 53 +++++++++++++++++++ 5 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/unzer/payment/paymenttypes/Wero.java create mode 100644 src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java diff --git a/src/main/java/com/unzer/payment/Unzer.java b/src/main/java/com/unzer/payment/Unzer.java index dde1a8c5..866fabef 100644 --- a/src/main/java/com/unzer/payment/Unzer.java +++ b/src/main/java/com/unzer/payment/Unzer.java @@ -9,12 +9,20 @@ import com.unzer.payment.marketplace.MarketplaceCancel; import com.unzer.payment.marketplace.MarketplaceCharge; import com.unzer.payment.marketplace.MarketplacePayment; -import com.unzer.payment.models.*; +import com.unzer.payment.models.AdditionalTransactionData; +import com.unzer.payment.models.CardTransactionData; +import com.unzer.payment.models.CustomerType; +import com.unzer.payment.models.PaylaterInvoiceConfig; +import com.unzer.payment.models.PaylaterInvoiceConfigRequest; import com.unzer.payment.models.paylater.InstallmentPlansRequest; import com.unzer.payment.paymenttypes.PaylaterInstallment; import com.unzer.payment.paymenttypes.PaymentType; import com.unzer.payment.resources.PaypageV2; -import com.unzer.payment.service.*; +import com.unzer.payment.service.LinkpayService; +import com.unzer.payment.service.PaymentService; +import com.unzer.payment.service.PaypageService; +import com.unzer.payment.service.TokenService; +import com.unzer.payment.service.WebhookService; import com.unzer.payment.service.marketplace.MarketplacePaymentService; import com.unzer.payment.util.JwtHelper; import com.unzer.payment.webhook.Webhook; @@ -23,7 +31,11 @@ import java.math.BigDecimal; import java.net.URL; -import java.util.*; +import java.util.Currency; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.Objects; /** * {@code Unzer} is a facade to the Unzer REST Api. The facade is @@ -368,7 +380,10 @@ public Authorization authorize(BigDecimal amount, Currency currency, PaymentType URL returnUrl, Customer customer, Boolean card3ds) throws HttpCommunicationException { - return authorize(amount, currency, createPaymentType(paymentType).getId(), returnUrl, + if (paymentType.getId() == null) { + paymentType = createPaymentType(paymentType); + } + return authorize(amount, currency, paymentType.getId(), returnUrl, getCustomerId(createCustomerIfPresent(customer)), card3ds); } diff --git a/src/main/java/com/unzer/payment/paymenttypes/PaymentTypeEnum.java b/src/main/java/com/unzer/payment/paymenttypes/PaymentTypeEnum.java index f467112e..641eaf86 100644 --- a/src/main/java/com/unzer/payment/paymenttypes/PaymentTypeEnum.java +++ b/src/main/java/com/unzer/payment/paymenttypes/PaymentTypeEnum.java @@ -42,6 +42,7 @@ public enum PaymentTypeEnum { PAYLATER_DIRECT_DEBIT("pdd"), TWINT("twt"), OPEN_BANKING("obp"), + WERO("wro"), UNKNOWN("unknown"); private final String shortName; diff --git a/src/main/java/com/unzer/payment/paymenttypes/Wero.java b/src/main/java/com/unzer/payment/paymenttypes/Wero.java new file mode 100644 index 00000000..497f2144 --- /dev/null +++ b/src/main/java/com/unzer/payment/paymenttypes/Wero.java @@ -0,0 +1,24 @@ +package com.unzer.payment.paymenttypes; + +import com.unzer.payment.GeoLocation; +import com.unzer.payment.communication.json.ApiIdObject; +import com.unzer.payment.communication.json.ApiObject; + +public class Wero extends BasePaymentType { + + @Override + public String getResourceUrl() { + return "/v1/types/wero/"; + } + + @Override + public PaymentType map(PaymentType wero, ApiObject jsonId) { + ((Wero) wero).setId(jsonId.getId()); + ((Wero) wero).setRecurring(((ApiIdObject) jsonId).getRecurring()); + GeoLocation tempGeoLocation = + new GeoLocation(((ApiIdObject) jsonId).getGeoLocation().getClientIp(), + ((ApiIdObject) jsonId).getGeoLocation().getCountryIsoA2()); + ((Wero) wero).setGeoLocation(tempGeoLocation); + return wero; + } +} diff --git a/src/main/java/com/unzer/payment/service/PaymentService.java b/src/main/java/com/unzer/payment/service/PaymentService.java index 29f64956..078743b9 100644 --- a/src/main/java/com/unzer/payment/service/PaymentService.java +++ b/src/main/java/com/unzer/payment/service/PaymentService.java @@ -87,6 +87,7 @@ import com.unzer.payment.paymenttypes.Sofort; import com.unzer.payment.paymenttypes.Twint; import com.unzer.payment.paymenttypes.Wechatpay; +import com.unzer.payment.paymenttypes.Wero; import java.math.BigDecimal; import java.net.URL; @@ -254,6 +255,8 @@ private PaymentType getPaymentTypeFromTypeId(String typeId) { return new Twint(); case OPEN_BANKING: return new OpenBanking(); + case WERO: + return new Wero(); default: throw new PaymentException("Type '" + typeId + "' is currently not supported by the SDK"); } @@ -281,6 +284,7 @@ private ApiIdObject getJsonObjectFromTypeId(String typeId) { case KLARNA: case CLICK_TO_PAY: case TWINT: + case WERO: return new ApiIdObject(); case PAYPAL: return new ApiPaypal(); @@ -953,7 +957,7 @@ protected enum TransactionType { AUTHORIZE, PREAUTHORIZE, CHARGE, CHARGEBACK, PAYOUT, CANCEL_AUTHORIZE, CANCEL_CHARGE; public String apiName() { - return this.name().toLowerCase().replaceAll("_", "-"); + return this.name().toLowerCase().replace("_", "-"); } } } \ No newline at end of file diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java new file mode 100644 index 00000000..cdfa7214 --- /dev/null +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java @@ -0,0 +1,53 @@ +package com.unzer.payment.integration.paymenttypes; + +import com.unzer.payment.Authorization; +import com.unzer.payment.Charge; +import com.unzer.payment.business.AbstractPaymentTest; +import com.unzer.payment.paymenttypes.Wero; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; +import java.net.URL; +import java.util.Currency; + +import static com.unzer.payment.util.Types.unsafeUrl; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class WeroTest extends AbstractPaymentTest { + + @Test + void testCreateWeroType() { + Wero wero = new Wero(); + wero = getUnzer().createPaymentType(wero); + assertNotNull(wero.getId()); + } + + @Test + void testFetchWeroType() { + Wero wero = getUnzer().createPaymentType(new Wero()); + assertNotNull(wero.getId()); + Wero fetched = (Wero) getUnzer().fetchPaymentType(wero.getId()); + assertNotNull(fetched.getId()); + assertNotNull(fetched.getGeoLocation()); + } + + @Test + void testChargeWeroType() { + Wero wero = getUnzer().createPaymentType(new Wero()); + URL returnUrl = unsafeUrl("https://www.unzer.com"); + Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), wero, returnUrl); + assertNotNull(charge); + assertNotNull(charge.getId()); + assertNotNull(charge.getRedirectUrl()); + } + + @Test + void testAuthorizeWeroType() { + Wero wero = getUnzer().createPaymentType(new Wero()); + URL returnUrl = unsafeUrl("https://www.unzer.com"); + Authorization authorization = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), wero, returnUrl); + assertNotNull(authorization); + assertNotNull(authorization.getId()); + assertNotNull(authorization.getRedirectUrl()); + } +} From 1079b69b339832c2c73875faa2f1c9efddcd6432 Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Wed, 20 Aug 2025 10:51:09 +0200 Subject: [PATCH 02/15] [CC-2673] Add wero method. --- .../models/AdditionalTransactionData.java | 41 ++-------- .../payment/models/WeroTransactionData.java | 60 ++++++++++++++ .../models/paypage/PaymentMethodConfig.java | 3 + .../unzer/payment/resources/PaypageV2.java | 11 ++- .../AdditionalTransactionDataWeroTest.java | 80 +++++++++++++++++++ .../integration/paymenttypes/WeroTest.java | 60 ++++++++++++++ .../integration/resources/PaypageV2Test.java | 47 ++++++++++- 7 files changed, 264 insertions(+), 38 deletions(-) create mode 100644 src/main/java/com/unzer/payment/models/WeroTransactionData.java create mode 100644 src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java diff --git a/src/main/java/com/unzer/payment/models/AdditionalTransactionData.java b/src/main/java/com/unzer/payment/models/AdditionalTransactionData.java index 24ffb9a5..007ee4f8 100644 --- a/src/main/java/com/unzer/payment/models/AdditionalTransactionData.java +++ b/src/main/java/com/unzer/payment/models/AdditionalTransactionData.java @@ -2,9 +2,11 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; +import lombok.Data; import java.util.Objects; +@Data @JsonTypeName("additionalTransactionDataModel") @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME) public class AdditionalTransactionData { @@ -12,6 +14,7 @@ public class AdditionalTransactionData { private ShippingTransactionData shipping; private RiskData riskData; private PaypalData paypal; + private WeroTransactionData wero; /** * URL to the merchant's Terms and Conditions Page @@ -23,32 +26,7 @@ public class AdditionalTransactionData { */ private String privacyPolicyUrl; - public CardTransactionData getCard() { - return card; - } - - public AdditionalTransactionData setCard(CardTransactionData card) { - this.card = card; - return this; - } - - public ShippingTransactionData getShipping() { - return shipping; - } - - public AdditionalTransactionData setShipping(ShippingTransactionData shipping) { - this.shipping = shipping; - return this; - } - - public RiskData getRiskData() { - return riskData; - } - public AdditionalTransactionData setRiskData(RiskData riskData) { - this.riskData = riskData; - return this; - } /** * URL to the merchant's Terms and Conditions Page @@ -80,15 +58,6 @@ public AdditionalTransactionData setPrivacyPolicyUrl(String privacyPolicyUrl) { return this; } - public PaypalData getPaypal() { - return paypal; - } - - public AdditionalTransactionData setPaypal(PaypalData paypal) { - this.paypal = paypal; - return this; - } - @Override public boolean equals(Object o) { if (this == o) { @@ -112,6 +81,9 @@ public boolean equals(Object o) { if (!Objects.equals(paypal, that.paypal)) { return false; } + if (!Objects.equals(wero, that.wero)) { + return false; + } if (!Objects.equals(termsAndConditionUrl, that.termsAndConditionUrl)) { return false; } @@ -124,6 +96,7 @@ public int hashCode() { result = 31 * result + (shipping != null ? shipping.hashCode() : 0); result = 31 * result + (riskData != null ? riskData.hashCode() : 0); result = 31 * result + (paypal != null ? paypal.hashCode() : 0); + result = 31 * result + (wero != null ? wero.hashCode() : 0); result = 31 * result + (termsAndConditionUrl != null ? termsAndConditionUrl.hashCode() : 0); result = 31 * result + (privacyPolicyUrl != null ? privacyPolicyUrl.hashCode() : 0); return result; diff --git a/src/main/java/com/unzer/payment/models/WeroTransactionData.java b/src/main/java/com/unzer/payment/models/WeroTransactionData.java new file mode 100644 index 00000000..ef8c09ee --- /dev/null +++ b/src/main/java/com/unzer/payment/models/WeroTransactionData.java @@ -0,0 +1,60 @@ +package com.unzer.payment.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +/** + * Additional transaction data for Wero payments. + * Wrapped under the key "wero" inside additionalTransactionData. + */ +@Data +@JsonTypeName("wero") +@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME) +public class WeroTransactionData { + + private EventDependentPayment eventDependentPayment; + + @Data + public static class EventDependentPayment { + private CaptureTrigger captureTrigger; + private AmountPaymentType amountPaymentType; + /** + * Maximum time from authorization to capture in seconds. + */ + private Integer maxAuthToCaptureTime; + /** + * Whether multiple captures are allowed. + */ + private Boolean multiCapturesAllowed; + } + + public enum CaptureTrigger { + @JsonProperty("shipping") + @SerializedName("shipping") + SHIPPING, + @JsonProperty("delivery") + @SerializedName("delivery") + DELIVERY, + @JsonProperty("availability") + @SerializedName("availability") + AVAILABILITY, + @JsonProperty("servicefulfilment") + @SerializedName("servicefulfilment") + SERVICEFULFILMENT, + @JsonProperty("other") + @SerializedName("other") + OTHER + } + + public enum AmountPaymentType { + @JsonProperty("pay") + @SerializedName("pay") + PAY, + @JsonProperty("payupto") + @SerializedName("payupto") + PAYUPTO + } +} diff --git a/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java b/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java index 8fafb240..21e4b5fb 100644 --- a/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java +++ b/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java @@ -1,5 +1,6 @@ package com.unzer.payment.models.paypage; +import com.unzer.payment.models.WeroTransactionData; import lombok.Data; @Data @@ -13,6 +14,8 @@ public class PaymentMethodConfig { private Boolean credentialOnFile = null; // card only. private String exemption; // card only. + private WeroTransactionData.EventDependentPayment eventDependentPayment; // wero only + public PaymentMethodConfig(boolean enabled, Integer order) { this.enabled = enabled; this.order = order; diff --git a/src/main/java/com/unzer/payment/resources/PaypageV2.java b/src/main/java/com/unzer/payment/resources/PaypageV2.java index 6ab155d2..43de404f 100644 --- a/src/main/java/com/unzer/payment/resources/PaypageV2.java +++ b/src/main/java/com/unzer/payment/resources/PaypageV2.java @@ -5,7 +5,13 @@ import com.unzer.payment.BaseResource; import com.unzer.payment.communication.JsonDateTimeIso8601Converter; import com.unzer.payment.communication.JsonFieldIgnore; -import com.unzer.payment.models.paypage.*; +import com.unzer.payment.models.paypage.AmountSettings; +import com.unzer.payment.models.paypage.PaymentMethodConfig; +import com.unzer.payment.models.paypage.PaypagePayment; +import com.unzer.payment.models.paypage.Resources; +import com.unzer.payment.models.paypage.Risk; +import com.unzer.payment.models.paypage.Style; +import com.unzer.payment.models.paypage.Urls; import lombok.AccessLevel; import lombok.Data; import lombok.NoArgsConstructor; @@ -122,7 +128,8 @@ public enum MethodName { BANCONTACT("bancontact"), PFCARD("pfcard"), PFEFINANCE("pfefinance"), - TWINT("twint"); + TWINT("twint"), + WERO("wero"); private final String name; diff --git a/src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java b/src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java new file mode 100644 index 00000000..a7e2ffd6 --- /dev/null +++ b/src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java @@ -0,0 +1,80 @@ +package com.unzer.payment.business; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.unzer.payment.communication.JsonParser; +import com.unzer.payment.models.AdditionalTransactionData; +import com.unzer.payment.models.WeroTransactionData; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class AdditionalTransactionDataWeroTest { + + @Test + void serializationIncludesWeroDataWithExpectedFieldsAndValues() { + // Arrange + WeroTransactionData.EventDependentPayment edp = new WeroTransactionData.EventDependentPayment() + .setCaptureTrigger(WeroTransactionData.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(WeroTransactionData.AmountPaymentType.PAY) + .setMaxAuthToCaptureTime(300) + .setMultiCapturesAllowed(false); + + WeroTransactionData wero = new WeroTransactionData() + .setEventDependentPayment(edp); + + AdditionalTransactionData atd = new AdditionalTransactionData() + .setWero(wero); + + // Act + String json = new JsonParser().toJson(atd); + + // Assert + JsonObject root = new Gson().fromJson(json, JsonObject.class); + assertNotNull(root, "Root JSON should not be null"); + assertTrue(root.has("wero"), "JSON should contain 'wero' wrapper inside additional transaction data"); + + JsonObject weroObj = root.getAsJsonObject("wero"); + assertNotNull(weroObj, "'wero' object should not be null"); + assertTrue(weroObj.has("eventDependentPayment"), "'wero' should contain 'eventDependentPayment'"); + + JsonObject edpObj = weroObj.getAsJsonObject("eventDependentPayment"); + assertNotNull(edpObj, "'eventDependentPayment' object should not be null"); + + assertEquals("servicefulfilment", edpObj.get("captureTrigger").getAsString()); + assertEquals("pay", edpObj.get("amountPaymentType").getAsString()); + assertEquals(300, edpObj.get("maxAuthToCaptureTime").getAsInt()); + assertFalse(edpObj.get("multiCapturesAllowed").getAsBoolean()); + } + + @Test + void deserializationParsesWeroDataCorrectly() { + // Arrange + String json = "{" + + "\"wero\": {" + + " \"eventDependentPayment\": {" + + " \"captureTrigger\": \"servicefulfilment\"," + + " \"amountPaymentType\": \"pay\"," + + " \"maxAuthToCaptureTime\": 300," + + " \"multiCapturesAllowed\": false" + + " }" + + "}" + + "}"; + + // Act + AdditionalTransactionData atd = new JsonParser().fromJson(json, AdditionalTransactionData.class); + + // Assert + assertNotNull(atd); + assertNotNull(atd.getWero()); + assertNotNull(atd.getWero().getEventDependentPayment()); + WeroTransactionData.EventDependentPayment edp = atd.getWero().getEventDependentPayment(); + assertEquals(WeroTransactionData.CaptureTrigger.SERVICEFULFILMENT, edp.getCaptureTrigger()); + assertEquals(WeroTransactionData.AmountPaymentType.PAY, edp.getAmountPaymentType()); + assertEquals(300, edp.getMaxAuthToCaptureTime()); + assertFalse(edp.getMultiCapturesAllowed()); + } +} diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java index cdfa7214..0836c91c 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java @@ -3,6 +3,8 @@ import com.unzer.payment.Authorization; import com.unzer.payment.Charge; import com.unzer.payment.business.AbstractPaymentTest; +import com.unzer.payment.models.AdditionalTransactionData; +import com.unzer.payment.models.WeroTransactionData; import com.unzer.payment.paymenttypes.Wero; import org.junit.jupiter.api.Test; @@ -50,4 +52,62 @@ void testAuthorizeWeroType() { assertNotNull(authorization.getId()); assertNotNull(authorization.getRedirectUrl()); } + + @Test + void testChargeWeroTypeWithAdditionalTransactionData() { + // Create Wero type + Wero wero = getUnzer().createPaymentType(new Wero()); + URL returnUrl = unsafeUrl("https://www.unzer.com"); + + // Build Wero additional transaction data + WeroTransactionData.EventDependentPayment edp = new WeroTransactionData.EventDependentPayment() + .setCaptureTrigger(WeroTransactionData.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(WeroTransactionData.AmountPaymentType.PAY) + .setMaxAuthToCaptureTime(600) + .setMultiCapturesAllowed(true); + AdditionalTransactionData atd = new AdditionalTransactionData() + .setWero(new WeroTransactionData().setEventDependentPayment(edp)); + + // Build the charge request explicitly to attach additional transaction data + Charge request = new Charge(); + request.setAmount(BigDecimal.ONE); + request.setCurrency(Currency.getInstance("EUR")); + request.setTypeId(wero.getId()); + request.setReturnUrl(returnUrl); + request.setAdditionalTransactionData(atd); + + Charge charge = getUnzer().charge(request); + assertNotNull(charge); + assertNotNull(charge.getId()); + assertNotNull(charge.getRedirectUrl()); + } + + @Test + void testAuthorizeWeroTypeWithAdditionalTransactionData() { + // Create Wero type + Wero wero = getUnzer().createPaymentType(new Wero()); + URL returnUrl = unsafeUrl("https://www.unzer.com"); + + // Build Wero additional transaction data + WeroTransactionData.EventDependentPayment edp = new WeroTransactionData.EventDependentPayment() + .setCaptureTrigger(WeroTransactionData.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(WeroTransactionData.AmountPaymentType.PAYUPTO) + .setMaxAuthToCaptureTime(300) + .setMultiCapturesAllowed(false); + AdditionalTransactionData atd = new AdditionalTransactionData() + .setWero(new WeroTransactionData().setEventDependentPayment(edp)); + + // Build the authorization request explicitly to attach additional transaction data + Authorization request = new Authorization(); + request.setAmount(BigDecimal.ONE); + request.setCurrency(Currency.getInstance("EUR")); + request.setTypeId(wero.getId()); + request.setReturnUrl(returnUrl); + request.setAdditionalTransactionData(atd); + + Authorization authorization = getUnzer().authorize(request); + assertNotNull(authorization); + assertNotNull(authorization.getId()); + assertNotNull(authorization.getRedirectUrl()); + } } diff --git a/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java b/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java index 3010a64e..08fc7ed5 100644 --- a/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java +++ b/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java @@ -6,7 +6,13 @@ import com.unzer.payment.business.BasketV2TestData; import com.unzer.payment.models.CardTransactionData; import com.unzer.payment.models.RiskData; -import com.unzer.payment.models.paypage.*; +import com.unzer.payment.models.WeroTransactionData; +import com.unzer.payment.models.paypage.PaymentMethodConfig; +import com.unzer.payment.models.paypage.PaypagePayment; +import com.unzer.payment.models.paypage.Resources; +import com.unzer.payment.models.paypage.Risk; +import com.unzer.payment.models.paypage.Style; +import com.unzer.payment.models.paypage.Urls; import com.unzer.payment.resources.PaypageV2; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -18,7 +24,10 @@ import java.util.HashMap; import java.util.stream.Stream; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; class PaypageV2Test extends BearerAuthBaseTest { @@ -167,6 +176,25 @@ public static Stream getPaymentMethodsConfigs() { PaymentMethodConfig paylaterConfig = (new PaymentMethodConfig(true)) .setLabel("Paylater"); + // Wero configurations with eventDependentPayment + WeroTransactionData.EventDependentPayment weroEventDependent1 = new WeroTransactionData.EventDependentPayment() + .setCaptureTrigger(WeroTransactionData.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(WeroTransactionData.AmountPaymentType.PAY) + .setMaxAuthToCaptureTime(600) + .setMultiCapturesAllowed(true); + + WeroTransactionData.EventDependentPayment weroEventDependent2 = new WeroTransactionData.EventDependentPayment() + .setCaptureTrigger(WeroTransactionData.CaptureTrigger.DELIVERY) + .setAmountPaymentType(WeroTransactionData.AmountPaymentType.PAYUPTO) + .setMaxAuthToCaptureTime(300) + .setMultiCapturesAllowed(false); + + PaymentMethodConfig weroConfig1 = new PaymentMethodConfig(true, 2) + .setEventDependentPayment(weroEventDependent1); + + PaymentMethodConfig weroConfig2 = new PaymentMethodConfig(true) + .setEventDependentPayment(weroEventDependent2); + // Prepare Config Maps HashMap emptyConfig = new HashMap<>(); @@ -181,6 +209,17 @@ public static Stream getPaymentMethodsConfigs() { HashMap withPaylaterConfig = new HashMap<>(); withPaylaterConfig.put("cards", paylaterConfig); + HashMap withWeroConfig1 = new HashMap<>(); + withWeroConfig1.put("wero", weroConfig1); + + HashMap withWeroConfig2 = new HashMap<>(); + withWeroConfig2.put("wero", weroConfig2); + + HashMap withMixedWeroConfig = new HashMap<>(); + withMixedWeroConfig.put("default", disabledConfig); + withMixedWeroConfig.put("cards", enabledConfig); + withMixedWeroConfig.put("wero", weroConfig1); + HashMap withEnumMethodNames = new HashMap<>(); withEnumMethodNames.put(PaypageV2.MethodName.CARDS, enabledConfig); withEnumMethodNames.put(PaypageV2.MethodName.PAYPAL, enabledConfig); @@ -202,6 +241,7 @@ public static Stream getPaymentMethodsConfigs() { withEnumMethodNames.put(PaypageV2.MethodName.PFCARD, enabledConfig); withEnumMethodNames.put(PaypageV2.MethodName.PFEFINANCE, enabledConfig); withEnumMethodNames.put(PaypageV2.MethodName.TWINT, enabledConfig); + withEnumMethodNames.put(PaypageV2.MethodName.WERO, weroConfig1); withEnumMethodNames.put(PaypageV2.MethodName.DEFAULT, enabledConfig); return Stream.of( @@ -211,6 +251,9 @@ public static Stream getPaymentMethodsConfigs() { Arguments.of("Method Configs", withCardConfig), Arguments.of("CardSpecificConfig", withCardConfig), Arguments.of("PaylaterConfig", withPaylaterConfig), + Arguments.of("WeroConfig with ServiceFulfilment", withWeroConfig1), + Arguments.of("WeroConfig with Delivery", withWeroConfig2), + Arguments.of("Mixed Config with Wero", withMixedWeroConfig), Arguments.of("Method name enums", withEnumMethodNames) ); } From d5906ae3258f2b6c04eda55504efa979aeedf1aa Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Wed, 20 Aug 2025 10:55:24 +0200 Subject: [PATCH 03/15] [CC-2673] Add wero method. --- .../payment/models/WeroTransactionData.java | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/src/main/java/com/unzer/payment/models/WeroTransactionData.java b/src/main/java/com/unzer/payment/models/WeroTransactionData.java index ef8c09ee..49ed11e3 100644 --- a/src/main/java/com/unzer/payment/models/WeroTransactionData.java +++ b/src/main/java/com/unzer/payment/models/WeroTransactionData.java @@ -1,9 +1,7 @@ package com.unzer.payment.models; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; -import com.google.gson.annotations.SerializedName; import lombok.Data; /** @@ -14,47 +12,5 @@ @JsonTypeName("wero") @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME) public class WeroTransactionData { - private EventDependentPayment eventDependentPayment; - - @Data - public static class EventDependentPayment { - private CaptureTrigger captureTrigger; - private AmountPaymentType amountPaymentType; - /** - * Maximum time from authorization to capture in seconds. - */ - private Integer maxAuthToCaptureTime; - /** - * Whether multiple captures are allowed. - */ - private Boolean multiCapturesAllowed; - } - - public enum CaptureTrigger { - @JsonProperty("shipping") - @SerializedName("shipping") - SHIPPING, - @JsonProperty("delivery") - @SerializedName("delivery") - DELIVERY, - @JsonProperty("availability") - @SerializedName("availability") - AVAILABILITY, - @JsonProperty("servicefulfilment") - @SerializedName("servicefulfilment") - SERVICEFULFILMENT, - @JsonProperty("other") - @SerializedName("other") - OTHER - } - - public enum AmountPaymentType { - @JsonProperty("pay") - @SerializedName("pay") - PAY, - @JsonProperty("payupto") - @SerializedName("payupto") - PAYUPTO - } } From 5bcc5e71c5e5fa0a290bfd1ecfe6712d10d8d25a Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Wed, 20 Aug 2025 11:12:21 +0200 Subject: [PATCH 04/15] [CC-2673] Add wero method. --- .../models/paypage/PaymentMethodConfig.java | 4 ++-- .../AdditionalTransactionDataWeroTest.java | 13 +++++++------ .../payment/integration/paymenttypes/WeroTest.java | 13 +++++++------ .../integration/resources/PaypageV2Test.java | 14 +++++++------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java b/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java index 21e4b5fb..9742d63a 100644 --- a/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java +++ b/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java @@ -1,6 +1,6 @@ package com.unzer.payment.models.paypage; -import com.unzer.payment.models.WeroTransactionData; +import com.unzer.payment.models.EventDependentPayment; import lombok.Data; @Data @@ -14,7 +14,7 @@ public class PaymentMethodConfig { private Boolean credentialOnFile = null; // card only. private String exemption; // card only. - private WeroTransactionData.EventDependentPayment eventDependentPayment; // wero only + private EventDependentPayment eventDependentPayment; // wero only public PaymentMethodConfig(boolean enabled, Integer order) { this.enabled = enabled; diff --git a/src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java b/src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java index a7e2ffd6..083ab0d2 100644 --- a/src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java +++ b/src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java @@ -4,6 +4,7 @@ import com.google.gson.JsonObject; import com.unzer.payment.communication.JsonParser; import com.unzer.payment.models.AdditionalTransactionData; +import com.unzer.payment.models.EventDependentPayment; import com.unzer.payment.models.WeroTransactionData; import org.junit.jupiter.api.Test; @@ -17,9 +18,9 @@ class AdditionalTransactionDataWeroTest { @Test void serializationIncludesWeroDataWithExpectedFieldsAndValues() { // Arrange - WeroTransactionData.EventDependentPayment edp = new WeroTransactionData.EventDependentPayment() - .setCaptureTrigger(WeroTransactionData.CaptureTrigger.SERVICEFULFILMENT) - .setAmountPaymentType(WeroTransactionData.AmountPaymentType.PAY) + EventDependentPayment edp = new EventDependentPayment() + .setCaptureTrigger(EventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(EventDependentPayment.AmountPaymentType.PAY) .setMaxAuthToCaptureTime(300) .setMultiCapturesAllowed(false); @@ -71,9 +72,9 @@ void deserializationParsesWeroDataCorrectly() { assertNotNull(atd); assertNotNull(atd.getWero()); assertNotNull(atd.getWero().getEventDependentPayment()); - WeroTransactionData.EventDependentPayment edp = atd.getWero().getEventDependentPayment(); - assertEquals(WeroTransactionData.CaptureTrigger.SERVICEFULFILMENT, edp.getCaptureTrigger()); - assertEquals(WeroTransactionData.AmountPaymentType.PAY, edp.getAmountPaymentType()); + EventDependentPayment edp = atd.getWero().getEventDependentPayment(); + assertEquals(EventDependentPayment.CaptureTrigger.SERVICEFULFILMENT, edp.getCaptureTrigger()); + assertEquals(EventDependentPayment.AmountPaymentType.PAY, edp.getAmountPaymentType()); assertEquals(300, edp.getMaxAuthToCaptureTime()); assertFalse(edp.getMultiCapturesAllowed()); } diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java index 0836c91c..376f9718 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java @@ -4,6 +4,7 @@ import com.unzer.payment.Charge; import com.unzer.payment.business.AbstractPaymentTest; import com.unzer.payment.models.AdditionalTransactionData; +import com.unzer.payment.models.EventDependentPayment; import com.unzer.payment.models.WeroTransactionData; import com.unzer.payment.paymenttypes.Wero; import org.junit.jupiter.api.Test; @@ -60,9 +61,9 @@ void testChargeWeroTypeWithAdditionalTransactionData() { URL returnUrl = unsafeUrl("https://www.unzer.com"); // Build Wero additional transaction data - WeroTransactionData.EventDependentPayment edp = new WeroTransactionData.EventDependentPayment() - .setCaptureTrigger(WeroTransactionData.CaptureTrigger.SERVICEFULFILMENT) - .setAmountPaymentType(WeroTransactionData.AmountPaymentType.PAY) + EventDependentPayment edp = new EventDependentPayment() + .setCaptureTrigger(EventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(EventDependentPayment.AmountPaymentType.PAY) .setMaxAuthToCaptureTime(600) .setMultiCapturesAllowed(true); AdditionalTransactionData atd = new AdditionalTransactionData() @@ -89,9 +90,9 @@ void testAuthorizeWeroTypeWithAdditionalTransactionData() { URL returnUrl = unsafeUrl("https://www.unzer.com"); // Build Wero additional transaction data - WeroTransactionData.EventDependentPayment edp = new WeroTransactionData.EventDependentPayment() - .setCaptureTrigger(WeroTransactionData.CaptureTrigger.SERVICEFULFILMENT) - .setAmountPaymentType(WeroTransactionData.AmountPaymentType.PAYUPTO) + EventDependentPayment edp = new EventDependentPayment() + .setCaptureTrigger(EventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(EventDependentPayment.AmountPaymentType.PAYUPTO) .setMaxAuthToCaptureTime(300) .setMultiCapturesAllowed(false); AdditionalTransactionData atd = new AdditionalTransactionData() diff --git a/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java b/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java index 08fc7ed5..5342480f 100644 --- a/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java +++ b/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java @@ -5,8 +5,8 @@ import com.unzer.payment.Metadata; import com.unzer.payment.business.BasketV2TestData; import com.unzer.payment.models.CardTransactionData; +import com.unzer.payment.models.EventDependentPayment; import com.unzer.payment.models.RiskData; -import com.unzer.payment.models.WeroTransactionData; import com.unzer.payment.models.paypage.PaymentMethodConfig; import com.unzer.payment.models.paypage.PaypagePayment; import com.unzer.payment.models.paypage.Resources; @@ -177,15 +177,15 @@ public static Stream getPaymentMethodsConfigs() { .setLabel("Paylater"); // Wero configurations with eventDependentPayment - WeroTransactionData.EventDependentPayment weroEventDependent1 = new WeroTransactionData.EventDependentPayment() - .setCaptureTrigger(WeroTransactionData.CaptureTrigger.SERVICEFULFILMENT) - .setAmountPaymentType(WeroTransactionData.AmountPaymentType.PAY) + EventDependentPayment weroEventDependent1 = new EventDependentPayment() + .setCaptureTrigger(EventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(EventDependentPayment.AmountPaymentType.PAY) .setMaxAuthToCaptureTime(600) .setMultiCapturesAllowed(true); - WeroTransactionData.EventDependentPayment weroEventDependent2 = new WeroTransactionData.EventDependentPayment() - .setCaptureTrigger(WeroTransactionData.CaptureTrigger.DELIVERY) - .setAmountPaymentType(WeroTransactionData.AmountPaymentType.PAYUPTO) + EventDependentPayment weroEventDependent2 = new EventDependentPayment() + .setCaptureTrigger(EventDependentPayment.CaptureTrigger.DELIVERY) + .setAmountPaymentType(EventDependentPayment.AmountPaymentType.PAYUPTO) .setMaxAuthToCaptureTime(300) .setMultiCapturesAllowed(false); From 6fb13d6b1a2fcee0518376d91aaa77dbe017c975 Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Wed, 20 Aug 2025 11:29:03 +0200 Subject: [PATCH 05/15] [CC-2673] Add wero method. --- .../com/unzer/payment/integration/resources/PaypageV2Test.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java b/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java index 5342480f..2111d989 100644 --- a/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java +++ b/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java @@ -21,6 +21,7 @@ import java.math.BigDecimal; import java.util.Date; +import java.util.EnumMap; import java.util.HashMap; import java.util.stream.Stream; @@ -220,7 +221,7 @@ public static Stream getPaymentMethodsConfigs() { withMixedWeroConfig.put("cards", enabledConfig); withMixedWeroConfig.put("wero", weroConfig1); - HashMap withEnumMethodNames = new HashMap<>(); + EnumMap withEnumMethodNames = new EnumMap<>(PaypageV2.MethodName.class); withEnumMethodNames.put(PaypageV2.MethodName.CARDS, enabledConfig); withEnumMethodNames.put(PaypageV2.MethodName.PAYPAL, enabledConfig); withEnumMethodNames.put(PaypageV2.MethodName.PAYLATER_INSTALLMENT, enabledConfig); From d05d0a5dd0dbeb804a4f6f1ff78a4b368a13cdbf Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Wed, 20 Aug 2025 13:59:39 +0200 Subject: [PATCH 06/15] [CC-2673] Add wero method. --- .../com/unzer/payment/integration/resources/PaypageV2Test.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java b/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java index 2111d989..5342480f 100644 --- a/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java +++ b/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java @@ -21,7 +21,6 @@ import java.math.BigDecimal; import java.util.Date; -import java.util.EnumMap; import java.util.HashMap; import java.util.stream.Stream; @@ -221,7 +220,7 @@ public static Stream getPaymentMethodsConfigs() { withMixedWeroConfig.put("cards", enabledConfig); withMixedWeroConfig.put("wero", weroConfig1); - EnumMap withEnumMethodNames = new EnumMap<>(PaypageV2.MethodName.class); + HashMap withEnumMethodNames = new HashMap<>(); withEnumMethodNames.put(PaypageV2.MethodName.CARDS, enabledConfig); withEnumMethodNames.put(PaypageV2.MethodName.PAYPAL, enabledConfig); withEnumMethodNames.put(PaypageV2.MethodName.PAYLATER_INSTALLMENT, enabledConfig); From fb2902cc5b239a3f57db52e1affc8f4687a6178b Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Wed, 20 Aug 2025 14:17:10 +0200 Subject: [PATCH 07/15] [CC-2673] Add wero method. --- .../payment/models/EventDependentPayment.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/java/com/unzer/payment/models/EventDependentPayment.java diff --git a/src/main/java/com/unzer/payment/models/EventDependentPayment.java b/src/main/java/com/unzer/payment/models/EventDependentPayment.java new file mode 100644 index 00000000..840e529d --- /dev/null +++ b/src/main/java/com/unzer/payment/models/EventDependentPayment.java @@ -0,0 +1,41 @@ +package com.unzer.payment.models; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +/** + * Event dependent payment configuration for Wero payments. + */ +@Data +public class EventDependentPayment { + private CaptureTrigger captureTrigger; + private AmountPaymentType amountPaymentType; + /** + * Maximum time from authorization to capture in seconds. + */ + private Integer maxAuthToCaptureTime; + /** + * Whether multiple captures are allowed. + */ + private Boolean multiCapturesAllowed; + + public enum CaptureTrigger { + @SerializedName("shipping") + SHIPPING, + @SerializedName("delivery") + DELIVERY, + @SerializedName("availability") + AVAILABILITY, + @SerializedName("servicefulfilment") + SERVICEFULFILMENT, + @SerializedName("other") + OTHER + } + + public enum AmountPaymentType { + @SerializedName("pay") + PAY, + @SerializedName("payupto") + PAYUPTO + } +} From 4978c8f0a29e733dd137f125a3de368bb697be15 Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Wed, 20 Aug 2025 15:01:37 +0200 Subject: [PATCH 08/15] [CC-2673] Add orderId to klarna tests --- .../integration/paymenttypes/KlarnaTest.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/KlarnaTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/KlarnaTest.java index c0df9909..4fd1ffdf 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/KlarnaTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/KlarnaTest.java @@ -1,6 +1,13 @@ package com.unzer.payment.integration.paymenttypes; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Basket; +import com.unzer.payment.BasketItem; +import com.unzer.payment.Customer; +import com.unzer.payment.PaymentError; +import com.unzer.payment.PaymentException; +import com.unzer.payment.Unzer; import com.unzer.payment.business.AbstractPaymentTest; import com.unzer.payment.models.AdditionalTransactionData; import com.unzer.payment.paymenttypes.Klarna; @@ -10,13 +17,21 @@ import org.junit.jupiter.api.TestFactory; import java.math.BigDecimal; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Currency; +import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; import static com.unzer.payment.util.Types.unsafeUrl; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.DynamicTest.dynamicTest; @@ -154,6 +169,7 @@ public TestCase(String name, Customer customer, Basket basket, Authorization aut Klarna type = unzer.createPaymentType(new Klarna()); tc.authorization.setTypeId(type.getId()); + tc.authorization.setOrderId(tc.basket.getOrderId()); Customer customer = unzer.createCustomer(tc.customer); tc.authorization.setCustomerId(customer.getId()); From ec5a52eaa0eece5f66c7f487547c1b56b86a0976 Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Wed, 20 Aug 2025 15:33:52 +0200 Subject: [PATCH 09/15] [CC-2673] [CC-2787 ] Fix format for risk.registrationDate --- .../RiskRegistrationDateConverter.java | 48 +++++++++++++++++++ .../unzer/payment/models/paypage/Risk.java | 3 ++ 2 files changed, 51 insertions(+) create mode 100644 src/main/java/com/unzer/payment/communication/RiskRegistrationDateConverter.java diff --git a/src/main/java/com/unzer/payment/communication/RiskRegistrationDateConverter.java b/src/main/java/com/unzer/payment/communication/RiskRegistrationDateConverter.java new file mode 100644 index 00000000..e8a65cd1 --- /dev/null +++ b/src/main/java/com/unzer/payment/communication/RiskRegistrationDateConverter.java @@ -0,0 +1,48 @@ +package com.unzer.payment.communication; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import java.lang.reflect.Type; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +/** + * Gson converter for dates in format yyyyMMdd. + */ +public class RiskRegistrationDateConverter implements JsonDeserializer, JsonSerializer { + + public static final String DATE_FORMAT = "yyyyMMdd"; + + @Override + public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { + String value = json.getAsString(); + if (value == null || value.isEmpty()) { + return null; + } + SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); + df.setLenient(false); + // Interpret as UTC start of day when only date is given + df.setTimeZone(TimeZone.getTimeZone("UTC")); + try { + return df.parse(value); + } catch (ParseException e) { + throw new RuntimeException("Failed to parse date in format '" + DATE_FORMAT + "': " + value, e); + } + } + + @Override + public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) { + SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); + df.setLenient(false); + df.setTimeZone(TimeZone.getTimeZone("UTC")); + return new JsonPrimitive(df.format(src)); + + } +} diff --git a/src/main/java/com/unzer/payment/models/paypage/Risk.java b/src/main/java/com/unzer/payment/models/paypage/Risk.java index 376b701b..0fcfce42 100644 --- a/src/main/java/com/unzer/payment/models/paypage/Risk.java +++ b/src/main/java/com/unzer/payment/models/paypage/Risk.java @@ -1,5 +1,7 @@ package com.unzer.payment.models.paypage; +import com.google.gson.annotations.JsonAdapter; +import com.unzer.payment.communication.RiskRegistrationDateConverter; import lombok.Data; import java.util.Date; @@ -7,6 +9,7 @@ @Data public class Risk { private Integer registrationLevel; + @JsonAdapter(value = RiskRegistrationDateConverter.class) private Date registrationDate; private String customerGroup; private Integer confirmedOrders; From a81a4cb2a41d88c2d59286fed9934e6345583bfb Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Wed, 20 Aug 2025 16:08:33 +0200 Subject: [PATCH 10/15] [CC-2673] Cleanup tests. --- .../unzer/payment/PaymentExceptionTest.java | 14 ++-- .../java/com/unzer/payment/PaymentTest.java | 10 +-- .../com/unzer/payment/PaymentTypeTest.java | 4 +- .../payment/business/AuthorizationTest.java | 41 ++++++----- .../unzer/payment/business/BasketV1Test.java | 27 ++++--- .../unzer/payment/business/BasketV2Test.java | 29 +++++--- .../business/BusinessCustomerTest.java | 16 +++-- .../CancelAfterAuthorizationTest.java | 29 ++++---- .../business/CancelAfterChargeTest.java | 27 ++++--- .../unzer/payment/business/CancelTest.java | 20 +++--- .../ChargeAfterAuthorizationTest.java | 22 +++--- .../unzer/payment/business/ChargeTest.java | 50 +++++++------ .../unzer/payment/business/CustomerTest.java | 27 +++---- .../unzer/payment/business/LinkpayTest.java | 12 ++-- .../unzer/payment/business/MetadataTest.java | 16 +++-- .../unzer/payment/business/PaymentTest.java | 39 ++++++---- .../unzer/payment/business/PayoutTest.java | 6 +- .../unzer/payment/business/PaypageTest.java | 10 +-- .../unzer/payment/business/RecurringTest.java | 28 +++++--- .../unzer/payment/business/ShipmentTest.java | 4 +- .../payment/business/errors/ErrorTest.java | 35 +++++---- .../business/payment/ChargebackTest.java | 22 ++++-- .../payment/business/payment/PreauthTest.java | 15 ++-- .../business/paymenttypes/ClickToPayTest.java | 12 ++-- .../paymenttypes/OpenBankingTest.java | 7 +- .../AbstractUnzerHttpCommunicationTest.java | 22 +++--- .../communication/JsonDateConverterTest.java | 14 ++-- .../JsonDateTimeConverterTest.java | 14 ++-- .../payment/communication/JsonParserTest.java | 24 ++++--- .../JsonWebhookEnumConverterTest.java | 4 +- .../communication/api/ApiConfigTest.java | 2 +- .../integration/paymenttypes/AlipayTest.java | 8 +-- .../paymenttypes/ApplepayTest.java | 54 +++++++------- .../paymenttypes/BancontactTest.java | 10 +-- .../integration/paymenttypes/CardTest.java | 72 +++++++++++-------- .../integration/paymenttypes/EpsTest.java | 10 +-- .../integration/paymenttypes/GiropayTest.java | 8 +-- .../integration/paymenttypes/IdealTest.java | 8 +-- .../paymenttypes/InstallmentSecuredTest.java | 32 +++++---- .../paymenttypes/InvoiceSecuredTest.java | 23 ++++-- .../integration/paymenttypes/InvoiceTest.java | 8 +-- .../integration/paymenttypes/KlarnaTest.java | 6 +- .../paymenttypes/OpenBankingTest.java | 10 +-- .../integration/paymenttypes/PayUTest.java | 4 +- .../paymenttypes/PaylaterDirectDebitTest.java | 12 ++-- .../paymenttypes/PaylaterInstallmentTest.java | 36 ++++++---- .../paymenttypes/PaylaterInvoiceTest.java | 26 +++++-- .../paymenttypes/PaypalExpressTest.java | 6 +- .../integration/paymenttypes/PaypalTest.java | 12 ++-- .../integration/paymenttypes/PisTest.java | 8 +-- .../paymenttypes/PostFinanceCardTest.java | 8 +-- .../paymenttypes/PostFinanceEFinanceTest.java | 8 +-- .../paymenttypes/PrepaymentTest.java | 8 +-- .../paymenttypes/Przelewy24Test.java | 8 +-- .../SepaDirectDebitSecuredTest.java | 12 ++-- .../paymenttypes/SepaDirectDebitTest.java | 12 ++-- .../integration/paymenttypes/SofortTest.java | 6 +- .../integration/paymenttypes/TwintTest.java | 8 +-- .../paymenttypes/WechatpayTest.java | 8 +-- .../integration/paymenttypes/WeroTest.java | 2 + .../integration/resources/AuthTokenTest.java | 8 ++- .../payment/service/PaymentServiceTest.java | 12 ++-- .../unzer/payment/service/UrlUtilTest.java | 2 +- .../payment/util/ApplePayAdapterTest.java | 12 ++-- .../com/unzer/payment/util/VersionTest.java | 4 +- .../unzer/payment/webhook/WebhookTest.java | 10 +-- 66 files changed, 632 insertions(+), 451 deletions(-) diff --git a/src/test/java/com/unzer/payment/PaymentExceptionTest.java b/src/test/java/com/unzer/payment/PaymentExceptionTest.java index 249da8e6..5087faec 100644 --- a/src/test/java/com/unzer/payment/PaymentExceptionTest.java +++ b/src/test/java/com/unzer/payment/PaymentExceptionTest.java @@ -9,39 +9,39 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class PaymentExceptionTest { +class PaymentExceptionTest { @Test - public void testMessageIsNotNull() { + void testMessageIsNotNull() { PaymentException paymentException = new PaymentException("An Error occurred!"); assertNotNull(paymentException.getMessage()); assertEquals("An Error occurred!", paymentException.getMessage()); } @Test - public void testMessageIsEmpty() { + void testMessageIsEmpty() { PaymentException paymentException = new PaymentException(""); assertNotNull(paymentException.getMessage()); assertEquals("Unzer responded with 0 when calling . ", paymentException.getMessage()); } @Test - public void testPaymentErrorListEmptyAndMessageNotEmpty() { + void testPaymentErrorListEmptyAndMessageNotEmpty() { PaymentException paymentException = new PaymentException(new ArrayList(), "An Error occurred!"); assertNotNull(paymentException.getMessage()); assertEquals("An Error occurred!", paymentException.getMessage()); } @Test - public void testPaymentErrorListEmptyAndMessageIsEmpty() { + void testPaymentErrorListEmptyAndMessageIsEmpty() { PaymentException paymentException = new PaymentException(new ArrayList(), ""); assertNotNull(paymentException.getMessage()); assertEquals("Unzer responded with 0 when calling . ", paymentException.getMessage()); } @Test - public void testPaymentErrorListNotEmptyAndMessageIsEmpty() { + void testPaymentErrorListNotEmptyAndMessageIsEmpty() { PaymentError paymentError = new PaymentError(); paymentError.setCode("0"); paymentError.setCustomerMessage("This is a Customer Error Message!"); @@ -56,7 +56,7 @@ public void testPaymentErrorListNotEmptyAndMessageIsEmpty() { } @Test - public void testMessageIsNull() { + void testMessageIsNull() { PaymentException paymentException = new PaymentException(null); assertNotNull(paymentException.getMessage()); assertEquals("Unzer responded with 0 when calling . ", paymentException.getMessage()); diff --git a/src/test/java/com/unzer/payment/PaymentTest.java b/src/test/java/com/unzer/payment/PaymentTest.java index bb96bee2..429e4e9d 100644 --- a/src/test/java/com/unzer/payment/PaymentTest.java +++ b/src/test/java/com/unzer/payment/PaymentTest.java @@ -5,12 +5,14 @@ import java.math.BigDecimal; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class PaymentTest { +class PaymentTest { @Test - public void testIsNotEmpty() { + void testIsNotEmpty() { Payment payment = new Payment(getUnzer()); assertFalse(payment.isNotEmpty("")); assertFalse(payment.isNotEmpty(" ")); @@ -19,7 +21,7 @@ public void testIsNotEmpty() { } @Test - public void testChargeOnNullAuthorization() { + void testChargeOnNullAuthorization() { Payment payment = new Payment(getUnzer()); try { diff --git a/src/test/java/com/unzer/payment/PaymentTypeTest.java b/src/test/java/com/unzer/payment/PaymentTypeTest.java index 84b511d4..3fe041c9 100644 --- a/src/test/java/com/unzer/payment/PaymentTypeTest.java +++ b/src/test/java/com/unzer/payment/PaymentTypeTest.java @@ -6,10 +6,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -public class PaymentTypeTest extends AbstractPaymentTest { +class PaymentTypeTest extends AbstractPaymentTest { @Test - public void testForInvalidPaymentType() { + void testForInvalidPaymentType() { assertThrows(PaymentException.class, () -> { getUnzer().fetchPaymentType("s-xxx-shdshdbshbv"); }); diff --git a/src/test/java/com/unzer/payment/business/AuthorizationTest.java b/src/test/java/com/unzer/payment/business/AuthorizationTest.java index 86aae067..90157fab 100644 --- a/src/test/java/com/unzer/payment/business/AuthorizationTest.java +++ b/src/test/java/com/unzer/payment/business/AuthorizationTest.java @@ -1,6 +1,11 @@ package com.unzer.payment.business; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Basket; +import com.unzer.payment.Customer; +import com.unzer.payment.Payment; +import com.unzer.payment.Unzer; import com.unzer.payment.communication.HttpCommunicationException; import com.unzer.payment.marketplace.MarketplaceAuthorization; import com.unzer.payment.marketplace.MarketplacePayment; @@ -24,10 +29,10 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -public class AuthorizationTest extends AbstractPaymentTest { +class AuthorizationTest extends AbstractPaymentTest { @Test - public void testAuthorizeWithAuthorizationObject() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeWithAuthorizationObject() throws MalformedURLException, HttpCommunicationException { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); assertNotNull(authorize.getId()); assertNotNull(authorize); @@ -36,7 +41,7 @@ public void testAuthorizeWithAuthorizationObject() throws MalformedURLException, } @Test - public void testAuthorizeWithTypeId() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeWithTypeId() throws MalformedURLException, HttpCommunicationException { Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); assertNotNull(authorize); assertNotNull(authorize.getId()); @@ -45,7 +50,7 @@ public void testAuthorizeWithTypeId() throws MalformedURLException, HttpCommunic } @Test - public void testAuthorizeSuccess() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeSuccess() throws MalformedURLException, HttpCommunicationException { Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); assertNotNull(authorize); assertNotNull(authorize.getId()); @@ -55,7 +60,7 @@ public void testAuthorizeSuccess() throws MalformedURLException, HttpCommunicati } @Test - public void testAuthorizeWithPaymentType() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeWithPaymentType() throws MalformedURLException, HttpCommunicationException { Unzer unzer = getUnzer(Keys.DEFAULT); LocalDate locaDateNow = LocalDate.now(); Card card = new Card("4444333322221111", "12/" + (locaDateNow.getYear() + 1)); @@ -67,7 +72,7 @@ public void testAuthorizeWithPaymentType() throws MalformedURLException, HttpCom } @Test - public void testAuthorizeReturnPaymentTypeAndCustomer() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeReturnPaymentTypeAndCustomer() throws MalformedURLException, HttpCommunicationException { Unzer unzer = getUnzer(Keys.DEFAULT); LocalDate locaDateNow = LocalDate.now(); Card card = new Card("4444333322221111", "12/" + (locaDateNow.getYear() + 1)); @@ -82,7 +87,7 @@ public void testAuthorizeReturnPaymentTypeAndCustomer() throws MalformedURLExcep } @Test - public void testAuthorizeWithCustomerId() throws MalformedURLException, HttpCommunicationException, ParseException { + void testAuthorizeWithCustomerId() throws MalformedURLException, HttpCommunicationException, ParseException { Customer customer = getUnzer().createCustomer(getMaximumCustomer(generateUuid())); Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), customer.getCustomerId(), false); assertNotNull(authorize); @@ -92,7 +97,7 @@ public void testAuthorizeWithCustomerId() throws MalformedURLException, HttpComm } @Test - public void testAuthorizeWithReturnUrl() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeWithReturnUrl() throws MalformedURLException, HttpCommunicationException { Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); assertNotNull(authorize); assertNotNull(authorize.getId()); @@ -101,7 +106,7 @@ public void testAuthorizeWithReturnUrl() throws MalformedURLException, HttpCommu } @Test - public void testAuthorizeWithCustomerTypeReturnUrl() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeWithCustomerTypeReturnUrl() throws MalformedURLException, HttpCommunicationException { Unzer unzer = getUnzer(Keys.DEFAULT); LocalDate locaDateNow = LocalDate.now(); Card card = new Card("4444333322221111", "12/" + (locaDateNow.getYear() + 1)); @@ -114,7 +119,7 @@ public void testAuthorizeWithCustomerTypeReturnUrl() throws MalformedURLExceptio } @Test - public void testAuthorizeWithCustomerIdReturnUrl() throws MalformedURLException, HttpCommunicationException, ParseException { + void testAuthorizeWithCustomerIdReturnUrl() throws MalformedURLException, HttpCommunicationException, ParseException { Customer maxCustomer = getMaximumCustomer(generateUuid()); Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), maxCustomer.getId(), false); assertNotNull(authorize); @@ -124,7 +129,7 @@ public void testAuthorizeWithCustomerIdReturnUrl() throws MalformedURLException, } @Test - public void testFetchAuthorization() throws MalformedURLException, HttpCommunicationException { + void testFetchAuthorization() throws MalformedURLException, HttpCommunicationException { Authorization authorize = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); assertNotNull(authorize); assertNotNull(authorize.getId()); @@ -136,7 +141,7 @@ public void testFetchAuthorization() throws MalformedURLException, HttpCommunica } @Test - public void testAuthorizeWithOrderId() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeWithOrderId() throws MalformedURLException, HttpCommunicationException { String orderId = generateUuid(); Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), null, orderId, null, null, false)); assertNotNull(authorize); @@ -151,7 +156,7 @@ public void testAuthorizeWithOrderId() throws MalformedURLException, HttpCommuni } @Test - public void testAuthorizeCard3dsFalse() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeCard3dsFalse() throws MalformedURLException, HttpCommunicationException { String orderId = generateUuid(); Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), null, orderId, null, null, false)); assertNotNull(authorize); @@ -167,7 +172,7 @@ public void testAuthorizeCard3dsFalse() throws MalformedURLException, HttpCommun } @Test - public void testAuthorizeCard3dsTrue() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeCard3dsTrue() throws MalformedURLException, HttpCommunicationException { String orderId = generateUuid(); Unzer unzer = getUnzer(); Authorization authorize = unzer.authorize(getAuthorization(createPaymentTypeCard(unzer, "4711100000000000").getId(), null, orderId, null, null, true)); @@ -184,7 +189,7 @@ public void testAuthorizeCard3dsTrue() throws MalformedURLException, HttpCommuni } @Test - public void testAuthorizeWithPaymentReference() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeWithPaymentReference() throws MalformedURLException, HttpCommunicationException { Authorization authorization = getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId()); authorization.setPaymentReference("pmt-ref"); Authorization authorize = getUnzer().authorize(authorization); @@ -194,7 +199,7 @@ public void testAuthorizeWithPaymentReference() throws MalformedURLException, Ht } @Test - public void testAuthorizeWithAuthorizeObject() throws MalformedURLException, HttpCommunicationException { + void testAuthorizeWithAuthorizeObject() throws MalformedURLException, HttpCommunicationException { Authorization authorization = getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId()); authorization.setPaymentReference("pmt-ref"); authorization.setAmount(new BigDecimal("1.0")); @@ -207,7 +212,7 @@ public void testAuthorizeWithAuthorizeObject() throws MalformedURLException, Htt @Disabled("Needs further configuration in Testdata") @Test - public void testMarketplaceAuthorize() throws MalformedURLException, HttpCommunicationException { + void testMarketplaceAuthorize() throws MalformedURLException, HttpCommunicationException { String participantId_1 = MARKETPLACE_PARTICIPANT_ID_1; String participantId_2 = MARKETPLACE_PARTICIPANT_ID_2; diff --git a/src/test/java/com/unzer/payment/business/BasketV1Test.java b/src/test/java/com/unzer/payment/business/BasketV1Test.java index d78d691e..9ef1e829 100644 --- a/src/test/java/com/unzer/payment/business/BasketV1Test.java +++ b/src/test/java/com/unzer/payment/business/BasketV1Test.java @@ -1,7 +1,12 @@ package com.unzer.payment.business; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.Basket; +import com.unzer.payment.BasketItem; +import com.unzer.payment.Charge; +import com.unzer.payment.Payment; +import com.unzer.payment.PaymentException; import com.unzer.payment.communication.HttpCommunicationException; import com.unzer.payment.service.UrlUtil; import org.junit.jupiter.api.Test; @@ -13,12 +18,14 @@ import static com.unzer.payment.business.BasketV1TestData.getMaxTestBasketV1; import static com.unzer.payment.business.BasketV1TestData.getMinTestBasketV1; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class BasketV1Test extends AbstractPaymentTest { +class BasketV1Test extends AbstractPaymentTest { @Test - public void testCreateFetchBasket() { + void testCreateFetchBasket() { Basket maxBasket = getMaxTestBasketV1(); int basketItemCnt = maxBasket.getBasketItems().size(); for (int i = 0; i < basketItemCnt; i++) { @@ -76,7 +83,7 @@ private void assertBasketItemEquals(BasketItem expected, BasketItem actual) { } @Test - public void testCreateFetchMinBasket() { + void testCreateFetchMinBasket() { Basket minBasket = getMinTestBasketV1(); Basket basket = getUnzer().createBasket(minBasket); Basket basketFetched = getUnzer().fetchBasket(basket.getId()); @@ -86,7 +93,7 @@ public void testCreateFetchMinBasket() { } @Test - public void testUpdateBasket() { + void testUpdateBasket() { Basket minBasket = getMinTestBasketV1(); Basket basket = getUnzer().createBasket(minBasket); Basket basketFetched = getUnzer().fetchBasket(basket.getId()); @@ -99,7 +106,7 @@ public void testUpdateBasket() { } @Test - public void testUpdateBasketWithFetched() { + void testUpdateBasketWithFetched() { Basket minBasket = getMinTestBasketV1(); Basket basket = getUnzer().createBasket(minBasket); Basket basketFetched = getUnzer().fetchBasket(basket.getId()); @@ -111,7 +118,7 @@ public void testUpdateBasketWithFetched() { } @Test - public void testAuthorizationWithBasket() + void testAuthorizationWithBasket() throws MalformedURLException, HttpCommunicationException { Basket basket = createMaxTestBasket(); Authorization authorization = @@ -133,7 +140,7 @@ private Basket createMaxTestBasket() throws PaymentException, HttpCommunicationE } @Test - public void testChargeWithBasket() throws MalformedURLException, HttpCommunicationException { + void testChargeWithBasket() throws MalformedURLException, HttpCommunicationException { Basket basket = createMaxTestBasket(); Charge chargeReq = getCharge(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), null, null, null, @@ -150,7 +157,7 @@ public void testChargeWithBasket() throws MalformedURLException, HttpCommunicati } @Test - public void testBasketV2IsPriorVersion() { + void testBasketV2IsPriorVersion() { Basket basket = new Basket() .setTotalValueGross(BigDecimal.TEN) .setAmountTotalGross(BigDecimal.ONE); diff --git a/src/test/java/com/unzer/payment/business/BasketV2Test.java b/src/test/java/com/unzer/payment/business/BasketV2Test.java index 80c2dc8b..d8fac76d 100644 --- a/src/test/java/com/unzer/payment/business/BasketV2Test.java +++ b/src/test/java/com/unzer/payment/business/BasketV2Test.java @@ -1,7 +1,12 @@ package com.unzer.payment.business; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.Basket; +import com.unzer.payment.BasketItem; +import com.unzer.payment.Charge; +import com.unzer.payment.Payment; +import com.unzer.payment.Unzer; import com.unzer.payment.communication.JsonParser; import org.assertj.core.data.MapEntry; import org.junit.jupiter.api.Test; @@ -13,11 +18,13 @@ import static com.unzer.payment.business.BasketV2TestData.getMaxTestBasketV2; import static com.unzer.payment.business.BasketV2TestData.getMinTestBasketV2; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; -public class BasketV2Test extends AbstractPaymentTest { +class BasketV2Test extends AbstractPaymentTest { @Test - public void testCreateFetchBasket() { + void testCreateFetchBasket() { Basket maxBasket = getMaxTestBasketV2(); Basket basket = getUnzer().createBasket(maxBasket); Basket basketFetched = getUnzer().fetchBasket(basket.getId()); @@ -34,7 +41,7 @@ private void assertBasketEquals(Basket expected, Basket actual) { } @Test - public void testCreateFetchMinBasket() { + void testCreateFetchMinBasket() { Basket minBasket = getMinTestBasketV2(); Basket basket = getUnzer().createBasket(minBasket); Basket basketFetched = getUnzer().fetchBasket(basket.getId()); @@ -44,7 +51,7 @@ public void testCreateFetchMinBasket() { } @Test - public void testUpdateBasket() { + void testUpdateBasket() { Basket minBasket = getMinTestBasketV2(); Basket basket = getUnzer().createBasket(minBasket); Basket basketFetched = getUnzer().fetchBasket(basket.getId()); @@ -59,7 +66,7 @@ public void testUpdateBasket() { } @Test - public void testUpdateBasketWithFetched() { + void testUpdateBasketWithFetched() { Basket minBasket = getMinTestBasketV2(); Basket basket = getUnzer().createBasket(minBasket); Basket basketFetched = getUnzer().fetchBasket(basket.getId()); @@ -70,7 +77,7 @@ public void testUpdateBasketWithFetched() { } @Test - public void testAuthorizationWithBasket() { + void testAuthorizationWithBasket() { Unzer unzer = getUnzer(); Basket basket = unzer.createBasket(getMaxTestBasketV2()); Authorization authorization = getAuthorization( @@ -92,7 +99,7 @@ public void testAuthorizationWithBasket() { } @Test - public void testChargeWithBasket() { + void testChargeWithBasket() { Basket basket = getUnzer().createBasket(getMaxTestBasketV2()); Charge chargeReq = getCharge(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), null, null, null, @@ -109,7 +116,7 @@ public void testChargeWithBasket() { } @Test - public void testTypeEnumUnmarshalling() { + void testTypeEnumUnmarshalling() { List> validTypeValues = Arrays.asList( MapEntry.entry(null, new BasketItem()), MapEntry.entry("goods", new BasketItem().setType(BasketItem.Type.GOODS)), @@ -133,7 +140,7 @@ public void testTypeEnumUnmarshalling() { } @Test - public void testInvalidTypeSkipped() { + void testInvalidTypeSkipped() { String basketItemJson = "{ \"type\": \"invalid-type\" }"; JsonParser jsonParser = new JsonParser(); diff --git a/src/test/java/com/unzer/payment/business/BusinessCustomerTest.java b/src/test/java/com/unzer/payment/business/BusinessCustomerTest.java index cdfc41e9..e827b9c5 100644 --- a/src/test/java/com/unzer/payment/business/BusinessCustomerTest.java +++ b/src/test/java/com/unzer/payment/business/BusinessCustomerTest.java @@ -11,13 +11,15 @@ import java.text.ParseException; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; -public class BusinessCustomerTest extends AbstractPaymentTest { +class BusinessCustomerTest extends AbstractPaymentTest { @Test - public void testCreateRegisteredBusinessCustomer() { + void testCreateRegisteredBusinessCustomer() { Customer customer = getUnzer().createCustomer(getRegisterdMinimumBusinessCustomer()); assertNotNull(customer); assertNotNull(customer.getId()); @@ -25,7 +27,7 @@ public void testCreateRegisteredBusinessCustomer() { } @Test - public void testCreateRegisteredMaximumBusinessCustomer() throws HttpCommunicationException, ParseException { + void testCreateRegisteredMaximumBusinessCustomer() throws HttpCommunicationException, ParseException { Customer maxCustomer = getRegisterdMaximumBusinessCustomer(generateUuid()); Customer customer = getUnzer().createCustomer(maxCustomer); assertNotNull(customer); @@ -34,7 +36,7 @@ public void testCreateRegisteredMaximumBusinessCustomer() throws HttpCommunicati } @Test - public void testFetchRegisteredMaximumBusinessCustomer() throws HttpCommunicationException, ParseException { + void testFetchRegisteredMaximumBusinessCustomer() throws HttpCommunicationException, ParseException { Customer customer = getRegisterdMaximumBusinessCustomer(generateUuid()); customer = getUnzer().createCustomer(customer); assertNotNull(customer); @@ -76,7 +78,7 @@ public void testFetchUnRegisteredMaximumBusinessCustomer() throws HttpCommunicat } @Test - public void testUpdateCustomer() throws HttpCommunicationException, ParseException { + void testUpdateCustomer() throws HttpCommunicationException, ParseException { Customer customer = getUnzer().createCustomer(getRegisterdMaximumBusinessCustomer(generateUuid())); assertNotNull(customer); assertNotNull(customer.getId()); @@ -92,7 +94,7 @@ public void testUpdateCustomer() throws HttpCommunicationException, ParseExcepti } @Test - public void testDeleteCustomer() throws HttpCommunicationException, ParseException { + void testDeleteCustomer() throws HttpCommunicationException, ParseException { Customer customer = getUnzer().createCustomer(getRegisterdMaximumBusinessCustomer(generateUuid())); assertNotNull(customer); assertNotNull(customer.getId()); diff --git a/src/test/java/com/unzer/payment/business/CancelAfterAuthorizationTest.java b/src/test/java/com/unzer/payment/business/CancelAfterAuthorizationTest.java index e6d3f358..a07373a9 100644 --- a/src/test/java/com/unzer/payment/business/CancelAfterAuthorizationTest.java +++ b/src/test/java/com/unzer/payment/business/CancelAfterAuthorizationTest.java @@ -1,6 +1,11 @@ package com.unzer.payment.business; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.BasePayment; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Basket; +import com.unzer.payment.Cancel; +import com.unzer.payment.Payment; import com.unzer.payment.communication.HttpCommunicationException; import com.unzer.payment.marketplace.MarketplaceAuthorization; import com.unzer.payment.marketplace.MarketplaceCancel; @@ -21,17 +26,17 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -public class CancelAfterAuthorizationTest extends AbstractPaymentTest { +class CancelAfterAuthorizationTest extends AbstractPaymentTest { @Test - public void fetchAuthorization() { + void fetchAuthorization() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId())); Authorization authorization = getUnzer().fetchAuthorization(authorize.getPaymentId()); assertNotNull(authorization); } @Test - public void fullCancelAfterAuthorization() { + void fullCancelAfterAuthorization() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Authorization authorization = getUnzer().fetchAuthorization(authorize.getPaymentId()); Cancel cancel = authorization.cancel(); @@ -40,7 +45,7 @@ public void fullCancelAfterAuthorization() { } @Test - public void partialCancelPayment() { + void partialCancelPayment() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Payment payment = getUnzer().fetchPayment(authorize.getPaymentId()); Cancel cancel = payment.cancel(new BigDecimal("0.1")); @@ -50,7 +55,7 @@ public void partialCancelPayment() { } @Test - public void partialCancelAfterAuthorization() { + void partialCancelAfterAuthorization() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Authorization authorization = getUnzer().fetchAuthorization(authorize.getPaymentId()); Cancel cancel = authorization.cancel(new BigDecimal("0.1")); @@ -60,7 +65,7 @@ public void partialCancelAfterAuthorization() { } @Test - public void partialCancelAfterAuthorizationUnzer() { + void partialCancelAfterAuthorizationUnzer() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Cancel cancel = getUnzer().cancelAuthorization(authorize.getPaymentId()); assertNotNull(cancel); @@ -69,7 +74,7 @@ public void partialCancelAfterAuthorizationUnzer() { } @Test - public void fetchCancelUnzer() { + void fetchCancelUnzer() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Cancel cancelExecuted = getUnzer().cancelAuthorization(authorize.getPaymentId()); assertNotNull(cancelExecuted); @@ -81,7 +86,7 @@ public void fetchCancelUnzer() { } @Test - public void partialCancelAfterAuthorizationIsListFilled() { + void partialCancelAfterAuthorizationIsListFilled() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Authorization authorization = getUnzer().fetchAuthorization(authorize.getPaymentId()); Cancel cancel = authorization.cancel(BigDecimal.ONE); @@ -97,7 +102,7 @@ public void partialCancelAfterAuthorizationIsListFilled() { } @Test - public void cancelWithPaymentReference() { + void cancelWithPaymentReference() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Cancel cancelReq = new Cancel(); cancelReq.setPaymentReference("pmt-ref"); @@ -114,7 +119,7 @@ public void cancelWithPaymentReference() { @Disabled("Needs further configuration in Testdata") @Test - public void testMarketplaceFullAuthorizeCancel() throws MalformedURLException, HttpCommunicationException { + void testMarketplaceFullAuthorizeCancel() throws MalformedURLException, HttpCommunicationException { String participantId_1 = MARKETPLACE_PARTICIPANT_ID_1; String participantId_2 = MARKETPLACE_PARTICIPANT_ID_2; @@ -162,7 +167,7 @@ public void testMarketplaceFullAuthorizeCancel() throws MalformedURLException, H @Disabled("Needs further configuration in Testdata") @Test - public void testMarketplacePartialAuthorizeCancel() throws MalformedURLException, HttpCommunicationException { + void testMarketplacePartialAuthorizeCancel() throws MalformedURLException, HttpCommunicationException { String participantId_1 = MARKETPLACE_PARTICIPANT_ID_1; String participantId_2 = MARKETPLACE_PARTICIPANT_ID_2; diff --git a/src/test/java/com/unzer/payment/business/CancelAfterChargeTest.java b/src/test/java/com/unzer/payment/business/CancelAfterChargeTest.java index 43ab2d12..c5956ea4 100644 --- a/src/test/java/com/unzer/payment/business/CancelAfterChargeTest.java +++ b/src/test/java/com/unzer/payment/business/CancelAfterChargeTest.java @@ -1,6 +1,11 @@ package com.unzer.payment.business; -import com.unzer.payment.*; +import com.unzer.payment.BasePayment; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Basket; +import com.unzer.payment.Cancel; +import com.unzer.payment.Charge; +import com.unzer.payment.Payment; import com.unzer.payment.communication.HttpCommunicationException; import com.unzer.payment.marketplace.MarketplaceCancel; import com.unzer.payment.marketplace.MarketplaceCharge; @@ -23,10 +28,10 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -public class CancelAfterChargeTest extends AbstractPaymentTest { +class CancelAfterChargeTest extends AbstractPaymentTest { @Test - public void testFetchChargeWithId() throws MalformedURLException, HttpCommunicationException { + void testFetchChargeWithId() throws MalformedURLException, HttpCommunicationException { Charge initCharge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); Charge charge = getUnzer().fetchCharge(initCharge.getPaymentId(), initCharge.getId()); assertNotNull(charge); @@ -36,7 +41,7 @@ public void testFetchChargeWithId() throws MalformedURLException, HttpCommunicat @Test - public void testFullRefundWithId() throws MalformedURLException, HttpCommunicationException { + void testFullRefundWithId() throws MalformedURLException, HttpCommunicationException { Charge initCharge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); Cancel cancel = getUnzer().cancelCharge(initCharge.getPaymentId(), initCharge.getId()); assertNotNull(cancel); @@ -44,7 +49,7 @@ public void testFullRefundWithId() throws MalformedURLException, HttpCommunicati } @Test - public void testFullRefundWithCharge() throws MalformedURLException, HttpCommunicationException { + void testFullRefundWithCharge() throws MalformedURLException, HttpCommunicationException { Charge initCharge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); Charge charge = getUnzer().fetchCharge(initCharge.getPaymentId(), initCharge.getId()); Cancel cancel = charge.cancel(); @@ -53,14 +58,14 @@ public void testFullRefundWithCharge() throws MalformedURLException, HttpCommuni } @Test - public void testPartialRefundWithId() throws MalformedURLException, HttpCommunicationException { + void testPartialRefundWithId() throws MalformedURLException, HttpCommunicationException { Charge initCharge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); Cancel cancel = getUnzer().cancelCharge(initCharge.getPaymentId(), initCharge.getId(), new BigDecimal("0.1")); assertNotNull(cancel); } @Test - public void testPartialRefundWithCharge() throws MalformedURLException, HttpCommunicationException { + void testPartialRefundWithCharge() throws MalformedURLException, HttpCommunicationException { Charge initCharge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); Charge charge = getUnzer().fetchCharge(initCharge.getPaymentId(), initCharge.getId()); Cancel cancelExecuted = charge.cancel(new BigDecimal("0.1")); @@ -70,7 +75,7 @@ public void testPartialRefundWithCharge() throws MalformedURLException, HttpComm } @Test - public void testCancelAfterChargeChargeWithPaymentReference() throws MalformedURLException, HttpCommunicationException { + void testCancelAfterChargeChargeWithPaymentReference() throws MalformedURLException, HttpCommunicationException { Charge initCharge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); Cancel cancelReq = new Cancel(); cancelReq.setPaymentReference("pmt-ref"); @@ -86,7 +91,7 @@ public void testCancelAfterChargeChargeWithPaymentReference() throws MalformedUR } @Test - public void testCancelAfterChargeChargeWithCancelObject() throws MalformedURLException, HttpCommunicationException { + void testCancelAfterChargeChargeWithCancelObject() throws MalformedURLException, HttpCommunicationException { Charge initCharge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); Cancel cancelReq = new Cancel(); cancelReq.setPaymentReference("pmt-ref"); @@ -106,7 +111,7 @@ public void testCancelAfterChargeChargeWithCancelObject() throws MalformedURLExc @Disabled("Needs further configuration in Testdata") @Test - public void testMarketplaceFullCancelChargeWithCard() throws MalformedURLException, HttpCommunicationException { + void testMarketplaceFullCancelChargeWithCard() throws MalformedURLException, HttpCommunicationException { String participantId_1 = MARKETPLACE_PARTICIPANT_ID_1; String participantId_2 = MARKETPLACE_PARTICIPANT_ID_2; @@ -161,7 +166,7 @@ public void testMarketplaceFullCancelChargeWithCard() throws MalformedURLExcepti @Disabled("Needs further configuration in Testdata") @Test - public void testMarketplacePartialCancelChargeWithCard() throws MalformedURLException, HttpCommunicationException { + void testMarketplacePartialCancelChargeWithCard() throws MalformedURLException, HttpCommunicationException { String participantId_1 = MARKETPLACE_PARTICIPANT_ID_1; String participantId_2 = MARKETPLACE_PARTICIPANT_ID_2; diff --git a/src/test/java/com/unzer/payment/business/CancelTest.java b/src/test/java/com/unzer/payment/business/CancelTest.java index 19b49609..73caddaf 100644 --- a/src/test/java/com/unzer/payment/business/CancelTest.java +++ b/src/test/java/com/unzer/payment/business/CancelTest.java @@ -1,7 +1,11 @@ package com.unzer.payment.business; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Cancel; +import com.unzer.payment.Charge; +import com.unzer.payment.Unzer; import com.unzer.payment.paymenttypes.Card; import org.junit.jupiter.api.Test; @@ -13,10 +17,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class CancelTest extends AbstractPaymentTest { +class CancelTest extends AbstractPaymentTest { @Test - public void testFetchCancelAuthorizationWithUnzer() { + void testFetchCancelAuthorizationWithUnzer() { Authorization authorize = getUnzer().authorize( getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Cancel cancelInit = authorize.cancel(); @@ -29,7 +33,7 @@ public void testFetchCancelAuthorizationWithUnzer() { } @Test - public void test_fetch_cancel_charge() { + void test_fetch_cancel_charge() { Unzer unzer = getUnzer(); Card card = unzer.createPaymentType(new Card("4711100000000000", "03/30").setCvc("123")); assertNotNull(card.getId()); @@ -49,7 +53,7 @@ public void test_fetch_cancel_charge() { } @Test - public void testFetchCancelAuthorizationWithPayment() { + void testFetchCancelAuthorizationWithPayment() { Authorization authorize = getUnzer().authorize( getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Cancel cancelInit = authorize.cancel(); @@ -62,7 +66,7 @@ public void testFetchCancelAuthorizationWithPayment() { } @Test - public void testFetchCancelChargeWithUnzer() { + void testFetchCancelChargeWithUnzer() { Charge initCharge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), unsafeUrl("https://www.unzer.com"), false); @@ -77,7 +81,7 @@ public void testFetchCancelChargeWithUnzer() { } @Test - public void testCancelChargeWithPayment() { + void testCancelChargeWithPayment() { Charge initCharge = getUnzer() .charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), @@ -93,7 +97,7 @@ public void testCancelChargeWithPayment() { } @Test - public void testCancelChargeWithPaymentReference() { + void testCancelChargeWithPaymentReference() { Charge initCharge = getUnzer() .charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), diff --git a/src/test/java/com/unzer/payment/business/ChargeAfterAuthorizationTest.java b/src/test/java/com/unzer/payment/business/ChargeAfterAuthorizationTest.java index 2cd4f4f3..487db934 100644 --- a/src/test/java/com/unzer/payment/business/ChargeAfterAuthorizationTest.java +++ b/src/test/java/com/unzer/payment/business/ChargeAfterAuthorizationTest.java @@ -1,6 +1,10 @@ package com.unzer.payment.business; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Basket; +import com.unzer.payment.Charge; +import com.unzer.payment.Payment; import com.unzer.payment.communication.HttpCommunicationException; import com.unzer.payment.marketplace.MarketplaceAuthorization; import com.unzer.payment.marketplace.MarketplaceCharge; @@ -22,17 +26,17 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -public class ChargeAfterAuthorizationTest extends AbstractPaymentTest { +class ChargeAfterAuthorizationTest extends AbstractPaymentTest { @Test - public void fetchAuthorization() { + void fetchAuthorization() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId())); Authorization authorization = getUnzer().fetchAuthorization(authorize.getPaymentId()); assertNotNull(authorization); } @Test - public void fullChargeAfterAuthorization() { + void fullChargeAfterAuthorization() { String orderId = generateUuid(); Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), null, orderId, null, null, false)); Authorization authorization = getUnzer().fetchAuthorization(authorize.getPaymentId()); @@ -45,7 +49,7 @@ public void fullChargeAfterAuthorization() { } @Test - public void fullChargeAfterAuthorizationUnzer() { + void fullChargeAfterAuthorizationUnzer() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Charge charge = getUnzer().chargeAuthorization(authorize.getPaymentId()); assertNotNull(charge); @@ -53,7 +57,7 @@ public void fullChargeAfterAuthorizationUnzer() { } @Test - public void partialChargeAfterAuthorization() { + void partialChargeAfterAuthorization() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Authorization authorization = getUnzer().fetchAuthorization(authorize.getPaymentId()); Charge charge = authorization.charge(new BigDecimal("0.1")); @@ -62,7 +66,7 @@ public void partialChargeAfterAuthorization() { } @Test - public void chargeAfterAuthorizationWithPaymentReference() { + void chargeAfterAuthorizationWithPaymentReference() { Authorization authorize = getUnzer().authorize(getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Charge charge = authorize.charge(new BigDecimal("1.0"), "pmt-ref"); assertNotNull(charge); @@ -72,7 +76,7 @@ public void chargeAfterAuthorizationWithPaymentReference() { @Disabled("Needs further configuration in Testdata") @Test - public void testMarketplaceFullAuthorizeCharge() throws MalformedURLException, HttpCommunicationException { + void testMarketplaceFullAuthorizeCharge() throws MalformedURLException, HttpCommunicationException { String participantId_1 = MARKETPLACE_PARTICIPANT_ID_1; String participantId_2 = MARKETPLACE_PARTICIPANT_ID_2; @@ -125,7 +129,7 @@ public void testMarketplaceFullAuthorizeCharge() throws MalformedURLException, H @Disabled("Needs further configuration in Testdata") @Test - public void testMarketplaceAuthorizeCharge() throws MalformedURLException, HttpCommunicationException { + void testMarketplaceAuthorizeCharge() throws MalformedURLException, HttpCommunicationException { String participantId_1 = MARKETPLACE_PARTICIPANT_ID_1; String participantId_2 = MARKETPLACE_PARTICIPANT_ID_2; diff --git a/src/test/java/com/unzer/payment/business/ChargeTest.java b/src/test/java/com/unzer/payment/business/ChargeTest.java index b6c4fa88..71cdef86 100644 --- a/src/test/java/com/unzer/payment/business/ChargeTest.java +++ b/src/test/java/com/unzer/payment/business/ChargeTest.java @@ -2,7 +2,12 @@ import com.google.gson.GsonBuilder; -import com.unzer.payment.*; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Basket; +import com.unzer.payment.Charge; +import com.unzer.payment.Customer; +import com.unzer.payment.Payment; +import com.unzer.payment.Unzer; import com.unzer.payment.communication.HttpCommunicationException; import com.unzer.payment.communication.JsonFieldIgnoreStragegy; import com.unzer.payment.marketplace.MarketplaceCharge; @@ -25,12 +30,15 @@ import static com.unzer.payment.business.Keys.MARKETPLACE_KEY; import static com.unzer.payment.util.Types.unsafeUrl; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class ChargeTest extends AbstractPaymentTest { +class ChargeTest extends AbstractPaymentTest { @Test - public void testChargeWithTypeId() throws MalformedURLException, HttpCommunicationException { + void testChargeWithTypeId() throws MalformedURLException, HttpCommunicationException { Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://integration.splitit.com//gateways/Proxy/Execute?publicToken=9e517919-9e3d-4d5f-825e-99f7712eefd1"), false); assertNotNull(charge); assertNotNull(charge.getId()); @@ -39,7 +47,7 @@ public void testChargeWithTypeId() throws MalformedURLException, HttpCommunicati } @Test - public void testChargeIsSuccess() throws MalformedURLException, HttpCommunicationException { + void testChargeIsSuccess() throws MalformedURLException, HttpCommunicationException { Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); assertNotNull(charge); assertNotNull(charge.getId()); @@ -50,7 +58,7 @@ public void testChargeIsSuccess() throws MalformedURLException, HttpCommunicatio } @Test - public void testChargeWIthInvoiceAndOrderIdIsSuccess() throws MalformedURLException, HttpCommunicationException { + void testChargeWIthInvoiceAndOrderIdIsSuccess() throws MalformedURLException, HttpCommunicationException { Charge requestCharge = getCharge("1234"); requestCharge.setCard3ds(Boolean.FALSE); requestCharge.setInvoiceId("4567"); @@ -65,7 +73,7 @@ public void testChargeWIthInvoiceAndOrderIdIsSuccess() throws MalformedURLExcept } @Test - public void testChargeWithPaymentType() throws MalformedURLException, HttpCommunicationException { + void testChargeWithPaymentType() throws MalformedURLException, HttpCommunicationException { Unzer unzer = getUnzer(DEFAULT); LocalDate locaDateNow = LocalDate.now(); Card card = new Card("4444333322221111", "12/" + (locaDateNow.getYear() + 1)); @@ -77,7 +85,7 @@ public void testChargeWithPaymentType() throws MalformedURLException, HttpCommun } @Test - public void testChargeWithReturnUrl() throws MalformedURLException, HttpCommunicationException { + void testChargeWithReturnUrl() throws MalformedURLException, HttpCommunicationException { Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), false); assertNotNull(charge); assertEquals("COR.000.100.112", charge.getMessage().getCode()); @@ -86,7 +94,7 @@ public void testChargeWithReturnUrl() throws MalformedURLException, HttpCommunic } @Test - public void testChargeWithCustomerTypeReturnUrl() throws MalformedURLException, HttpCommunicationException { + void testChargeWithCustomerTypeReturnUrl() throws MalformedURLException, HttpCommunicationException { Unzer unzer = getUnzer(DEFAULT); LocalDate locaDateNow = LocalDate.now(); Card card = new Card("4444333322221111", "12/" + (locaDateNow.getYear() + 1)); @@ -99,7 +107,7 @@ public void testChargeWithCustomerTypeReturnUrl() throws MalformedURLException, } @Test - public void testChargeWithCustomerIdReturnUrl() throws MalformedURLException, HttpCommunicationException, ParseException { + void testChargeWithCustomerIdReturnUrl() throws MalformedURLException, HttpCommunicationException, ParseException { Customer customer = getUnzer().createCustomer(getMaximumCustomer(generateUuid())); Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), new URL("https://www.unzer.com"), customer.getId(), false); assertNotNull(charge); @@ -108,7 +116,7 @@ public void testChargeWithCustomerIdReturnUrl() throws MalformedURLException, Ht } @Test - public void testChargeReturnPayment() throws MalformedURLException, HttpCommunicationException { + void testChargeReturnPayment() throws MalformedURLException, HttpCommunicationException { Unzer unzer = getUnzer(DEFAULT); LocalDate locaDateNow = LocalDate.now(); Card card = new Card("4444333322221111", "12/" + (locaDateNow.getYear() + 1)); @@ -123,7 +131,7 @@ public void testChargeReturnPayment() throws MalformedURLException, HttpCommunic @Disabled("does not throw error") @Test - public void testChargeSofort() throws MalformedURLException, HttpCommunicationException { + void testChargeSofort() throws MalformedURLException, HttpCommunicationException { Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), new Sofort(), new URL("https://www.unzer.com")); assertNotNull(charge.getRedirectUrl()); assertNotNull(charge); @@ -135,7 +143,7 @@ public void testChargeSofort() throws MalformedURLException, HttpCommunicationEx } @Test - public void testChargeOrderId() throws MalformedURLException, HttpCommunicationException { + void testChargeOrderId() throws MalformedURLException, HttpCommunicationException { String orderId = generateUuid(); Charge charge = getUnzer().charge(getCharge(orderId, false, null)); assertNotNull(charge); @@ -151,7 +159,7 @@ public void testChargeOrderId() throws MalformedURLException, HttpCommunicationE } @Test - public void testChargeWith3dsFalse() throws MalformedURLException, HttpCommunicationException { + void testChargeWith3dsFalse() throws MalformedURLException, HttpCommunicationException { String orderId = generateUuid(); Charge charge = getUnzer().charge(getCharge(orderId, false, null)); assertNotNull(charge); @@ -163,7 +171,7 @@ public void testChargeWith3dsFalse() throws MalformedURLException, HttpCommunica } @Test - public void testChargeWith3dsTrue() throws MalformedURLException, HttpCommunicationException { + void testChargeWith3dsTrue() throws MalformedURLException, HttpCommunicationException { String orderId = generateUuid(); Charge charge = getUnzer().charge(getCharge(orderId, true, null)); assertNotNull(charge); @@ -175,7 +183,7 @@ public void testChargeWith3dsTrue() throws MalformedURLException, HttpCommunicat } @Test - public void testChargeWithPaymentReference() throws MalformedURLException, HttpCommunicationException { + void testChargeWithPaymentReference() throws MalformedURLException, HttpCommunicationException { String orderId = generateUuid(); Charge chargeObj = getCharge(orderId, true, null); chargeObj.setPaymentReference("pmt-ref"); @@ -186,7 +194,7 @@ public void testChargeWithPaymentReference() throws MalformedURLException, HttpC } @Test - public void testChargeWithChargeObject() throws MalformedURLException, HttpCommunicationException { + void testChargeWithChargeObject() throws MalformedURLException, HttpCommunicationException { String orderId = generateUuid(); Charge chargeObj = getCharge(orderId, true, null); chargeObj.setPaymentReference("pmt-ref"); @@ -199,7 +207,7 @@ public void testChargeWithChargeObject() throws MalformedURLException, HttpCommu } @Test - public void testChargeObjectIsParsableWithGson() { + void testChargeObjectIsParsableWithGson() { Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), unsafeUrl("https://integration.splitit.com//gateways/Proxy/Execute?publicToken=9e517919-9e3d-4d5f-825e-99f7712eefd1"), false); assertEquals(String.class, new GsonBuilder() .addSerializationExclusionStrategy(new JsonFieldIgnoreStragegy()) @@ -209,7 +217,7 @@ public void testChargeObjectIsParsableWithGson() { @Disabled("Needs further configuration in Testdata") @Test - public void testMarketplaceChargeWithCard() throws MalformedURLException, HttpCommunicationException { + void testMarketplaceChargeWithCard() throws MalformedURLException, HttpCommunicationException { String participantId_1 = MARKETPLACE_PARTICIPANT_ID_1; String participantId_2 = MARKETPLACE_PARTICIPANT_ID_2; @@ -252,7 +260,7 @@ public void testMarketplaceChargeWithCard() throws MalformedURLException, HttpCo @Disabled("Needs further configuration in Testdata") @Test - public void testMarketplaceChargeWithSepaDirectDebit() throws MalformedURLException, HttpCommunicationException { + void testMarketplaceChargeWithSepaDirectDebit() throws MalformedURLException, HttpCommunicationException { String participantId_1 = MARKETPLACE_PARTICIPANT_ID_1; String participantId_2 = MARKETPLACE_PARTICIPANT_ID_2; @@ -294,7 +302,7 @@ public void testMarketplaceChargeWithSepaDirectDebit() throws MalformedURLExcept @Disabled("Needs further configuration in Testdata") @Test - public void testMarketplaceChargeWithSofort() throws MalformedURLException, HttpCommunicationException { + void testMarketplaceChargeWithSofort() throws MalformedURLException, HttpCommunicationException { String participantId_1 = MARKETPLACE_PARTICIPANT_ID_1; String participantId_2 = MARKETPLACE_PARTICIPANT_ID_2; diff --git a/src/test/java/com/unzer/payment/business/CustomerTest.java b/src/test/java/com/unzer/payment/business/CustomerTest.java index 685aea43..55c0fcaa 100644 --- a/src/test/java/com/unzer/payment/business/CustomerTest.java +++ b/src/test/java/com/unzer/payment/business/CustomerTest.java @@ -17,13 +17,16 @@ import java.util.stream.Stream; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.DynamicTest.dynamicTest; -public class CustomerTest extends AbstractPaymentTest { +class CustomerTest extends AbstractPaymentTest { @Test - public void testCreateMinimumCustomer() { + void testCreateMinimumCustomer() { Customer customer = getUnzer().createCustomer(getMinimumCustomer()); assertNotNull(customer); assertNotNull(customer.getId()); @@ -32,7 +35,7 @@ public void testCreateMinimumCustomer() { } @Test - public void testCreateMaximumCustomer() { + void testCreateMaximumCustomer() { Customer maxCustomer = getMaximumCustomer(generateUuid()); Customer customer = getUnzer().createCustomer(maxCustomer); assertNotNull(customer); @@ -41,7 +44,7 @@ public void testCreateMaximumCustomer() { } @Test - public void testCreateMaximumMrsCustomer() { + void testCreateMaximumMrsCustomer() { Customer maxMrsCustomer = getMaximumMrsCustomer(generateUuid()); Customer customer = getUnzer().createCustomer(maxMrsCustomer); assertNotNull(customer); @@ -50,7 +53,7 @@ public void testCreateMaximumMrsCustomer() { } @Test - public void testCreateMaximumUnknownCustomer() { + void testCreateMaximumUnknownCustomer() { Customer unknownMrsCustomer = getMaximumUnknownCustomer(generateUuid()); Customer customer = getUnzer().createCustomer(unknownMrsCustomer); assertNotNull(customer); @@ -59,7 +62,7 @@ public void testCreateMaximumUnknownCustomer() { } @Test - public void testFetchCustomerMinimum() { + void testFetchCustomerMinimum() { Customer customer = getUnzer().createCustomer(getMinimumCustomer()); assertNotNull(customer); assertNotNull(customer.getId()); @@ -69,7 +72,7 @@ public void testFetchCustomerMinimum() { } @Test - public void testFetchCustomerMaximum() { + void testFetchCustomerMaximum() { Customer expectedCustomer = getMaximumCustomer(generateUuid()); Customer customer = getUnzer().createCustomer(expectedCustomer); assertNotNull(customer); @@ -80,7 +83,7 @@ public void testFetchCustomerMaximum() { } @Test - public void testUpdateCustomer() { + void testUpdateCustomer() { Customer customer = getUnzer().createCustomer(getMaximumCustomer(generateUuid())); assertNotNull(customer); assertNotNull(customer.getId()); @@ -93,7 +96,7 @@ public void testUpdateCustomer() { } @Test - public void testDeleteCustomer() { + void testDeleteCustomer() { Customer customer = getUnzer().createCustomer(getMaximumCustomer(generateUuid())); assertNotNull(customer); assertNotNull(customer.getId()); @@ -102,7 +105,7 @@ public void testDeleteCustomer() { } @Test - public void testCreateCustomerWithException() { + void testCreateCustomerWithException() { assertThrows(IllegalArgumentException.class, () -> { getUnzer().createCustomer(null); }); @@ -146,7 +149,7 @@ public TestCase(Customer customer, Customer.Salutation expectedSalutation) { } @Test - public void testCustomerBirthdate() { + void testCustomerBirthdate() { Unzer unzer = getUnzer(); Date birthdate = new Date(94, Calendar.DECEMBER, 1, 11, 59, 31); diff --git a/src/test/java/com/unzer/payment/business/LinkpayTest.java b/src/test/java/com/unzer/payment/business/LinkpayTest.java index 027eebaf..3d6dec03 100644 --- a/src/test/java/com/unzer/payment/business/LinkpayTest.java +++ b/src/test/java/com/unzer/payment/business/LinkpayTest.java @@ -15,12 +15,14 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.DynamicTest.dynamicTest; -public class LinkpayTest extends AbstractPaymentTest { +class LinkpayTest extends AbstractPaymentTest { @Test - public void fetch_linkpay() { + void fetch_linkpay() { Unzer unzer = getUnzer(); Linkpay newLinkpay = getMaximumLinkpay(null); Linkpay createdLinkpay = unzer.linkpay(newLinkpay); @@ -31,7 +33,7 @@ public void fetch_linkpay() { } @Test - public void charge_MaximumLinkpay() { + void charge_MaximumLinkpay() { Unzer unzer = getUnzer(); Linkpay request = getMaximumLinkpay(null); request = unzer.linkpay(request); @@ -73,7 +75,7 @@ public void charge_MaximumLinkpay() { } @Test - public void charge_Linkpay_WithEmptyCssMap() { + void charge_Linkpay_WithEmptyCssMap() { Unzer unzer = getUnzer(); Linkpay request = getMaximumLinkpay(null); diff --git a/src/test/java/com/unzer/payment/business/MetadataTest.java b/src/test/java/com/unzer/payment/business/MetadataTest.java index 614af181..3cdf3ff7 100644 --- a/src/test/java/com/unzer/payment/business/MetadataTest.java +++ b/src/test/java/com/unzer/payment/business/MetadataTest.java @@ -1,16 +1,20 @@ package com.unzer.payment.business; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.Charge; +import com.unzer.payment.Metadata; +import com.unzer.payment.Payment; +import com.unzer.payment.Unzer; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class MetadataTest extends AbstractPaymentTest { +class MetadataTest extends AbstractPaymentTest { @Test - public void testCreateFetchMetadata() { + void testCreateFetchMetadata() { Metadata metadata = getUnzer().createMetadata(getTestMetadata()); Metadata metadataFetched = getUnzer().fetchMetadata(metadata.getId()); assertNotNull(metadataFetched); @@ -19,7 +23,7 @@ public void testCreateFetchMetadata() { } @Test - public void testSortedMetadata() { + void testSortedMetadata() { Metadata metadataRequest = getTestMetadata(true); Metadata metadata = getUnzer().createMetadata(metadataRequest); assertEquals("delivery-date", metadata.getMetadataMap().keySet().toArray()[0]); @@ -31,7 +35,7 @@ public void testSortedMetadata() { } @Test - public void testAuthorizationWithMetadata() { + void testAuthorizationWithMetadata() { Unzer unzer = getUnzer(); String metadataId = unzer.createMetadata(getTestMetadata()).getId(); Authorization authorize = unzer.authorize( @@ -48,7 +52,7 @@ public void testAuthorizationWithMetadata() { } @Test - public void testChargeWithMetadata() { + void testChargeWithMetadata() { Unzer unzer = getUnzer(); String metadataId = unzer.createMetadata(getTestMetadata()).getId(); Charge charge = unzer.charge( diff --git a/src/test/java/com/unzer/payment/business/PaymentTest.java b/src/test/java/com/unzer/payment/business/PaymentTest.java index 7edd416f..d575d46b 100644 --- a/src/test/java/com/unzer/payment/business/PaymentTest.java +++ b/src/test/java/com/unzer/payment/business/PaymentTest.java @@ -1,7 +1,14 @@ package com.unzer.payment.business; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Cancel; +import com.unzer.payment.Charge; +import com.unzer.payment.Customer; +import com.unzer.payment.Payment; +import com.unzer.payment.PaymentException; +import com.unzer.payment.Unzer; import com.unzer.payment.communication.HttpCommunicationException; import com.unzer.payment.paymenttypes.Card; import org.junit.jupiter.api.Test; @@ -12,12 +19,14 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; -public class PaymentTest extends AbstractPaymentTest { +class PaymentTest extends AbstractPaymentTest { @Test - public void testFetchPaymentWithAuthorization() { + void testFetchPaymentWithAuthorization() { Authorization authorize = getUnzer().authorize( getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId())); Payment payment = getUnzer().fetchPayment(authorize.getPayment().getId()); @@ -29,7 +38,7 @@ public void testFetchPaymentWithAuthorization() { } @Test - public void testFullChargeAfterAuthorize() { + void testFullChargeAfterAuthorize() { Authorization authorize = getUnzer().authorize( getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Payment payment = getUnzer().fetchPayment(authorize.getPayment().getId()); @@ -39,7 +48,7 @@ public void testFullChargeAfterAuthorize() { } @Test - public void testFetchPaymentWithCharges() { + void testFetchPaymentWithCharges() { Authorization authorize = getUnzer().authorize( getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Payment payment = getUnzer().fetchPayment(authorize.getPayment().getId()); @@ -59,7 +68,7 @@ public void testFetchPaymentWithCharges() { } @Test - public void testPartialChargeAfterAuthorize() { + void testPartialChargeAfterAuthorize() { Authorization authorize = getUnzer().authorize( getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Payment payment = getUnzer().fetchPayment(authorize.getPayment().getId()); @@ -70,7 +79,7 @@ public void testPartialChargeAfterAuthorize() { } @Test - public void testFullCancelAuthorize() { + void testFullCancelAuthorize() { Unzer unzer = getUnzer(Keys.KEY_WITHOUT_3DS); Card card = createPaymentTypeCard(unzer, "4711100000000000"); @@ -87,7 +96,7 @@ public void testFullCancelAuthorize() { } @Test - public void testPartialCancelAuthorize() { + void testPartialCancelAuthorize() { Authorization authorize = getUnzer().authorize( getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), false)); Payment payment = getUnzer().fetchPayment(authorize.getPayment().getId()); @@ -98,7 +107,7 @@ public void testPartialCancelAuthorize() { } @Test - public void testFullCancelOnCharge() { + void testFullCancelOnCharge() { Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), unsafeUrl("https://www.unzer.com"), false); @@ -108,7 +117,7 @@ public void testFullCancelOnCharge() { } @Test - public void testPartialCancelOnCharge() { + void testPartialCancelOnCharge() { Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), unsafeUrl("https://www.unzer.com"), false); @@ -118,7 +127,7 @@ public void testPartialCancelOnCharge() { } @Test - public void testAuthorize() { + void testAuthorize() { // Variant 1 Unzer unzer = getUnzer(); Payment payment = new Payment(unzer); @@ -139,7 +148,7 @@ public void testAuthorize() { } @Test - public void testAuthorizeWithExistedCustomer() throws HttpCommunicationException, ParseException { + void testAuthorizeWithExistedCustomer() throws HttpCommunicationException, ParseException { Unzer unzer = getUnzer(); // Variant 1 Payment payment = new Payment(unzer); @@ -161,7 +170,7 @@ public void testAuthorizeWithExistedCustomer() throws HttpCommunicationException } @Test - public void testAuthorizeWithNotExistedPaymentTypeAndCustomer() { + void testAuthorizeWithNotExistedPaymentTypeAndCustomer() { Customer customerRequest = getMaximumCustomer(""); Card cardRequest = getPaymentTypeCard(); Unzer unzer = getUnzer(); @@ -181,7 +190,7 @@ public void testAuthorizeWithNotExistedPaymentTypeAndCustomer() { } @Test - public void testChargeWithoutAuthorize() { + void testChargeWithoutAuthorize() { Charge chargeUsingPayment = new Payment(getUnzer()).charge(BigDecimal.ONE, Currency.getInstance("EUR"), createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), diff --git a/src/test/java/com/unzer/payment/business/PayoutTest.java b/src/test/java/com/unzer/payment/business/PayoutTest.java index a08517ba..f7a5a1b7 100644 --- a/src/test/java/com/unzer/payment/business/PayoutTest.java +++ b/src/test/java/com/unzer/payment/business/PayoutTest.java @@ -20,11 +20,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class PayoutTest extends AbstractPaymentTest { +class PayoutTest extends AbstractPaymentTest { @Disabled("Further Configuration needed") @Test - public void testPayoutCardMinimal() throws MalformedURLException, HttpCommunicationException { + void testPayoutCardMinimal() throws MalformedURLException, HttpCommunicationException { Card card = createPaymentTypeCard(getUnzer(), "4711100000000000"); Payout payout = getUnzer().payout(BigDecimal.ONE, Currency.getInstance("EUR"), card.getId(), new URL("https://www.unzer.com")); assertNotNull(payout); @@ -35,7 +35,7 @@ public void testPayoutCardMinimal() throws MalformedURLException, HttpCommunicat @Disabled("Further Configuration needed") @Test - public void testPayoutCardWithAllData() throws MalformedURLException, HttpCommunicationException, ParseException { + void testPayoutCardWithAllData() throws MalformedURLException, HttpCommunicationException, ParseException { Card card = createPaymentTypeCard(getUnzer(), "4711100000000000"); Payout payout = getUnzer().payout(getTestPayout(card.getId())); assertNotNull(payout); diff --git a/src/test/java/com/unzer/payment/business/PaypageTest.java b/src/test/java/com/unzer/payment/business/PaypageTest.java index 4db90a32..65c89ec6 100644 --- a/src/test/java/com/unzer/payment/business/PaypageTest.java +++ b/src/test/java/com/unzer/payment/business/PaypageTest.java @@ -18,13 +18,15 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.DynamicTest.dynamicTest; -public class PaypageTest extends AbstractPaymentTest { +class PaypageTest extends AbstractPaymentTest { @Test - public void testMaximumPaypage() { + void testMaximumPaypage() { Unzer unzer = getUnzer(); Paypage request = getMaximumPaypage(null); @@ -70,7 +72,7 @@ public void testMaximumPaypage() { } @Test - public void testPaypage_WithEmptyCssMap() { + void testPaypage_WithEmptyCssMap() { Unzer unzer = getUnzer(); Paypage request = getMaximumPaypage(null); diff --git a/src/test/java/com/unzer/payment/business/RecurringTest.java b/src/test/java/com/unzer/payment/business/RecurringTest.java index 32860a89..adb0ce1e 100644 --- a/src/test/java/com/unzer/payment/business/RecurringTest.java +++ b/src/test/java/com/unzer/payment/business/RecurringTest.java @@ -1,7 +1,11 @@ package com.unzer.payment.business; -import com.unzer.payment.*; +import com.unzer.payment.Charge; +import com.unzer.payment.Customer; +import com.unzer.payment.Metadata; +import com.unzer.payment.Recurring; +import com.unzer.payment.Unzer; import com.unzer.payment.communication.HttpCommunicationException; import com.unzer.payment.paymenttypes.Card; import com.unzer.payment.paymenttypes.Paypal; @@ -15,11 +19,13 @@ import java.util.Currency; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; -public class RecurringTest extends AbstractPaymentTest { +class RecurringTest extends AbstractPaymentTest { @Test - public void testRecurringCardWithoutCustomer() throws MalformedURLException, HttpCommunicationException, ParseException { + void testRecurringCardWithoutCustomer() throws MalformedURLException, HttpCommunicationException, ParseException { String typeId = createPaymentTypeCard(getUnzer(), "4711100000000000").getId(); Recurring recurring = getUnzer().recurring(typeId, new URL("https://www.unzer.com")); assertRecurring(recurring, Recurring.Status.PENDING); @@ -30,7 +36,7 @@ public void testRecurringCardWithoutCustomer() throws MalformedURLException, Htt } @Test - public void testRecurringCardWitCustomerId() throws MalformedURLException, HttpCommunicationException, ParseException { + void testRecurringCardWitCustomerId() throws MalformedURLException, HttpCommunicationException, ParseException { Customer customer = getUnzer().createCustomer(getMaximumCustomer(generateUuid())); String typeId = createPaymentTypeCard(getUnzer(), "4711100000000000").getId(); Recurring recurring = getUnzer().recurring(typeId, customer.getId(), new URL("https://www.unzer.com")); @@ -42,7 +48,7 @@ public void testRecurringCardWitCustomerId() throws MalformedURLException, HttpC } @Test - public void testRecurringCardWitCustomerWithCustomerId() throws MalformedURLException, HttpCommunicationException, ParseException { + void testRecurringCardWitCustomerWithCustomerId() throws MalformedURLException, HttpCommunicationException, ParseException { Customer customer = getUnzer().createCustomer(getMaximumCustomer(generateUuid())); Recurring recurring = getUnzer().recurring(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), customer.getCustomerId(), new URL("https://www.unzer.com")); assertRecurring(recurring, Recurring.Status.PENDING); @@ -50,7 +56,7 @@ public void testRecurringCardWitCustomerWithCustomerId() throws MalformedURLExce } @Test - public void testRecurringCardWitCustomerAndMetadata() throws MalformedURLException, HttpCommunicationException, ParseException { + void testRecurringCardWitCustomerAndMetadata() throws MalformedURLException, HttpCommunicationException, ParseException { Customer customer = getUnzer().createCustomer(getMaximumCustomer(generateUuid())); Metadata metadata = getUnzer().createMetadata(getTestMetadata()); Recurring recurring = getUnzer().recurring(createPaymentTypeCard(getUnzer(), "4711100000000000").getId(), customer.getId(), metadata.getId(), new URL("https://www.unzer.com")); @@ -59,7 +65,7 @@ public void testRecurringCardWitCustomerAndMetadata() throws MalformedURLExcepti } @Test - public void testRecurringPaypalWithoutCustomer() throws MalformedURLException, HttpCommunicationException, ParseException { + void testRecurringPaypalWithoutCustomer() throws MalformedURLException, HttpCommunicationException, ParseException { Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); Paypal paypal = new Paypal(); paypal = unzer.createPaymentType(paypal); @@ -71,7 +77,7 @@ public void testRecurringPaypalWithoutCustomer() throws MalformedURLException, H } @Test - public void testRecurringPaypalWitCustomerId() throws MalformedURLException, HttpCommunicationException { + void testRecurringPaypalWitCustomerId() throws MalformedURLException, HttpCommunicationException { Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); Customer customer = unzer.createCustomer(getMaximumCustomer(generateUuid())); Paypal paypal = new Paypal(); @@ -85,7 +91,7 @@ public void testRecurringPaypalWitCustomerId() throws MalformedURLException, Htt } @Test - public void testRecurringCardDuringCharge() throws MalformedURLException, HttpCommunicationException, ParseException { + void testRecurringCardDuringCharge() throws MalformedURLException, HttpCommunicationException, ParseException { String typeId = createPaymentTypeCard(getUnzer(), "4711100000000000").getId(); Card type = (Card) getUnzer().fetchPaymentType(typeId); assertEquals(false, type.getRecurring()); @@ -98,7 +104,7 @@ public void testRecurringCardDuringCharge() throws MalformedURLException, HttpCo } @Test - public void testRecurringSepaDirectDebitDuringCharge() throws MalformedURLException, HttpCommunicationException, ParseException { + void testRecurringSepaDirectDebitDuringCharge() throws MalformedURLException, HttpCommunicationException, ParseException { Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); SepaDirectDebit sdd = unzer.createPaymentType(getSepaDirectDebit()); sdd = (SepaDirectDebit) unzer.fetchPaymentType(sdd.getId()); diff --git a/src/test/java/com/unzer/payment/business/ShipmentTest.java b/src/test/java/com/unzer/payment/business/ShipmentTest.java index ae655903..58b6a25e 100644 --- a/src/test/java/com/unzer/payment/business/ShipmentTest.java +++ b/src/test/java/com/unzer/payment/business/ShipmentTest.java @@ -9,9 +9,9 @@ import static com.unzer.payment.util.Uuid.generateUuid; import static org.junit.jupiter.api.Assertions.assertThrows; -public class ShipmentTest extends AbstractPaymentTest { +class ShipmentTest extends AbstractPaymentTest { @Test - public void testAuthorizeWithShipmentNotSameAddressWithInvoiceSecured() { + void testAuthorizeWithShipmentNotSameAddressWithInvoiceSecured() { assertThrows(PaymentException.class, () -> { Unzer unzer = getUnzer(); InvoiceSecured paymentTypeInvoiceSecured = unzer.createPaymentType(new InvoiceSecured()); diff --git a/src/test/java/com/unzer/payment/business/errors/ErrorTest.java b/src/test/java/com/unzer/payment/business/errors/ErrorTest.java index 1809940e..14b36dbe 100644 --- a/src/test/java/com/unzer/payment/business/errors/ErrorTest.java +++ b/src/test/java/com/unzer/payment/business/errors/ErrorTest.java @@ -1,7 +1,12 @@ package com.unzer.payment.business.errors; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.Charge; +import com.unzer.payment.Customer; +import com.unzer.payment.PaymentError; +import com.unzer.payment.PaymentException; +import com.unzer.payment.Unzer; import com.unzer.payment.business.AbstractPaymentTest; import com.unzer.payment.business.Keys; import com.unzer.payment.communication.HttpCommunicationException; @@ -12,11 +17,15 @@ import java.util.List; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class ErrorTest extends AbstractPaymentTest { +class ErrorTest extends AbstractPaymentTest { @Test - public void testKeyMissing() { + void testKeyMissing() { assertThrows( AssertionError.class, () -> new Unzer(null) @@ -31,7 +40,7 @@ public void testKeyMissing() { // The given key something is unknown or invalid. // The key 's-priv-123' is invalid @Test - public void testInvalidKey() throws HttpCommunicationException { + void testInvalidKey() throws HttpCommunicationException { try { getUnzer("s-priv-123").authorize(getAuthorization("")); } catch (PaymentException e) { @@ -48,7 +57,7 @@ public void testInvalidKey() throws HttpCommunicationException { // Card resources can only be created directly with a valid PCI certification. // Please contact Unzer to grant permission for PCI level SAQ-D or SAQ-A EP @Test - public void testPCILevelSaqA() { + void testPCILevelSaqA() { try { getUnzer(Keys.PUBLIC_KEY).createPaymentType(getPaymentTypeCard()); // Prod Sandbox } catch (PaymentException e) { @@ -66,7 +75,7 @@ public void testPCILevelSaqA() { // Payment type '/types/s-crd-jbrjthrghag2' not found //FIXME tests nothing @Test - public void testInvalidAccess() { + void testInvalidAccess() { Card card = createPaymentTypeCard(getUnzer(), "4711100000000000"); try { getUnzer(Keys.DEFAULT).fetchPaymentType(card.getId()); // Prod-Sandbox @@ -83,7 +92,7 @@ public void testInvalidAccess() { // Invalid return URL // Return URL is mandatory @Test - public void testMissingReturnUrl() throws HttpCommunicationException { + void testMissingReturnUrl() throws HttpCommunicationException { try { Authorization authorization = getAuthorization(createPaymentTypeCard(getUnzer(), "4711100000000000").getId()); authorization.setReturnUrl(null); @@ -97,7 +106,7 @@ public void testMissingReturnUrl() throws HttpCommunicationException { } @Test - public void testPaymentTypeIdInvalid() throws HttpCommunicationException { + void testPaymentTypeIdInvalid() throws HttpCommunicationException { try { getUnzer().authorize(getAuthorization("")); } catch (PaymentException e) { @@ -109,7 +118,7 @@ public void testPaymentTypeIdInvalid() throws HttpCommunicationException { } @Test - public void testFetchNonExistingPayment() { + void testFetchNonExistingPayment() { try { getUnzer().fetchAuthorization("213"); } catch (PaymentException e) { @@ -121,14 +130,14 @@ public void testFetchNonExistingPayment() { } @Test - public void testFetchNonExistingCharge() throws HttpCommunicationException { + void testFetchNonExistingCharge() throws HttpCommunicationException { Charge charge = getUnzer().charge(getCharge()); Charge chargeFetched = getUnzer().fetchCharge(charge.getPaymentId(), "s-chg-200"); assertNull(chargeFetched); } @Test - public void testinvalidPutCustomer() throws HttpCommunicationException, ParseException { + void testinvalidPutCustomer() throws HttpCommunicationException, ParseException { try { Customer customer = getUnzer().createCustomer(getMaximumCustomer(generateUuid())); Customer customerUpdate = new Customer(customer.getFirstname(), customer.getLastname()); @@ -143,7 +152,7 @@ public void testinvalidPutCustomer() throws HttpCommunicationException, ParseExc } @Test - public void testCreateInvalidCustomer() throws HttpCommunicationException, ParseException { + void testCreateInvalidCustomer() throws HttpCommunicationException, ParseException { try { Customer customer = getMinimumCustomer(); customer.setBirthDate(getDate("01.01.1944")); diff --git a/src/test/java/com/unzer/payment/business/payment/ChargebackTest.java b/src/test/java/com/unzer/payment/business/payment/ChargebackTest.java index 95bd54b9..24c5de3a 100644 --- a/src/test/java/com/unzer/payment/business/payment/ChargebackTest.java +++ b/src/test/java/com/unzer/payment/business/payment/ChargebackTest.java @@ -1,7 +1,11 @@ package com.unzer.payment.business.payment; import com.github.tomakehurst.wiremock.junit5.WireMockTest; -import com.unzer.payment.*; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Chargeback; +import com.unzer.payment.Payment; +import com.unzer.payment.Processing; +import com.unzer.payment.Unzer; import com.unzer.payment.communication.HttpClientMock; import com.unzer.payment.communication.json.JsonMessage; import com.unzer.payment.enums.RecurrenceType; @@ -12,15 +16,23 @@ import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Collections; +import java.util.Comparator; +import java.util.Currency; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.Scanner; -import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.jsonResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertIterableEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @WireMockTest(httpPort = 8080) -public class ChargebackTest { +class ChargebackTest { private static String getResponse(String response) { return new Scanner( Objects.requireNonNull( @@ -31,7 +43,7 @@ private static String getResponse(String response) { } @Test - public void chargeback_fetched_successfully() throws ParseException { + void chargeback_fetched_successfully() throws ParseException { stubFor( get("/v1/payments/s-pay-286").willReturn( jsonResponse(getResponse("fetch-payment.json"), 200)) diff --git a/src/test/java/com/unzer/payment/business/payment/PreauthTest.java b/src/test/java/com/unzer/payment/business/payment/PreauthTest.java index 1e809a57..f11e928d 100644 --- a/src/test/java/com/unzer/payment/business/payment/PreauthTest.java +++ b/src/test/java/com/unzer/payment/business/payment/PreauthTest.java @@ -11,11 +11,16 @@ import java.util.Objects; import java.util.Scanner; -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static org.junit.jupiter.api.Assertions.*; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.jsonResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; @WireMockTest(httpPort = 8080) -public class PreauthTest { +class PreauthTest { private static String getResponse(String response) { return new Scanner( Objects.requireNonNull( @@ -26,7 +31,7 @@ private static String getResponse(String response) { } @Test - public void preauthorize_fetched_successfully() { + void preauthorize_fetched_successfully() { stubFor( post("/v1/payments/preauthorize/").willReturn( jsonResponse(getResponse("fetch-preauthorize.json"), 200)) @@ -60,7 +65,7 @@ public void preauthorize_fetched_successfully() { } @Test - public void cancel_preauth_transaction() { + void cancel_preauth_transaction() { stubFor( post("/v1/payments/s-pay-123/preauthorize/cancels").willReturn( jsonResponse(getResponse("cancel-preauthorize.json"), 200)) diff --git a/src/test/java/com/unzer/payment/business/paymenttypes/ClickToPayTest.java b/src/test/java/com/unzer/payment/business/paymenttypes/ClickToPayTest.java index 0c1e222f..6f6449fa 100644 --- a/src/test/java/com/unzer/payment/business/paymenttypes/ClickToPayTest.java +++ b/src/test/java/com/unzer/payment/business/paymenttypes/ClickToPayTest.java @@ -5,27 +5,23 @@ import com.unzer.payment.Unzer; import com.unzer.payment.communication.HttpClientMock; import com.unzer.payment.communication.JsonParser; -import com.unzer.payment.models.googlepay.IntermediateSigningKey; -import com.unzer.payment.models.googlepay.SignedKey; -import com.unzer.payment.models.googlepay.SignedMessage; import com.unzer.payment.paymenttypes.ClickToPay; -import com.unzer.payment.paymenttypes.GooglePay; -import org.checkerframework.checker.units.qual.C; import org.junit.jupiter.api.Test; import java.math.BigDecimal; -import java.util.Collections; import java.util.Currency; import java.util.Objects; import java.util.Scanner; -import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.jsonResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; @WireMockTest(httpPort = 8080) -public class ClickToPayTest { +class ClickToPayTest { private static String getResponse(String response) { return new Scanner(Objects.requireNonNull( diff --git a/src/test/java/com/unzer/payment/business/paymenttypes/OpenBankingTest.java b/src/test/java/com/unzer/payment/business/paymenttypes/OpenBankingTest.java index 42898b3a..543be111 100644 --- a/src/test/java/com/unzer/payment/business/paymenttypes/OpenBankingTest.java +++ b/src/test/java/com/unzer/payment/business/paymenttypes/OpenBankingTest.java @@ -13,12 +13,15 @@ import java.util.Objects; import java.util.Scanner; -import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.jsonResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; @WireMockTest(httpPort = 8080) -public class OpenBankingTest { +class OpenBankingTest { private static String getResponse(String response) { return new Scanner(Objects.requireNonNull( diff --git a/src/test/java/com/unzer/payment/communication/AbstractUnzerHttpCommunicationTest.java b/src/test/java/com/unzer/payment/communication/AbstractUnzerHttpCommunicationTest.java index 1a0628ad..000db81f 100644 --- a/src/test/java/com/unzer/payment/communication/AbstractUnzerHttpCommunicationTest.java +++ b/src/test/java/com/unzer/payment/communication/AbstractUnzerHttpCommunicationTest.java @@ -14,13 +14,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class AbstractUnzerHttpCommunicationTest { +class AbstractUnzerHttpCommunicationTest { private final String privateKey = "samplekey"; @Test - public void testApiErrorsAreTranslatedToPaymentException() { + void testApiErrorsAreTranslatedToPaymentException() { PaymentException exception = null; MockUnzerRestCommunication rest = setupRest(errorJson(), 409); @@ -42,7 +42,7 @@ public void testApiErrorsAreTranslatedToPaymentException() { } @Test - public void testhttpGet() throws PaymentException, HttpCommunicationException { + void testhttpGet() throws PaymentException, HttpCommunicationException { MockUnzerRestCommunication rest = setupRest(validJsonResponse(), 200); @@ -52,7 +52,7 @@ public void testhttpGet() throws PaymentException, HttpCommunicationException { } @Test - public void testHttpPost() throws PaymentException, HttpCommunicationException { + void testHttpPost() throws PaymentException, HttpCommunicationException { MockUnzerRestCommunication rest = setupRest(validJsonResponse(), 201); String result = rest.httpPost("https://unzer.com", privateKey, sampleData()); assertEquals(validJsonResponse(), result); @@ -60,7 +60,7 @@ public void testHttpPost() throws PaymentException, HttpCommunicationException { } @Test - public void testhttpPut() throws PaymentException, HttpCommunicationException { + void testhttpPut() throws PaymentException, HttpCommunicationException { MockUnzerRestCommunication rest = setupRest(validJsonResponse(), 200); String result = rest.httpPut("https://unzer.com", privateKey, sampleData()); assertEquals(validJsonResponse(), result); @@ -69,7 +69,7 @@ public void testhttpPut() throws PaymentException, HttpCommunicationException { } @Test - public void testhttpDelete() throws PaymentException, HttpCommunicationException { + void testhttpDelete() throws PaymentException, HttpCommunicationException { MockUnzerRestCommunication rest = setupRest(validJsonResponse(), 200); String result = rest.httpDelete("https://unzer.com", privateKey); assertEquals(validJsonResponse(), result); @@ -86,7 +86,7 @@ private void assertLoggingHooks(MockUnzerRestCommunication rest, int expectedSta } @Test - public void testAuthAndUserAgentHeaderAreSetOnGetRequest() throws PaymentException, HttpCommunicationException { + void testAuthAndUserAgentHeaderAreSetOnGetRequest() throws PaymentException, HttpCommunicationException { MockUnzerRestCommunication rest = setupRest(validJsonResponse(), 200); @@ -97,7 +97,7 @@ public void testAuthAndUserAgentHeaderAreSetOnGetRequest() throws PaymentExcepti } @Test - public void testAuthContentTypeAndUserAgentHeaderAndBodiesContentEncodingAreSetOnPostRequest() throws PaymentException, HttpCommunicationException { + void testAuthContentTypeAndUserAgentHeaderAndBodiesContentEncodingAreSetOnPostRequest() throws PaymentException, HttpCommunicationException { MockUnzerRestCommunication rest = setupRest(validJsonResponse(), 200); @@ -110,7 +110,7 @@ public void testAuthContentTypeAndUserAgentHeaderAndBodiesContentEncodingAreSetO } @Test - public void testAuthContentTypeAndUserAgentHeaderAndBodiesContentEncodingAreSetOnPutRequest() throws PaymentException, HttpCommunicationException { + void testAuthContentTypeAndUserAgentHeaderAndBodiesContentEncodingAreSetOnPutRequest() throws PaymentException, HttpCommunicationException { MockUnzerRestCommunication rest = setupRest(validJsonResponse(), 200); @@ -123,7 +123,7 @@ public void testAuthContentTypeAndUserAgentHeaderAndBodiesContentEncodingAreSetO } @Test - public void testAuthAndUserAgentHeaderAreSetOnDeleteRequest() throws PaymentException, HttpCommunicationException { + void testAuthAndUserAgentHeaderAreSetOnDeleteRequest() throws PaymentException, HttpCommunicationException { MockUnzerRestCommunication rest = setupRest(validJsonResponse(), 200); @@ -135,7 +135,7 @@ public void testAuthAndUserAgentHeaderAreSetOnDeleteRequest() throws PaymentExce } @Test - public void testClientIpHeader() { + void testClientIpHeader() { MockUnzerRestCommunication rest = new MockUnzerRestCommunication(Locale.ITALY, "192.168.1.1"); rest.responseMockStatus = 200; rest.responseMockContent = validJsonResponse(); diff --git a/src/test/java/com/unzer/payment/communication/JsonDateConverterTest.java b/src/test/java/com/unzer/payment/communication/JsonDateConverterTest.java index 3a2771f0..42889ea4 100644 --- a/src/test/java/com/unzer/payment/communication/JsonDateConverterTest.java +++ b/src/test/java/com/unzer/payment/communication/JsonDateConverterTest.java @@ -11,10 +11,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -public class JsonDateConverterTest { +class JsonDateConverterTest { @Test - public void date_parsed_successfully() { + void date_parsed_successfully() { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", "1980-12-01"); @@ -24,7 +24,7 @@ public void date_parsed_successfully() { } @Test - public void dateTime_parsed_successfully() { + void dateTime_parsed_successfully() { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", "1980-12-01 11:59:00"); @@ -35,7 +35,7 @@ public void dateTime_parsed_successfully() { } @Test - public void getDateTestWrongFormat() { + void getDateTestWrongFormat() { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", "1980-12-01 12:00"); @@ -47,7 +47,7 @@ public void getDateTestWrongFormat() { } @Test - public void getDateTestInvalidDate() { + void getDateTestInvalidDate() { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", "2000-12-32"); @@ -59,7 +59,7 @@ public void getDateTestInvalidDate() { } @Test - public void getDateTestInvalidDateTime() { + void getDateTestInvalidDateTime() { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", "2000-12-31 25:00:00"); @@ -71,7 +71,7 @@ public void getDateTestInvalidDateTime() { } @Test - public void date_time_converted_without_time() { + void date_time_converted_without_time() { Date initialDate = new Date(94, Calendar.DECEMBER, 1, 11, 59, 31); String convertedDate = new JsonDateConverter().serialize(initialDate, null, null).getAsString(); diff --git a/src/test/java/com/unzer/payment/communication/JsonDateTimeConverterTest.java b/src/test/java/com/unzer/payment/communication/JsonDateTimeConverterTest.java index 4d7c6498..2dc8d2bf 100644 --- a/src/test/java/com/unzer/payment/communication/JsonDateTimeConverterTest.java +++ b/src/test/java/com/unzer/payment/communication/JsonDateTimeConverterTest.java @@ -11,11 +11,11 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -public class JsonDateTimeConverterTest { +class JsonDateTimeConverterTest { private static final JsonDateTimeConverter converter = new JsonDateTimeConverter(); @Test - public void date_parsed_fine() { + void date_parsed_fine() { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", "1980-12-01"); @@ -24,7 +24,7 @@ public void date_parsed_fine() { } @Test - public void dateTime_parsed_fine() { + void dateTime_parsed_fine() { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", "1980-12-01 11:59:00"); @@ -34,7 +34,7 @@ public void dateTime_parsed_fine() { } @Test - public void getDateTestWrongFormat() { + void getDateTestWrongFormat() { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", "1980-12-01 12:00"); @@ -44,7 +44,7 @@ public void getDateTestWrongFormat() { } @Test - public void getDateTestInvalidDate() { + void getDateTestInvalidDate() { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", "2000-12-32"); @@ -54,7 +54,7 @@ public void getDateTestInvalidDate() { } @Test - public void getDateTestInvalidDateTime() { + void getDateTestInvalidDateTime() { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("date", "2000-12-31 25:00:00"); @@ -64,7 +64,7 @@ public void getDateTestInvalidDateTime() { } @Test - public void date_time_converted_with_time() { + void date_time_converted_with_time() { Date initialDate = new Date(94, Calendar.DECEMBER, 1, 11, 59, 31); String convertedDate = converter.serialize(initialDate, null, null).getAsString(); diff --git a/src/test/java/com/unzer/payment/communication/JsonParserTest.java b/src/test/java/com/unzer/payment/communication/JsonParserTest.java index fba70b26..8846f932 100644 --- a/src/test/java/com/unzer/payment/communication/JsonParserTest.java +++ b/src/test/java/com/unzer/payment/communication/JsonParserTest.java @@ -10,12 +10,16 @@ import com.unzer.payment.communication.json.JsonErrorObject; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; -public class JsonParserTest extends AbstractPaymentTest { +class JsonParserTest extends AbstractPaymentTest { @Test - public void given_an_error_message_then_payment_exception_is_thrown() { + void given_an_error_message_then_payment_exception_is_thrown() { try { JsonParser parser = new JsonParser(); parser.fromJson(TestData.errorJson(), ApiCharge.class); @@ -28,41 +32,41 @@ public void given_an_error_message_then_payment_exception_is_thrown() { } @Test - public void given_an_error_json_then_fromJson_returnes_jsonerrorobject() { + void given_an_error_json_then_fromJson_returnes_jsonerrorobject() { assertJsonError(new JsonParser().fromJson(TestData.errorJson(), JsonErrorObject.class)); } @Test - public void testValidJson() { + void testValidJson() { assertTrue(new JsonParser().isJsonValid("{\"name\": \"value\"}")); } @Test - public void testInvalidJson() { + void testInvalidJson() { assertFalse(new JsonParser().isJsonValid("This is an error message!")); } @Test - public void testNullJson() { + void testNullJson() { assertThrows(IllegalArgumentException.class, () -> { new JsonParser().fromJson(null, Payment.class); }); } @Test - public void testNullClass() { + void testNullClass() { assertThrows(IllegalArgumentException.class, () -> { new JsonParser().fromJson("{\"name\": \"value\"}", null); }); } @Test - public void testNullValidJson() { + void testNullValidJson() { assertFalse(new JsonParser().isJsonValid(null)); } @Test - public void testFromInvalidJson() { + void testFromInvalidJson() { assertThrows(IllegalArgumentException.class, () -> { new JsonParser().fromJson("This is an error message!", Payment.class); }); diff --git a/src/test/java/com/unzer/payment/communication/JsonWebhookEnumConverterTest.java b/src/test/java/com/unzer/payment/communication/JsonWebhookEnumConverterTest.java index 624c1f9f..9da6af5c 100644 --- a/src/test/java/com/unzer/payment/communication/JsonWebhookEnumConverterTest.java +++ b/src/test/java/com/unzer/payment/communication/JsonWebhookEnumConverterTest.java @@ -8,10 +8,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -public class JsonWebhookEnumConverterTest { +class JsonWebhookEnumConverterTest { @Test - public void testDeserializeWithInvalidJson() { + void testDeserializeWithInvalidJson() { JsonWebhookEnumConverter converter = new JsonWebhookEnumConverter(); WebhookEventEnum webhookEventEnum = converter.deserialize(null, null, null); diff --git a/src/test/java/com/unzer/payment/communication/api/ApiConfigTest.java b/src/test/java/com/unzer/payment/communication/api/ApiConfigTest.java index 519c4dc2..97ab3a37 100644 --- a/src/test/java/com/unzer/payment/communication/api/ApiConfigTest.java +++ b/src/test/java/com/unzer/payment/communication/api/ApiConfigTest.java @@ -21,6 +21,6 @@ void getTokenServiceConfig() { @Test void getPaypageServiceConfig() { assertEquals("https://paypage.unzer.com", ApiConfigs.PAYPAGE_API.getBaseUrl()); - assertEquals("https://paypage.test.unzer.io", ApiConfigs.PAYPAGE_API.getTestBaseUrl()); + assertEquals("https://paypage.test.unzer.com", ApiConfigs.PAYPAGE_API.getTestBaseUrl()); } } diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/AlipayTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/AlipayTest.java index 2c10a280..7775e65b 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/AlipayTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/AlipayTest.java @@ -14,17 +14,17 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -public class AlipayTest extends AbstractPaymentTest { +class AlipayTest extends AbstractPaymentTest { @Test - public void testCreateAlipayManatoryType() { + void testCreateAlipayManatoryType() { Alipay alipay = new Alipay(); alipay = getUnzer().createPaymentType(alipay); assertNotNull(alipay.getId()); } @Test - public void testChargeAlipayType() { + void testChargeAlipayType() { Unzer unzer = getUnzer(); Alipay alipay = unzer.createPaymentType(new Alipay()); Charge charge = unzer.charge( @@ -39,7 +39,7 @@ public void testChargeAlipayType() { } @Test - public void testFetchAlipayType() { + void testFetchAlipayType() { Alipay alipay = getUnzer().createPaymentType(new Alipay()); assertNotNull(alipay.getId()); Alipay fetchedAlipay = (Alipay) getUnzer().fetchPaymentType(alipay.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/ApplepayTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/ApplepayTest.java index ee3f1a96..307b7692 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/ApplepayTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/ApplepayTest.java @@ -3,7 +3,11 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.Cancel; +import com.unzer.payment.Charge; +import com.unzer.payment.PaymentException; +import com.unzer.payment.Unzer; import com.unzer.payment.business.AbstractPaymentTest; import com.unzer.payment.paymenttypes.Applepay; import com.unzer.payment.paymenttypes.ApplepayHeader; @@ -19,10 +23,10 @@ @Disabled("refresh credentials") -public class ApplepayTest extends AbstractPaymentTest { +class ApplepayTest extends AbstractPaymentTest { @Test - public void testCreateApplePayTypeFromJson() throws JsonProcessingException { + void testCreateApplePayTypeFromJson() throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); String applePayData = "{\"version\":\"EC_v1\",\"data\":\"+GfdFIUZV57HNDYWpfFpGnXXXXT7F9ZVRkEwxrulUfLUzUlRpV2XnEpVe9Kf6CZMYCvCAh8vB26lB9oZU+IdppNK9iZXXXXUq0G2X+jPCRxsuNp+eVBCQCLD5YHLcc9xCi7K62Gn2NOX80Q/hXeMVNpgIBmE9f7SjX6r6Oq8mD6ak4sUABRsD3efbKr9/kdFI+n0679p3ca1deqN91r3+XeOPLeErtexoJfwFRpIo85f/FhaoX/MgIzGVQ5KI9+khiR/Bez7aT0yOjMdTIJangkjpSqB9aj5UDDVO3jDryR7+fvWs3+Y9hGG3HoAXqKl3NSZvrSn7fqqJJUpXuaOtyEi9GTvYAq/7cQ34K8XvitAMTcHB17z/vwOlaIO62m6JnigKT2hh5ngFSpqZ6XR2Xxj01EJnJDZiTtauoEPKo27e5kE1H9vaQycYaVyrYxbsecqRSAtWKtGNVdkw927io14LuVEXcoYOTOzieX769MKpsU7lOemqBO8B0eXSsChOC7s3jncwuSGI/k5FyNBrtZawnI1yy39zCF4JtmpqaYuEa43QgKH4pE=\",\"signature\":\"MIAGCSqGSIb3DQXXXXCAMIACAQExDzANBglghkgBZQMEXXXXXDCABgkqhkiG9w0BBwEAAKCAMIID5DCCA4ugAwIBAgIIWdihvKr0480wCgYIKoZIzj0EAwIwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMB4XDTIxMDQyMDE5MzcwMFoXDTI2MDQxOTE5MzY1OVowYjEoMCYGA1UEAwwfZWNjLXNtcC1icm9rZXItc2lnbl9VQzQtU0FOREJPWDEUMBIGA1UECwwLaU9TIFN5c3RlbXMxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAXXXXXXEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEgjD9q8Oc914gLFDZm0US5jfiqQHdbLPgsc1LUmeY+M9OvegaJajCHkwz3c6OKpbC9q+hkwNFxOh6RCbOlRsSlaOCAhEwggINMAwGA1UdEwEB/wQCMAAwHwYDVR0jBBgwFoAUI/JJxE+T5O8n5sT2KGw/orv9LkswRQYIKwYBBQUHAQEEOTA3MDUGCCsGAQUFBzABhilodHRwOi8vb2NzcC5hcHBsZS5jb20vb2NzcDA0LWFwcGxlYWljYTMwMjCCAR0GA1UdIASCARQwggEQMIIBDAYJKoZIhvdjZAUBMIH+MIHDBggrBgEFBQcCAjCBtgyBs1JlbGlhbmNlIG9uIHRoaXMgY2VydGlmaWNhdGUgYnkgYW55IHBhcnR5IGFzc3VtZXMgYWNjZXB0YW5jZSBvZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJkIHRlcm1zIGFuZCBjb25kaXRpb25zIG9mIHVzZSwgY2VydGlmaWNhdGUgcG9saWN5IGFuZCBjZXJ0aWZpY2F0aW9uIHByYWN0aWNlIHNXXXXlbWVudHMuMDYGCCsGAQUFBwIBFipodHRwOi8vd3d3LmFwcGxlLmNvbS9jZXJ0aWZpY2F0ZWF1dGhvcml0eS8wNAYDVR0fBC0wKzApoCegJYYjaHR0cDovL2NybC5hcHBsZS5jb20vYXBwbGVhaWNhMy5jcmwwHQYDVR0OBBYEFAIkMAua7u1GMZekplopnkJxghxFMA4GA1UdDwEB/wQEAwIHgDAPBgkqhkiG92NkBh0EAgUAMAoGCCqGSM49BAMCA0cAMEQCIHShsyTbQklDDdMnTFB0xICNmh9IDjqFxcE2JWYyX7yjAiBpNpBTq/ULWlL59gBNxYqtbFCn1ghoN5DgpzrQHkrZgTCCAu4wggJ1oAMCAQICCEltL786mNqXMAoGCCqGSM49BAMCMGcxGzAZBgNVBAMMEkFwcGxlIFJvb3QgQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMB4XDTE0MDUwNjIzNDYzMFoXDTI5MDUwNjIzNDYzMFowejEuMCwGAXXXXwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE8BcRhBnXZIXVGl4lgQd26ICi7957rk3gjfxLk+EzVtVmWzWuItCXdg0iTnu6CP12F86Iy3a7ZnC+yOgphP9URaOB9zCB9DBGBggrBgEFBQcBAQQ6MDgwNgYIKwYBBQUHMAGGKmh0dHA6Ly9vY3NwLmFwcGxlLmNvbS9vY3NwMDQtYXBwbGVyb290Y2FnMzAdBgNVHQXXXXUI/JJxE+T5O8n5sT2KGw/orv9LkswDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS7sN6hWDOImqSKmd6+veuv2sskqzA3BgNVHR8EMDAuMCygKqAohiZodHRwOi8vY3JsLmFwcGxlLmNvbS9hcHBsZXJvb3RjYWczLmNybDAOBgXXXX8BAf8EBAMCAQYwEAYKKoZIhvdjZAYCDgQCBQAwCgYIKoZIzj0EAwIDZwAwZAIwOs9yg1EWmbGG+zXDVspiv/QX7dkPdU2ijr7xnIFeQreJ+Jj3m1mfmNVBDY+d6cL+AjAyLdVEIbCjBXdsXfM4O5Bn/Rd8LCFtlk/GcmmCEm9U+Hp9G5nLmwmJIWEGmQ8Jkh0XXXXCAYwwggGIAgEBMIGGMHoxLjAsBgNVBAMMJUFwcGxlIXXXXGxpY2F0aW9uIEludGVncmF0aW9uIENBIC0gRzMxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMwEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUwIIWdihvKr0480wDQYJYIZIAWUDBAIBBQCggZUwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMjEwNTA1MDk0NTMxWjAqBgkqhkiG9w0BCTQxHTAbMA0GCWCGSAFlAwQCAQUAoQoGCCqGSM49BAMCMC8GCSqGSIb3DQEJBDEiBCDvQVDhC5JuNew7wc4LCTf3m3UuhTbYpDCTUXn2+DJ+EzAKBggqhkjOPQQDAgRHMEUCICKMGsj9v/6KcCENaXtHQawWi3rS8Y5Oo/FLaC3TSO04AiEA4dlmVIniu4X4fme+AY7XJHcG11e1glVFW0msnQP18/sAAAAAAAA=\",\"header\":{\"ephemeralPublicKey\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEMtiXUxCDL9zrWc7+rscObEhZy/ED/LvrXmdL3zdQOT/Mk/vvb6OjhXYUfmPgF17zhTAaJrk8jrYDRqHuI/FYMA==\",\"publicKeyHash\":\"zqO5Y3ldWWm4NnIkfGCvJILw30rp3y46Jsf21gE8CNg=\",\"transactionId\":\"4bffc6XXXXf11d3f60fffXXX2f98cbea13b1de7d2efXXXX2fbbb98b18ca6ff20\"}}"; @@ -33,7 +37,7 @@ public void testCreateApplePayTypeFromJson() throws JsonProcessingException { } @Test - public void testCreateApplepayType() { + void testCreateApplepayType() { Applepay applepay = getApplePay(); Applepay response = getUnzer().createPaymentType(applepay); @@ -46,7 +50,7 @@ public void testCreateApplepayType() { } @Test - public void testCreateApplepayTypeAndFetch() { + void testCreateApplepayTypeAndFetch() { Applepay applepay = getApplePay(); applepay = getUnzer().createPaymentType(applepay); @@ -67,7 +71,7 @@ public void testCreateApplepayTypeAndFetch() { } @Test - public void testAuthorizeApplePayType() { + void testAuthorizeApplePayType() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Authorization authorization = applepay.authorize(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); assertNotNull(authorization); @@ -76,7 +80,7 @@ public void testAuthorizeApplePayType() { } @Test - public void testAuthorizeApplePayTypeAndCancel() { + void testAuthorizeApplePayTypeAndCancel() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Authorization authorization = applepay.authorize(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); Cancel cancel = authorization.cancel(); @@ -87,7 +91,7 @@ public void testAuthorizeApplePayTypeAndCancel() { } @Test - public void testAuthorizeApplePayTypeWithBigAmount() { + void testAuthorizeApplePayTypeWithBigAmount() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Authorization authorization = applepay.authorize(BigDecimal.valueOf(10000L), Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); assertNotNull(authorization); @@ -96,7 +100,7 @@ public void testAuthorizeApplePayTypeWithBigAmount() { } @Test - public void testAuthorizeApplePayTypeWithZeroAmount() { + void testAuthorizeApplePayTypeWithZeroAmount() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); try { @@ -107,7 +111,7 @@ public void testAuthorizeApplePayTypeWithZeroAmount() { } @Test - public void testAuthorizeApplePayTypeId() { + void testAuthorizeApplePayTypeId() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Authorization authorization = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), applepay.getId(), unsafeUrl("https://www.meinShop.de")); assertNotNull(authorization); @@ -116,7 +120,7 @@ public void testAuthorizeApplePayTypeId() { } @Test - public void testAuthorizeApplePayTypeIdAndCancel() { + void testAuthorizeApplePayTypeIdAndCancel() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Authorization authorization = getUnzer().authorize(BigDecimal.ONE, Currency.getInstance("EUR"), applepay.getId(), unsafeUrl("https://www.meinShop.de")); Cancel cancel = getUnzer().cancelAuthorization(authorization.getPaymentId()); @@ -127,7 +131,7 @@ public void testAuthorizeApplePayTypeIdAndCancel() { } @Test - public void testAuthorizeApplePayTypeIdWithBigAmount() { + void testAuthorizeApplePayTypeIdWithBigAmount() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Authorization authorization = getUnzer().authorize(BigDecimal.valueOf(10000L), Currency.getInstance("EUR"), applepay.getId(), unsafeUrl("https://www.meinShop.de")); assertNotNull(authorization); @@ -136,7 +140,7 @@ public void testAuthorizeApplePayTypeIdWithBigAmount() { } @Test - public void testAuthorizeApplePayTypeIdWithZeroAmount() { + void testAuthorizeApplePayTypeIdWithZeroAmount() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); try { @@ -147,7 +151,7 @@ public void testAuthorizeApplePayTypeIdWithZeroAmount() { } @Test - public void testChargeApplePayType() { + void testChargeApplePayType() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Charge charge = applepay.charge(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); assertNotNull(charge); @@ -156,7 +160,7 @@ public void testChargeApplePayType() { } @Test - public void testChargeApplePayTypeAndFullCancel() { + void testChargeApplePayTypeAndFullCancel() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Charge charge = applepay.charge(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); Cancel cancel = getUnzer().cancelCharge(charge.getPaymentId(), charge.getId()); @@ -167,7 +171,7 @@ public void testChargeApplePayTypeAndFullCancel() { } @Test - public void testChargeApplePayTypeAndPartialCancel() { + void testChargeApplePayTypeAndPartialCancel() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Charge charge = applepay.charge(BigDecimal.TEN, Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); Cancel cancel = getUnzer().cancelCharge(charge.getPaymentId(), charge.getId(), BigDecimal.ONE); @@ -178,7 +182,7 @@ public void testChargeApplePayTypeAndPartialCancel() { } @Test - public void testChargeApplePayTypeAndPartialAndFullCancel() { + void testChargeApplePayTypeAndPartialAndFullCancel() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Charge charge = applepay.charge(BigDecimal.TEN, Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); Cancel partialCancel = getUnzer().cancelCharge(charge.getPaymentId(), charge.getId(), BigDecimal.ONE); @@ -193,7 +197,7 @@ public void testChargeApplePayTypeAndPartialAndFullCancel() { } @Test - public void testChargeApplePayTypeWithBigAmount() { + void testChargeApplePayTypeWithBigAmount() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Charge charge = applepay.charge(BigDecimal.valueOf(10000L), Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); assertNotNull(charge); @@ -202,7 +206,7 @@ public void testChargeApplePayTypeWithBigAmount() { } @Test - public void testChargeApplePayTypeWithZeroAmount() { + void testChargeApplePayTypeWithZeroAmount() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); try { applepay.charge(BigDecimal.ZERO, Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); @@ -212,7 +216,7 @@ public void testChargeApplePayTypeWithZeroAmount() { } @Test - public void testChargeApplePayTypeId() { + void testChargeApplePayTypeId() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), applepay.getId(), unsafeUrl("https://www.meinShop.de")); assertNotNull(charge); @@ -221,7 +225,7 @@ public void testChargeApplePayTypeId() { } @Test - public void testChargeApplePayTypeIdAndFullCancel() { + void testChargeApplePayTypeIdAndFullCancel() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), applepay.getId(), unsafeUrl("https://www.meinShop.de")); Cancel cancel = getUnzer().cancelCharge(charge.getPaymentId(), charge.getId()); @@ -232,7 +236,7 @@ public void testChargeApplePayTypeIdAndFullCancel() { } @Test - public void testChargeApplePayTypeIdAndPartialCancel() { + void testChargeApplePayTypeIdAndPartialCancel() { Unzer unzer = getUnzer(); Applepay applepay = unzer.createPaymentType(getApplePay()); Charge charge = unzer.charge(BigDecimal.TEN, Currency.getInstance("EUR"), applepay.getId(), unsafeUrl("https://www.meinShop.de")); @@ -244,7 +248,7 @@ public void testChargeApplePayTypeIdAndPartialCancel() { } @Test - public void testChargeApplePayTypeIdAndPartialAndFullCancel() { + void testChargeApplePayTypeIdAndPartialAndFullCancel() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Charge charge = getUnzer().charge(BigDecimal.TEN, Currency.getInstance("EUR"), applepay.getId(), unsafeUrl("https://www.meinShop.de")); Cancel partialCancel = getUnzer().cancelCharge(charge.getPaymentId(), charge.getId(), BigDecimal.ONE); @@ -259,7 +263,7 @@ public void testChargeApplePayTypeIdAndPartialAndFullCancel() { } @Test - public void testChargeApplePayTypeIdWithBigAmount() { + void testChargeApplePayTypeIdWithBigAmount() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); Charge charge = getUnzer().charge(BigDecimal.valueOf(10000L), Currency.getInstance("EUR"), applepay.getId(), unsafeUrl("https://www.meinShop.de")); assertNotNull(charge); @@ -268,7 +272,7 @@ public void testChargeApplePayTypeIdWithBigAmount() { } @Test - public void testChargeApplePayTypeIdWithZeroAmount() { + void testChargeApplePayTypeIdWithZeroAmount() { Applepay applepay = getUnzer().createPaymentType(getApplePay()); try { getUnzer().charge(BigDecimal.ZERO, Currency.getInstance("EUR"), applepay.getId(), unsafeUrl("https://www.meinShop.de")); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/BancontactTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/BancontactTest.java index d315f3f0..ec3681c4 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/BancontactTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/BancontactTest.java @@ -15,17 +15,17 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -public class BancontactTest extends AbstractPaymentTest { +class BancontactTest extends AbstractPaymentTest { @Test - public void testCreateBancontactWithoutHolder() { + void testCreateBancontactWithoutHolder() { Bancontact bacncontact = new Bancontact(); bacncontact = getUnzer().createPaymentType(bacncontact); assertNotNull(bacncontact.getId()); } @Test - public void testCreateBancontactWithHolder() { + void testCreateBancontactWithHolder() { Bancontact bancontact = new Bancontact("test holder"); bancontact = getUnzer().createPaymentType(bancontact); assertNotNull(bancontact.getId()); @@ -33,7 +33,7 @@ public void testCreateBancontactWithHolder() { } @Test - public void testChargeBancontactType() { + void testChargeBancontactType() { Unzer unzer = getUnzer(); Bancontact bancontact = unzer.createPaymentType(new Bancontact()); Charge charge = unzer.charge( @@ -48,7 +48,7 @@ public void testChargeBancontactType() { } @Test - public void testFetchBancontactType() { + void testFetchBancontactType() { Bancontact bancontact = getUnzer().createPaymentType(new Bancontact()); assertNotNull(bancontact.getId()); Bancontact fetchedBancontact = (Bancontact) getUnzer().fetchPaymentType(bancontact.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/CardTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/CardTest.java index bc259cb6..e2cd60fa 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/CardTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/CardTest.java @@ -1,6 +1,13 @@ package com.unzer.payment.integration.paymenttypes; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Charge; +import com.unzer.payment.Payment; +import com.unzer.payment.PaymentException; +import com.unzer.payment.Preauthorization; +import com.unzer.payment.Recurring; +import com.unzer.payment.Unzer; import com.unzer.payment.business.AbstractPaymentTest; import com.unzer.payment.communication.impl.HttpClientBasedRestCommunication; import com.unzer.payment.enums.RecurrenceType; @@ -20,14 +27,19 @@ import static com.unzer.payment.business.Keys.ALT_LEGACY_PRIVATE_KEY; import static com.unzer.payment.util.Types.unsafeUrl; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.DynamicTest.dynamicTest; class CardTest extends AbstractPaymentTest { @Test - public void testCreateCardWithMerchantNotPCIDSSCompliant() { + void testCreateCardWithMerchantNotPCIDSSCompliant() { assertThrows(PaymentException.class, () -> { Card card = new Card("4444333322221111", "03/20"); card.setCvc("123"); @@ -37,7 +49,7 @@ public void testCreateCardWithMerchantNotPCIDSSCompliant() { } @Test - public void testCreateCardType() { + void testCreateCardType() { Card card = new Card("4444333322221111", "03/99"); card.setCvc("123"); card.setCardHolder("Beethoven"); @@ -58,7 +70,7 @@ public void testCreateCardType() { } @Test - public void testCreateCardTypeWith3DSFlag() { + void testCreateCardTypeWith3DSFlag() { Card card = new Card("4444333322221111", "03/99"); card.setCvc("123"); card.set3ds(false); @@ -71,7 +83,7 @@ public void testCreateCardTypeWith3DSFlag() { } @Test - public void testPreauthorizeAndPaymentCardType() { + void testPreauthorizeAndPaymentCardType() { Card card = new Card("4444333322221111", "03/99"); card.setCvc("123"); Unzer unzer = getUnzer(); @@ -90,7 +102,7 @@ public void testPreauthorizeAndPaymentCardType() { } @Test - public void testAuthorizeAndPaymentCardType() { + void testAuthorizeAndPaymentCardType() { Card card = new Card("4444333322221111", "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -102,7 +114,7 @@ public void testAuthorizeAndPaymentCardType() { } @Test - public void testChargeCardType() { + void testChargeCardType() { Card card = new Card("4444333322221111", "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -111,7 +123,7 @@ public void testChargeCardType() { } @Test - public void testChargeCardTypeWith3ds() { + void testChargeCardTypeWith3ds() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -120,7 +132,7 @@ public void testChargeCardTypeWith3ds() { } @Test - public void testFetchCardType() { + void testFetchCardType() { Card card = new Card("4444333322221111", "03/2099"); card.setCvc("123"); card.setCardHolder("Mozart"); @@ -154,7 +166,7 @@ public void testFetchCardType() { } @Test - public void testCardMailEmptyWhenNotSending() { + void testCardMailEmptyWhenNotSending() { Card card = new Card("4444333322221111", "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -163,7 +175,7 @@ public void testCardMailEmptyWhenNotSending() { } @Test - public void testCardMailNotEmptyWhenSending() { + void testCardMailNotEmptyWhenSending() { Card card = new Card("4444333322221111", "03/99"); card.setCvc("123"); card.setEmail(MAIL_STRING); @@ -177,7 +189,7 @@ public void testCardMailNotEmptyWhenSending() { @Disabled("PAPI disallows removing email") @Test - public void testCardMailEmptyWhenOverridingWithNull() { + void testCardMailEmptyWhenOverridingWithNull() { Card card = new Card("4444333322221111", "03/99"); card.setCvc("123"); card.setEmail(MAIL_STRING); @@ -195,7 +207,7 @@ public void testCardMailEmptyWhenOverridingWithNull() { } @Test - public void testCardMailOverridingWithValue() { + void testCardMailOverridingWithValue() { Unzer unzer = getUnzer(); Card card = new Card("4444333322221111", "03/99"); card.setCvc("123"); @@ -215,7 +227,7 @@ public void testCardMailOverridingWithValue() { } @Test - public void testCardMailInvalidValue() { + void testCardMailInvalidValue() { Card card = new Card("4444333322221111", "03/99"); card.setCvc("123"); card.setEmail(INVALID_MAIL_STRING); @@ -230,7 +242,7 @@ public void testCardMailInvalidValue() { } @Test - public void testCardRegisterRecurring() { + void testCardRegisterRecurring() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -242,7 +254,7 @@ public void testCardRegisterRecurring() { } @Test - public void testCardRegisterRecurringAdditionalPaymentInformationScheduled() { + void testCardRegisterRecurringAdditionalPaymentInformationScheduled() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -255,7 +267,7 @@ public void testCardRegisterRecurringAdditionalPaymentInformationScheduled() { } @Test - public void testCardRegisterRecurringAdditionalPaymentInformationUnscheduled() { + void testCardRegisterRecurringAdditionalPaymentInformationUnscheduled() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -268,7 +280,7 @@ public void testCardRegisterRecurringAdditionalPaymentInformationUnscheduled() { } @Test - public void testCardAuthorizeAdditionalTransactionDataRecurrenceOneClick() { + void testCardAuthorizeAdditionalTransactionDataRecurrenceOneClick() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -282,7 +294,7 @@ public void testCardAuthorizeAdditionalTransactionDataRecurrenceOneClick() { } @Test - public void testCardAuthorizeAdditionalTransactionDataRecurrenceOneClickWithout3DS() { + void testCardAuthorizeAdditionalTransactionDataRecurrenceOneClickWithout3DS() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -297,7 +309,7 @@ public void testCardAuthorizeAdditionalTransactionDataRecurrenceOneClickWithout3 } @Test - public void testCardChargeAdditionalTransactionDataRecurrenceOneClick() { + void testCardChargeAdditionalTransactionDataRecurrenceOneClick() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -311,7 +323,7 @@ public void testCardChargeAdditionalTransactionDataRecurrenceOneClick() { } @Test - public void testCardChargeAdditionalTransactionDataRecurrenceOneClickWithout3DS() { + void testCardChargeAdditionalTransactionDataRecurrenceOneClickWithout3DS() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -326,7 +338,7 @@ public void testCardChargeAdditionalTransactionDataRecurrenceOneClickWithout3DS( } @Test - public void testCardAuthorizeAdditionalTransactionDataRecurrenceScheduled() { + void testCardAuthorizeAdditionalTransactionDataRecurrenceScheduled() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -340,7 +352,7 @@ public void testCardAuthorizeAdditionalTransactionDataRecurrenceScheduled() { } @Test - public void testCardAuthorizeAdditionalTransactionDataRecurrenceScheduledWithout3DS() { + void testCardAuthorizeAdditionalTransactionDataRecurrenceScheduledWithout3DS() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -355,7 +367,7 @@ public void testCardAuthorizeAdditionalTransactionDataRecurrenceScheduledWithout } @Test - public void testCardChargeAdditionalTransactionDataRecurrenceScheduled() { + void testCardChargeAdditionalTransactionDataRecurrenceScheduled() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -369,7 +381,7 @@ public void testCardChargeAdditionalTransactionDataRecurrenceScheduled() { } @Test - public void testCardChargeAdditionalTransactionDataRecurrenceScheduledWithout3DS() { + void testCardChargeAdditionalTransactionDataRecurrenceScheduledWithout3DS() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -384,7 +396,7 @@ public void testCardChargeAdditionalTransactionDataRecurrenceScheduledWithout3DS } @Test - public void testCardAuthorizeAdditionalTransactionDataRecurrenceUnscheduled() { + void testCardAuthorizeAdditionalTransactionDataRecurrenceUnscheduled() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -398,7 +410,7 @@ public void testCardAuthorizeAdditionalTransactionDataRecurrenceUnscheduled() { } @Test - public void testCardAuthorizeAdditionalTransactionDataRecurrenceUnscheduledWithout3DS() { + void testCardAuthorizeAdditionalTransactionDataRecurrenceUnscheduledWithout3DS() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -413,7 +425,7 @@ public void testCardAuthorizeAdditionalTransactionDataRecurrenceUnscheduledWitho } @Test - public void testCardChargeAdditionalTransactionDataRecurrenceUnscheduled() { + void testCardChargeAdditionalTransactionDataRecurrenceUnscheduled() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); @@ -427,7 +439,7 @@ public void testCardChargeAdditionalTransactionDataRecurrenceUnscheduled() { } @Test - public void testCardChargeAdditionalTransactionDataRecurrenceUnscheduledWithout3DS() { + void testCardChargeAdditionalTransactionDataRecurrenceUnscheduledWithout3DS() { Card card = new Card(VISA_3DS_ENABLED_CARD_NUMBER, "03/99"); card.setCvc("123"); card = getUnzer().createPaymentType(card); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/EpsTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/EpsTest.java index f8a21c9a..ffd4805a 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/EpsTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/EpsTest.java @@ -12,24 +12,24 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class EpsTest extends AbstractPaymentTest { +class EpsTest extends AbstractPaymentTest { @Test - public void testCreateEpsWithoutBicType() { + void testCreateEpsWithoutBicType() { Eps eps = new Eps(); eps = getUnzer().createPaymentType(eps); assertNotNull(eps.getId()); } @Test - public void testCreateEpsWithBicType() { + void testCreateEpsWithBicType() { Eps eps = new Eps("SPFKAT2BXXX"); eps = getUnzer().createPaymentType(eps); assertNotNull(eps.getId()); } @Test - public void testChargeEpsType() { + void testChargeEpsType() { Eps eps = getUnzer().createPaymentType(getEps()); Charge charge = eps.charge(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.unzer.com")); assertNotNull(charge); @@ -38,7 +38,7 @@ public void testChargeEpsType() { } @Test - public void testFetchEpsType() { + void testFetchEpsType() { Eps eps = getUnzer().createPaymentType(getEps()); assertNotNull(eps.getId()); Eps fetchedEps = (Eps) getUnzer().fetchPaymentType(eps.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/GiropayTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/GiropayTest.java index a037f376..193223c3 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/GiropayTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/GiropayTest.java @@ -12,17 +12,17 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class GiropayTest extends AbstractPaymentTest { +class GiropayTest extends AbstractPaymentTest { @Test - public void testCreateGiropayManatoryType() { + void testCreateGiropayManatoryType() { Giropay giropay = new Giropay(); giropay = getUnzer().createPaymentType(giropay); assertNotNull(giropay.getId()); } @Test - public void testChargeGiropayType() { + void testChargeGiropayType() { Giropay giropay = getUnzer().createPaymentType(getGiropay()); Charge charge = giropay.charge(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.unzer.com")); assertNotNull(charge); @@ -31,7 +31,7 @@ public void testChargeGiropayType() { } @Test - public void testFetchGiropayType() { + void testFetchGiropayType() { Giropay giropay = getUnzer().createPaymentType(getGiropay()); assertNotNull(giropay.getId()); Giropay fetchedGiropay = (Giropay) getUnzer().fetchPaymentType(giropay.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/IdealTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/IdealTest.java index f11b378c..1a29a2c6 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/IdealTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/IdealTest.java @@ -13,16 +13,16 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class IdealTest extends AbstractPaymentTest { +class IdealTest extends AbstractPaymentTest { @Test - public void testCreateIdealManatoryType() { + void testCreateIdealManatoryType() { Ideal ideal = getUnzer().createPaymentType(getIdeal()); assertNotNull(ideal.getId()); } @Test - public void testChargeIdealType() { + void testChargeIdealType() { Ideal ideal = getUnzer(Keys.LEGACY_PRIVATE_KEY).createPaymentType(getIdeal()); Charge charge = ideal.charge(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.unzer.com")); @@ -32,7 +32,7 @@ public void testChargeIdealType() { } @Test - public void testFetchIdealType() { + void testFetchIdealType() { Ideal ideal = getUnzer().createPaymentType(getIdeal()); assertNotNull(ideal.getId()); Ideal fetchedIdeal = (Ideal) getUnzer().fetchPaymentType(ideal.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/InstallmentSecuredTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/InstallmentSecuredTest.java index 3e652eb8..c658479c 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/InstallmentSecuredTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/InstallmentSecuredTest.java @@ -1,6 +1,12 @@ package com.unzer.payment.integration.paymenttypes; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.Basket; +import com.unzer.payment.Cancel; +import com.unzer.payment.Charge; +import com.unzer.payment.Customer; +import com.unzer.payment.Shipment; +import com.unzer.payment.Unzer; import com.unzer.payment.business.AbstractPaymentTest; import com.unzer.payment.business.Keys; import com.unzer.payment.business.paymenttypes.InstallmentSecuredRatePlan; @@ -26,13 +32,15 @@ import static com.unzer.payment.business.BasketV2TestData.getMaxTestBasketV2; import static com.unzer.payment.util.Types.unsafeUrl; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class InstallmentSecuredTest extends AbstractPaymentTest { +class InstallmentSecuredTest extends AbstractPaymentTest { @Test - public void testRateRetrieval() { + void testRateRetrieval() { BigDecimal effectiveInterestRate = new BigDecimal("5.5").setScale(4, RoundingMode.HALF_UP); Date orderDate = getDate("21.06.2019"); Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); @@ -208,7 +216,7 @@ private BigDecimal getAmount() { @Disabled("https://unz.atlassian.net/browse/AHC-5292") @Test - public void testAuthorizeViaTypeWithIbanBasketV2() + void testAuthorizeViaTypeWithIbanBasketV2() throws HttpCommunicationException, ParseException { InstallmentSecuredRatePlan ratePlan = getInstallmentSecuredRatePlan(); addIbanInvoiceParameter(ratePlan); @@ -270,7 +278,7 @@ protected Authorization getAuthorization(String typeId, String customerId, Strin @Disabled("https://unz.atlassian.net/browse/AHC-5292") @Test - public void testAuthorizeViaUnzerTypeIdWithIbanBasketV2() + void testAuthorizeViaUnzerTypeIdWithIbanBasketV2() throws HttpCommunicationException, ParseException, MalformedURLException { InstallmentSecuredRatePlan ratePlan = getInstallmentSecuredRatePlan(); addIbanInvoiceParameter(ratePlan); @@ -326,7 +334,7 @@ private void assertValidCharge(Charge charge) { @Disabled("https://unz.atlassian.net/browse/AHC-5292") @Test - public void testChargeViaAuthorizeBasketV2() throws HttpCommunicationException, ParseException { + void testChargeViaAuthorizeBasketV2() throws HttpCommunicationException, ParseException { Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); InstallmentSecuredRatePlan ratePlan = unzer.createPaymentType(getInstallmentSecuredRatePlan()); @@ -386,7 +394,7 @@ private void assertValidCancel(Cancel cancel, BigDecimal cancellationAmount) { @Disabled("https://unz.atlassian.net/browse/AHC-5292") @Test - public void testFullCancellationBeforeShipmentBasketV2() + void testFullCancellationBeforeShipmentBasketV2() throws HttpCommunicationException, ParseException { Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); InstallmentSecuredRatePlan ratePlan = @@ -447,7 +455,7 @@ public void testPartialCancellationBeforeShipmentBasketV1() @Disabled("https://unz.atlassian.net/browse/AHC-5292") @Test - public void testPartialCancellationBeforeShipmentBasketV2() + void testPartialCancellationBeforeShipmentBasketV2() throws HttpCommunicationException, ParseException { Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); InstallmentSecuredRatePlan ratePlan = @@ -510,7 +518,7 @@ private void assertValidShipment(Shipment shipment) { @Disabled("https://unz.atlassian.net/browse/AHC-5292") @Test - public void testShipmentBasketV2() throws HttpCommunicationException, ParseException { + void testShipmentBasketV2() throws HttpCommunicationException, ParseException { InstallmentSecuredRatePlan ratePlan = getInstallmentSecuredRatePlan(); addIbanInvoiceParameter(ratePlan); Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); @@ -568,7 +576,7 @@ public void testFullCancelAfterShipmentBasketV1() @Disabled("Until https://unz.atlassian.net/browse/AHC-5292 is resolved") @Test - public void testFullCancelAfterShipmentBasketV2() + void testFullCancelAfterShipmentBasketV2() throws HttpCommunicationException, ParseException { InstallmentSecuredRatePlan ratePlan = getInstallmentSecuredRatePlan(); addIbanInvoiceParameter(ratePlan); @@ -646,7 +654,7 @@ private InstallmentSecuredRatePlan getInstallmentSecuredRatePlan(BigDecimal amou @Disabled("https://unz.atlassian.net/browse/AHC-5292") @Test - public void testAuthorizeHirePurchaseDirectDebitBasketV2() + void testAuthorizeHirePurchaseDirectDebitBasketV2() throws HttpCommunicationException, ParseException { Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); HttpClientBasedRestCommunication restCommunication = new HttpClientBasedRestCommunication(); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/InvoiceSecuredTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/InvoiceSecuredTest.java index e3b4fe73..c90f8d65 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/InvoiceSecuredTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/InvoiceSecuredTest.java @@ -1,7 +1,13 @@ package com.unzer.payment.integration.paymenttypes; -import com.unzer.payment.*; +import com.unzer.payment.Basket; +import com.unzer.payment.Cancel; +import com.unzer.payment.Charge; +import com.unzer.payment.PaymentError; +import com.unzer.payment.PaymentException; +import com.unzer.payment.Shipment; +import com.unzer.payment.Unzer; import com.unzer.payment.business.AbstractPaymentTest; import com.unzer.payment.business.Keys; import com.unzer.payment.communication.HttpCommunicationException; @@ -29,10 +35,13 @@ import static com.unzer.payment.business.BasketV2TestData.getMinTestBasketV2; import static com.unzer.payment.util.Types.unsafeUrl; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.DynamicTest.dynamicTest; -public class InvoiceSecuredTest extends AbstractPaymentTest { +class InvoiceSecuredTest extends AbstractPaymentTest { @Test @Disabled("deprecated") @@ -64,7 +73,7 @@ public void testChargeTypeWithInvoiceIdBasketV2() throws HttpCommunicationExcept } @Test - public void testCreateInvoiceSecuredMandatoryType() { + void testCreateInvoiceSecuredMandatoryType() { InvoiceSecured invoice = getUnzer(Keys.LEGACY_PRIVATE_KEY).createPaymentType(getInvoiceSecured()); assertNotNull(invoice.getId()); } @@ -101,7 +110,7 @@ public void testChargeTypeWithInvalidCurrencyBasketV1() { } @Test - public void testChargeTypeWithInvalidCurrencyBasketV2() { + void testChargeTypeWithInvalidCurrencyBasketV2() { InvoiceSecured invoice = getUnzer(Keys.LEGACY_PRIVATE_KEY).createPaymentType(getInvoiceSecured()); Basket basket = getMinTestBasketV2(); assertThrows(PaymentException.class, () -> { @@ -111,7 +120,7 @@ public void testChargeTypeWithInvalidCurrencyBasketV2() { @Test - public void testChargeTypeDifferentAddresses() { + void testChargeTypeDifferentAddresses() { InvoiceSecured invoice = getUnzer(Keys.LEGACY_PRIVATE_KEY).createPaymentType(getInvoiceSecured()); assertThrows(PaymentException.class, () -> { invoice.charge(BigDecimal.TEN, Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de"), getMaximumCustomer(generateUuid())); @@ -147,7 +156,7 @@ public void testShipmentInvoiceSecuredTypeBasketV2() throws HttpCommunicationExc @Test - public void testFetchInvoiceSecuredType() { + void testFetchInvoiceSecuredType() { InvoiceSecured invoice = getUnzer(Keys.LEGACY_PRIVATE_KEY).createPaymentType(getInvoiceSecured()); assertNotNull(invoice.getId()); InvoiceSecured fetchedInvoiceSecured = (InvoiceSecured) getUnzer(Keys.LEGACY_PRIVATE_KEY).fetchPaymentType(invoice.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/InvoiceTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/InvoiceTest.java index e3f92d33..f9b6a76d 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/InvoiceTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/InvoiceTest.java @@ -14,16 +14,16 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class InvoiceTest extends AbstractPaymentTest { +class InvoiceTest extends AbstractPaymentTest { @Test - public void testCreateInvoiceMandatoryType() { + void testCreateInvoiceMandatoryType() { Invoice invoice = getUnzer(LEGACY_PRIVATE_KEY).createPaymentType(new Invoice()); assertNotNull(invoice.getId()); } @Test - public void testChargeType() { + void testChargeType() { Invoice invoice = getUnzer(LEGACY_PRIVATE_KEY).createPaymentType(new Invoice()); Charge charge = invoice.charge(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); assertNotNull(charge); @@ -31,7 +31,7 @@ public void testChargeType() { } @Test - public void testFetchInvoiceType() { + void testFetchInvoiceType() { Unzer unzer = getUnzer(LEGACY_PRIVATE_KEY); Invoice invoice = unzer.createPaymentType(new Invoice()); assertNotNull(invoice.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/KlarnaTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/KlarnaTest.java index 4fd1ffdf..49489984 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/KlarnaTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/KlarnaTest.java @@ -35,16 +35,16 @@ import static org.junit.jupiter.api.DynamicTest.dynamicTest; -public class KlarnaTest extends AbstractPaymentTest { +class KlarnaTest extends AbstractPaymentTest { @Test - public void testCreatePaymentType() { + void testCreatePaymentType() { Klarna klarna = getUnzer().createPaymentType(new Klarna()); assertNotNull(klarna); assertNotNull(klarna.getId()); } @Test - public void testFetchPaymentType() { + void testFetchPaymentType() { Klarna paymentType = getUnzer().createPaymentType(new Klarna()); assertNotNull(paymentType.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/OpenBankingTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/OpenBankingTest.java index baee751d..66ab653d 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/OpenBankingTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/OpenBankingTest.java @@ -3,6 +3,7 @@ import com.unzer.payment.Charge; import com.unzer.payment.business.AbstractPaymentTest; import com.unzer.payment.paymenttypes.OpenBanking; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.math.BigDecimal; @@ -11,16 +12,17 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class OpenBankingTest extends AbstractPaymentTest { +@Disabled("Missing keypair config") +class OpenBankingTest extends AbstractPaymentTest { @Test - public void testCreateOpenBankingType() { + void testCreateOpenBankingType() { OpenBanking openBanking = new OpenBanking("DE"); openBanking = getUnzer().createPaymentType(openBanking); assertNotNull(openBanking.getId()); } @Test - public void testChargeOpenBankingType() { + void testChargeOpenBankingType() { OpenBanking openBanking = getUnzer().createPaymentType(new OpenBanking("DE")); Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("EUR"), openBanking.getId(), unsafeUrl("https://www.unzer.com")); assertNotNull(charge); @@ -29,7 +31,7 @@ public void testChargeOpenBankingType() { } @Test - public void testFetchOpenBankingType() { + void testFetchOpenBankingType() { OpenBanking openBanking = getUnzer().createPaymentType(new OpenBanking("DE")); assertNotNull(openBanking.getId()); OpenBanking fetchedopenBanking = (OpenBanking) getUnzer().fetchPaymentType(openBanking.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/PayUTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/PayUTest.java index 5a921110..2c86bc90 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/PayUTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/PayUTest.java @@ -19,10 +19,10 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.DynamicTest.dynamicTest; -public class PayUTest extends AbstractPaymentTest { +class PayUTest extends AbstractPaymentTest { @Test - public void create_payment_type() { + void create_payment_type() { Unzer unzer = getUnzer(); PayU payU = new PayU(); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterDirectDebitTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterDirectDebitTest.java index 703c86c0..c81fb8d1 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterDirectDebitTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterDirectDebitTest.java @@ -1,6 +1,10 @@ package com.unzer.payment.integration.paymenttypes; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Charge; +import com.unzer.payment.Customer; +import com.unzer.payment.Unzer; import com.unzer.payment.business.AbstractPaymentTest; import com.unzer.payment.paymenttypes.PaylaterDirectDebit; import org.junit.jupiter.api.Test; @@ -14,9 +18,9 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -public class PaylaterDirectDebitTest extends AbstractPaymentTest { +class PaylaterDirectDebitTest extends AbstractPaymentTest { @Test - public void create_and_fetch_payment_type_ok() { + void create_and_fetch_payment_type_ok() { Unzer unzer = getUnzer(); PaylaterDirectDebit type = new PaylaterDirectDebit( "DE89370400440532013000", @@ -32,7 +36,7 @@ public void create_and_fetch_payment_type_ok() { } @Test - public void authorize_and_charge_ok() { + void authorize_and_charge_ok() { Unzer unzer = getUnzer(); PaylaterDirectDebit type = unzer.createPaymentType( new PaylaterDirectDebit( diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterInstallmentTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterInstallmentTest.java index 78f72b67..8bbc6f92 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterInstallmentTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterInstallmentTest.java @@ -1,6 +1,13 @@ package com.unzer.payment.integration.paymenttypes; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Basket; +import com.unzer.payment.BasketItem; +import com.unzer.payment.Cancel; +import com.unzer.payment.Charge; +import com.unzer.payment.Customer; +import com.unzer.payment.PaylaterInstallmentPlans; import com.unzer.payment.business.AbstractPaymentTest; import com.unzer.payment.communication.HttpCommunicationException; import com.unzer.payment.models.CustomerType; @@ -17,13 +24,18 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class PaylaterInstallmentTest extends AbstractPaymentTest { +class PaylaterInstallmentTest extends AbstractPaymentTest { @Test - public void testRateRetrievalUrl() { + void testRateRetrievalUrl() { BigDecimal amount = new BigDecimal("33.33"); InstallmentPlansRequest request = new InstallmentPlansRequest(amount, "EUR", "DE", CustomerType.B2C); @@ -35,7 +47,7 @@ public void testRateRetrievalUrl() { } @Test - public void testFetchInstallmentPlans() { + void testFetchInstallmentPlans() { BigDecimal amount = new BigDecimal("99.99"); InstallmentPlansRequest request = new InstallmentPlansRequest(amount, "EUR", "DE", CustomerType.B2C); @@ -66,7 +78,7 @@ private void assertPlans(List plans) { } @Test - public void testCreatePaylaterInstallmentTypeWithAllParameter() { + void testCreatePaylaterInstallmentTypeWithAllParameter() { PaylaterInstallmentPlans installmentPlans = getPaylaterInstallmentPlans(); InstallmentPlan selectedPlan = installmentPlans.getPlans().get(0); @@ -103,7 +115,7 @@ private BigDecimal getOrderAmount() { } @Test - public void testAuthorize() throws HttpCommunicationException, ParseException { + void testAuthorize() throws HttpCommunicationException, ParseException { PaylaterInstallmentPlans installmentPlans = getPaylaterInstallmentPlans(); InstallmentPlan selectedPlan = installmentPlans.getPlans().get(0); @@ -158,7 +170,7 @@ protected Authorization getAuthorization(String typeId, String customerId, Strin } @Test - public void testFullCharge() throws HttpCommunicationException, ParseException { + void testFullCharge() throws HttpCommunicationException, ParseException { PaylaterInstallmentPlans installmentPlans = getPaylaterInstallmentPlans(); InstallmentPlan selectedPlan = installmentPlans.getPlans().get(0); @@ -188,7 +200,7 @@ public void testFullCharge() throws HttpCommunicationException, ParseException { } @Test - public void testPartialCharge() throws HttpCommunicationException, ParseException { + void testPartialCharge() throws HttpCommunicationException, ParseException { PaylaterInstallmentPlans installmentPlans = getPaylaterInstallmentPlans(); InstallmentPlan selectedPlan = installmentPlans.getPlans().get(0); @@ -222,7 +234,7 @@ public void testPartialCharge() throws HttpCommunicationException, ParseExceptio } @Test - public void testFullCancelAfterAuthorization() throws HttpCommunicationException, ParseException { + void testFullCancelAfterAuthorization() throws HttpCommunicationException, ParseException { PaylaterInstallmentPlans installmentPlans = getPaylaterInstallmentPlans(); InstallmentPlan selectedPlan = installmentPlans.getPlans().get(0); @@ -253,7 +265,7 @@ public void testFullCancelAfterAuthorization() throws HttpCommunicationException } @Test - public void testFullCancelAfterCharge() throws HttpCommunicationException, ParseException { + void testFullCancelAfterCharge() throws HttpCommunicationException, ParseException { PaylaterInstallmentPlans installmentPlans = getPaylaterInstallmentPlans(); InstallmentPlan selectedPlan = installmentPlans.getPlans().get(0); @@ -286,7 +298,7 @@ public void testFullCancelAfterCharge() throws HttpCommunicationException, Parse } @Test - public void testPartialCancelAfterCharge() throws HttpCommunicationException, ParseException { + void testPartialCancelAfterCharge() throws HttpCommunicationException, ParseException { PaylaterInstallmentPlans installmentPlans = getPaylaterInstallmentPlans(); InstallmentPlan selectedPlan = installmentPlans.getPlans().get(0); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterInvoiceTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterInvoiceTest.java index 8509bd07..074a7578 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterInvoiceTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/PaylaterInvoiceTest.java @@ -1,8 +1,19 @@ package com.unzer.payment.integration.paymenttypes; -import com.unzer.payment.*; +import com.unzer.payment.Authorization; +import com.unzer.payment.BaseTransaction; +import com.unzer.payment.Basket; +import com.unzer.payment.BasketItem; +import com.unzer.payment.Cancel; +import com.unzer.payment.Charge; +import com.unzer.payment.Customer; +import com.unzer.payment.Unzer; import com.unzer.payment.business.AbstractPaymentTest; -import com.unzer.payment.models.*; +import com.unzer.payment.models.AdditionalTransactionData; +import com.unzer.payment.models.CustomerType; +import com.unzer.payment.models.PaylaterInvoiceConfig; +import com.unzer.payment.models.RiskData; +import com.unzer.payment.models.ShippingTransactionData; import com.unzer.payment.paymenttypes.PaylaterInvoice; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DynamicTest; @@ -19,19 +30,22 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.DynamicTest.dynamicTest; -public class PaylaterInvoiceTest extends AbstractPaymentTest { +class PaylaterInvoiceTest extends AbstractPaymentTest { @Test - public void testCreatePaylaterType() { + void testCreatePaylaterType() { PaylaterInvoice paylaterInvoice = getUnzer().createPaymentType(new PaylaterInvoice()); assertNotNull(paylaterInvoice.getId()); } @Test - public void testFetchPaylaterType() { + void testFetchPaylaterType() { PaylaterInvoice paylaterInvoice = getUnzer().createPaymentType(new PaylaterInvoice()); assertNotNull(paylaterInvoice.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/PaypalExpressTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/PaypalExpressTest.java index 5ba21bfb..bc59e53f 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/PaypalExpressTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/PaypalExpressTest.java @@ -18,9 +18,9 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertEquals; -public class PaypalExpressTest extends AbstractPaymentTest { +class PaypalExpressTest extends AbstractPaymentTest { @Test - public void testAuthorize() { + void testAuthorize() { Unzer unzer = getUnzer(); Paypal type = unzer.createPaymentType(new Paypal()); @@ -44,7 +44,7 @@ public void testAuthorize() { @Test - public void testCharge() { + void testCharge() { Unzer unzer = getUnzer(); Paypal type = unzer.createPaymentType(new Paypal()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/PaypalTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/PaypalTest.java index 32133d3d..5550b9f8 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/PaypalTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/PaypalTest.java @@ -14,17 +14,17 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -public class PaypalTest extends AbstractPaymentTest { +class PaypalTest extends AbstractPaymentTest { @Test - public void testCreatePaypalMandatoryType() { + void testCreatePaypalMandatoryType() { Paypal paypal = new Paypal(); paypal = getUnzer().createPaymentType(paypal); assertNotNull(paypal.getId()); } @Test - public void testCreatePaypalWithEmail() { + void testCreatePaypalWithEmail() { Paypal paypal = new Paypal(); paypal.setEmail("test.user@email.com"); paypal = getUnzer().createPaymentType(paypal); @@ -33,7 +33,7 @@ public void testCreatePaypalWithEmail() { } @Test - public void testAuthorizeType() { + void testAuthorizeType() { Paypal paypal = getUnzer().createPaymentType(new Paypal()); Authorization authorization = paypal.authorize(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); @@ -41,7 +41,7 @@ public void testAuthorizeType() { } @Test - public void testChargePaypalType() { + void testChargePaypalType() { Paypal paypal = getUnzer().createPaymentType(new Paypal()); Charge charge = paypal.charge(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.unzer.com")); @@ -51,7 +51,7 @@ public void testChargePaypalType() { } @Test - public void testFetchPaypalType() { + void testFetchPaypalType() { Paypal paypal = getUnzer().createPaymentType(new Paypal()); assertNotNull(paypal.getId()); Paypal fetchedPaypal = (Paypal) getUnzer().fetchPaymentType(paypal.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/PisTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/PisTest.java index 0144ff1e..5271461c 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/PisTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/PisTest.java @@ -14,17 +14,17 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class PisTest extends AbstractPaymentTest { +class PisTest extends AbstractPaymentTest { @Test - public void testCreatePis() { + void testCreatePis() { Pis pis = new Pis(); pis = getUnzer().createPaymentType(pis); assertNotNull(pis.getId()); } @Test - public void testCreatePisWithIbanBic() { + void testCreatePisWithIbanBic() { Pis pis = new Pis("DE69545100670661762678", "SPFKAT2BXXX"); pis = getUnzer().createPaymentType(pis); assertNotNull(pis.getId()); @@ -54,7 +54,7 @@ public void testAuthorizeType() { } @Test - public void testFetchPisType() { + void testFetchPisType() { Pis pis = getUnzer().createPaymentType(new Pis()); assertNotNull(pis.getId()); Pis fetchedPis = (Pis) getUnzer().fetchPaymentType(pis.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/PostFinanceCardTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/PostFinanceCardTest.java index 5f4b2f12..dae419d7 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/PostFinanceCardTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/PostFinanceCardTest.java @@ -13,17 +13,17 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class PostFinanceCardTest extends AbstractPaymentTest { +class PostFinanceCardTest extends AbstractPaymentTest { @Test - public void testCreatePostFinanceCardMandatoryType() { + void testCreatePostFinanceCardMandatoryType() { PostFinanceCard pfCard = new PostFinanceCard(); pfCard = getUnzer().createPaymentType(pfCard); assertNotNull(pfCard.getId()); } @Test - public void testChargePostFinanceCardType() { + void testChargePostFinanceCardType() { Unzer unzer = getUnzer(); PostFinanceCard pfCard = unzer.createPaymentType(getPostFinanceCard()); Charge charge = pfCard.charge(BigDecimal.ONE, Currency.getInstance("CHF"), @@ -39,7 +39,7 @@ private PostFinanceCard getPostFinanceCard() { } @Test - public void testFetchPostFinanceCardType() { + void testFetchPostFinanceCardType() { Unzer unzer = getUnzer(); PostFinanceCard pfCard = unzer.createPaymentType(getPostFinanceCard()); assertNotNull(pfCard.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/PostFinanceEFinanceTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/PostFinanceEFinanceTest.java index 5acc9aaf..a45d0308 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/PostFinanceEFinanceTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/PostFinanceEFinanceTest.java @@ -13,17 +13,17 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class PostFinanceEFinanceTest extends AbstractPaymentTest { +class PostFinanceEFinanceTest extends AbstractPaymentTest { @Test - public void testCreatePostFinanceEFinanceMandatoryType() { + void testCreatePostFinanceEFinanceMandatoryType() { PostFinanceEFinance pfEFinance = new PostFinanceEFinance(); pfEFinance = getUnzer().createPaymentType(pfEFinance); assertNotNull(pfEFinance.getId()); } @Test - public void testChargePostFinanceEFinanceType() { + void testChargePostFinanceEFinanceType() { Unzer unzer = getUnzer(); PostFinanceEFinance pfEFinance = unzer.createPaymentType(getPostFinanceEFinance()); Charge charge = pfEFinance.charge(BigDecimal.ONE, Currency.getInstance("CHF"), @@ -39,7 +39,7 @@ private PostFinanceEFinance getPostFinanceEFinance() { } @Test - public void testFetchPostFinanceEFinanceType() { + void testFetchPostFinanceEFinanceType() { Unzer unzer = getUnzer(); PostFinanceEFinance pfEFinance = unzer.createPaymentType(getPostFinanceEFinance()); assertNotNull(pfEFinance.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/PrepaymentTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/PrepaymentTest.java index 5d21d151..a94183dd 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/PrepaymentTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/PrepaymentTest.java @@ -12,17 +12,17 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class PrepaymentTest extends AbstractPaymentTest { +class PrepaymentTest extends AbstractPaymentTest { @Test - public void testCreatePrepaymentManatoryType() { + void testCreatePrepaymentManatoryType() { Prepayment prepayment = new Prepayment(); prepayment = getUnzer().createPaymentType(prepayment); assertNotNull(prepayment.getId()); } @Test - public void testChargePrepaymentType() { + void testChargePrepaymentType() { Prepayment prepayment = getUnzer().createPaymentType(getPrepayment()); Charge charge = prepayment.charge(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.meinShop.de")); assertNotNull(charge); @@ -35,7 +35,7 @@ public void testChargePrepaymentType() { } @Test - public void testFetchPrepaymentType() { + void testFetchPrepaymentType() { Prepayment prepayment = getUnzer().createPaymentType(getPrepayment()); assertNotNull(prepayment.getId()); Prepayment fetchedPrepayment = (Prepayment) getUnzer().fetchPaymentType(prepayment.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/Przelewy24Test.java b/src/test/java/com/unzer/payment/integration/paymenttypes/Przelewy24Test.java index 0dbfa6ff..8531c9bd 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/Przelewy24Test.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/Przelewy24Test.java @@ -13,17 +13,17 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class Przelewy24Test extends AbstractPaymentTest { +class Przelewy24Test extends AbstractPaymentTest { @Test - public void testCreatePrzelewy24ManatoryType() { + void testCreatePrzelewy24ManatoryType() { Przelewy24 p24 = new Przelewy24(); p24 = getUnzer().createPaymentType(p24); assertNotNull(p24.getId()); } @Test - public void testChargePrzelewy24Type() { + void testChargePrzelewy24Type() { Przelewy24 p24 = getUnzer(Keys.LEGACY_PRIVATE_KEY).createPaymentType(getPrzelewy24()); Charge charge = p24.charge(BigDecimal.ONE, Currency.getInstance("PLN"), unsafeUrl("https://www.unzer.com")); assertNotNull(charge); @@ -32,7 +32,7 @@ public void testChargePrzelewy24Type() { } @Test - public void testFetchPrzelewy24Type() { + void testFetchPrzelewy24Type() { Przelewy24 p24 = getUnzer().createPaymentType(getPrzelewy24()); assertNotNull(p24.getId()); Przelewy24 fetchedPrzelewy24 = (Przelewy24) getUnzer().fetchPaymentType(p24.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/SepaDirectDebitSecuredTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/SepaDirectDebitSecuredTest.java index 63bacee0..7acd3211 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/SepaDirectDebitSecuredTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/SepaDirectDebitSecuredTest.java @@ -23,27 +23,29 @@ import static com.unzer.payment.business.Keys.LEGACY_PRIVATE_KEY; import static com.unzer.payment.util.Types.unsafeUrl; import static com.unzer.payment.util.Uuid.generateUuid; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class SepaDirectDebitSecuredTest extends AbstractPaymentTest { +class SepaDirectDebitSecuredTest extends AbstractPaymentTest { @Test - public void testCreateSepaDirectDebitSecuredManatoryType() { + void testCreateSepaDirectDebitSecuredManatoryType() { SepaDirectDebitSecured sdd = new SepaDirectDebitSecured("DE89370400440532013000"); sdd = getUnzer(LEGACY_PRIVATE_KEY).createPaymentType(sdd); assertNotNull(sdd.getId()); } @Test - public void testCreateSepaDirectDebitSecuredFullType() { + void testCreateSepaDirectDebitSecuredFullType() { SepaDirectDebitSecured sddOriginal = getSepaDirectDebitSecured(); SepaDirectDebitSecured sddCreated = getUnzer(LEGACY_PRIVATE_KEY).createPaymentType(sddOriginal); assertSddEquals(sddOriginal, sddCreated); } @Test - public void testFetchSepaDirectDebitSecuredType() { + void testFetchSepaDirectDebitSecuredType() { Unzer unzer = getUnzer(LEGACY_PRIVATE_KEY); SepaDirectDebitSecured sdd = unzer.createPaymentType(getSepaDirectDebitSecured()); assertNotNull(sdd.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/SepaDirectDebitTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/SepaDirectDebitTest.java index 993f78e0..dc3493a6 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/SepaDirectDebitTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/SepaDirectDebitTest.java @@ -16,24 +16,24 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class SepaDirectDebitTest extends AbstractPaymentTest { +class SepaDirectDebitTest extends AbstractPaymentTest { @Test - public void testCreateSepaDirectDebitManatoryType() { + void testCreateSepaDirectDebitManatoryType() { SepaDirectDebit sdd = new SepaDirectDebit("DE89370400440532013000"); sdd = getUnzer(Keys.LEGACY_PRIVATE_KEY).createPaymentType(sdd); assertNotNull(sdd.getId()); } @Test - public void testCreateSepaDirectDebitFullType() { + void testCreateSepaDirectDebitFullType() { SepaDirectDebit sddOriginal = getSepaDirectDebit(); SepaDirectDebit sddCreated = getUnzer(Keys.LEGACY_PRIVATE_KEY).createPaymentType(sddOriginal); assertSddEquals(sddOriginal, sddCreated); } @Test - public void testChargeSepaDirectDebitType() { + void testChargeSepaDirectDebitType() { Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); SepaDirectDebit sdd = unzer.createPaymentType(getSepaDirectDebit()); Charge charge = sdd.charge(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.unzer.com")); @@ -46,7 +46,7 @@ public void testChargeSepaDirectDebitType() { } @Test - public void testFetchSepaDirectDebitType() { + void testFetchSepaDirectDebitType() { Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); SepaDirectDebit sdd = unzer.createPaymentType(getSepaDirectDebit()); assertNotNull(sdd.getId()); @@ -56,7 +56,7 @@ public void testFetchSepaDirectDebitType() { } @Test - public void testCancelSepaDirectDebitType() { + void testCancelSepaDirectDebitType() { Unzer unzer = getUnzer(Keys.LEGACY_PRIVATE_KEY); SepaDirectDebit sdd = unzer.createPaymentType(getSepaDirectDebit()); Charge charge = sdd.charge(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.unzer.com")); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/SofortTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/SofortTest.java index 4802458e..f1e3d809 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/SofortTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/SofortTest.java @@ -13,10 +13,10 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class SofortTest extends AbstractPaymentTest { +class SofortTest extends AbstractPaymentTest { @Test - public void testCreateSofortManatoryType() { + void testCreateSofortManatoryType() { Sofort sofort = new Sofort(); sofort = getUnzer().createPaymentType(sofort); assertNotNull(sofort.getId()); @@ -33,7 +33,7 @@ public void testChargeSofortType() { } @Test - public void testFetchSofortType() { + void testFetchSofortType() { Sofort sofort = getUnzer().createPaymentType(new Sofort()); assertNotNull(sofort.getId()); Sofort fetchedSofort = (Sofort) getUnzer().fetchPaymentType(sofort.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/TwintTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/TwintTest.java index e89d9516..18559b35 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/TwintTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/TwintTest.java @@ -11,17 +11,17 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class TwintTest extends AbstractPaymentTest { +class TwintTest extends AbstractPaymentTest { @Test - public void testCreateTwintManatoryType() { + void testCreateTwintManatoryType() { Twint twint = new Twint(); twint = getUnzer().createPaymentType(twint); assertNotNull(twint.getId()); } @Test - public void testChargeTwintType() { + void testChargeTwintType() { Twint twint = getUnzer().createPaymentType(new Twint()); Charge charge = getUnzer().charge(BigDecimal.ONE, Currency.getInstance("CHF"), twint.getId(), unsafeUrl("https://www.unzer.com")); assertNotNull(charge); @@ -30,7 +30,7 @@ public void testChargeTwintType() { } @Test - public void testFetchTwintType() { + void testFetchTwintType() { Twint twint = getUnzer().createPaymentType(new Twint()); assertNotNull(twint.getId()); Twint fetchedTwint = (Twint) getUnzer().fetchPaymentType(twint.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/WechatpayTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/WechatpayTest.java index 7b5818ac..a75a3205 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/WechatpayTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/WechatpayTest.java @@ -12,17 +12,17 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class WechatpayTest extends AbstractPaymentTest { +class WechatpayTest extends AbstractPaymentTest { @Test - public void testCreateWechatpayMandatoryType() { + void testCreateWechatpayMandatoryType() { Wechatpay wechatpay = new Wechatpay(); wechatpay = getUnzer().createPaymentType(wechatpay); assertNotNull(wechatpay.getId()); } @Test - public void testChargeWechatpayType() { + void testChargeWechatpayType() { Wechatpay wechatpay = getUnzer().createPaymentType(new Wechatpay()); Charge charge = wechatpay.charge(BigDecimal.ONE, Currency.getInstance("EUR"), unsafeUrl("https://www.unzer.com")); assertNotNull(charge); @@ -31,7 +31,7 @@ public void testChargeWechatpayType() { } @Test - public void testFetchWechatpayType() { + void testFetchWechatpayType() { Wechatpay wechatpay = getUnzer().createPaymentType(new Wechatpay()); assertNotNull(wechatpay.getId()); Wechatpay fetchedWechatpay = (Wechatpay) getUnzer().fetchPaymentType(wechatpay.getId()); diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java index 376f9718..3af4d309 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java @@ -7,6 +7,7 @@ import com.unzer.payment.models.EventDependentPayment; import com.unzer.payment.models.WeroTransactionData; import com.unzer.payment.paymenttypes.Wero; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.math.BigDecimal; @@ -16,6 +17,7 @@ import static com.unzer.payment.util.Types.unsafeUrl; import static org.junit.jupiter.api.Assertions.assertNotNull; +@Disabled("Missing keypair config") class WeroTest extends AbstractPaymentTest { @Test diff --git a/src/test/java/com/unzer/payment/integration/resources/AuthTokenTest.java b/src/test/java/com/unzer/payment/integration/resources/AuthTokenTest.java index 2ef7ca3f..5dfa48b1 100644 --- a/src/test/java/com/unzer/payment/integration/resources/AuthTokenTest.java +++ b/src/test/java/com/unzer/payment/integration/resources/AuthTokenTest.java @@ -7,13 +7,15 @@ import java.util.regex.Pattern; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class AuthTokenTest extends AbstractPaymentTest { +class AuthTokenTest extends AbstractPaymentTest { @Test - public void createTokenWithPrivateKey() { + void createTokenWithPrivateKey() { AuthToken autTokenResponse = getUnzer().createAuthToken(); assertNull(autTokenResponse.getId()); assertNotNull(autTokenResponse.getAccessToken()); diff --git a/src/test/java/com/unzer/payment/service/PaymentServiceTest.java b/src/test/java/com/unzer/payment/service/PaymentServiceTest.java index 6ec370b1..1f505f3d 100644 --- a/src/test/java/com/unzer/payment/service/PaymentServiceTest.java +++ b/src/test/java/com/unzer/payment/service/PaymentServiceTest.java @@ -1,7 +1,11 @@ package com.unzer.payment.service; -import com.unzer.payment.*; +import com.unzer.payment.Charge; +import com.unzer.payment.PaymentError; +import com.unzer.payment.PaymentException; +import com.unzer.payment.TestData; +import com.unzer.payment.Unzer; import com.unzer.payment.communication.HttpCommunicationMockUtils; import com.unzer.payment.communication.UnzerRestCommunication; import org.junit.jupiter.api.Test; @@ -9,7 +13,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class PaymentServiceTest { +class PaymentServiceTest { public PaymentService setUpPaymentService(String json, int status) { @@ -19,7 +23,7 @@ public PaymentService setUpPaymentService(String json, int status) { } @Test - public void testChargeInCaseOfCoreException() { + void testChargeInCaseOfCoreException() { PaymentService paymentService = setUpPaymentService(TestData.errorJson(), 500); PaymentException exception = null; try { @@ -37,7 +41,7 @@ public void testChargeInCaseOfCoreException() { } @Test - public void test200WithErrorJsonIsConvertedToPaymentException() { + void test200WithErrorJsonIsConvertedToPaymentException() { PaymentService paymentService = setUpPaymentService(TestData.errorJson(), 200); PaymentException exception = null; try { diff --git a/src/test/java/com/unzer/payment/service/UrlUtilTest.java b/src/test/java/com/unzer/payment/service/UrlUtilTest.java index 456a4d8c..371f40e9 100644 --- a/src/test/java/com/unzer/payment/service/UrlUtilTest.java +++ b/src/test/java/com/unzer/payment/service/UrlUtilTest.java @@ -18,7 +18,7 @@ import static org.junit.jupiter.api.DynamicTest.dynamicTest; -public class UrlUtilTest extends AbstractPaymentTest { +class UrlUtilTest extends AbstractPaymentTest { private static final String sbxTypesUrl = "https://sbx-api.unzer.com/v1/types/"; @TestFactory diff --git a/src/test/java/com/unzer/payment/util/ApplePayAdapterTest.java b/src/test/java/com/unzer/payment/util/ApplePayAdapterTest.java index eb29cb7f..2f0bc5d1 100644 --- a/src/test/java/com/unzer/payment/util/ApplePayAdapterTest.java +++ b/src/test/java/com/unzer/payment/util/ApplePayAdapterTest.java @@ -10,18 +10,20 @@ import java.util.Collections; import static com.unzer.payment.util.ApplePayAdapterUtil.doesUrlContainValidDomainName; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; @Execution(ExecutionMode.SAME_THREAD) -public class ApplePayAdapterTest { +class ApplePayAdapterTest { @BeforeEach public void setDefaultValues() { ApplePayAdapterUtil.setCustomAppleValidationUrls(ApplePayAdapterUtil.DEFAULT_VALIDATION_URLS); } @Test - public void ifAllParametersAreNullThrowError() { + void ifAllParametersAreNullThrowError() { assertThrows(NullPointerException.class, () -> ApplePayAdapterUtil.validateApplePayMerchant( null, null, @@ -30,7 +32,7 @@ public void ifAllParametersAreNullThrowError() { } @Test - public void doesUrlsContainValidDomainName() throws URISyntaxException { + void doesUrlsContainValidDomainName() throws URISyntaxException { assertTrue(doesUrlContainValidDomainName("https://www.apple-pay-gateway.apple.com/")); assertTrue(doesUrlContainValidDomainName("https://cn-apple-pay-gateway.apple.com/")); @@ -39,7 +41,7 @@ public void doesUrlsContainValidDomainName() throws URISyntaxException { } @Test - public void customValidationUrls() throws URISyntaxException { + void customValidationUrls() throws URISyntaxException { ApplePayAdapterUtil.setCustomAppleValidationUrls(Collections.singletonList("google.com")); assertTrue(doesUrlContainValidDomainName("https://www.google.com")); assertFalse(doesUrlContainValidDomainName("https://www.apple-pay-gateway.apple.com/")); diff --git a/src/test/java/com/unzer/payment/util/VersionTest.java b/src/test/java/com/unzer/payment/util/VersionTest.java index aa29b242..19c5633a 100644 --- a/src/test/java/com/unzer/payment/util/VersionTest.java +++ b/src/test/java/com/unzer/payment/util/VersionTest.java @@ -6,9 +6,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; -public class VersionTest { +class VersionTest { @Test - public void testVersionIsCorrect() { + void testVersionIsCorrect() { // Version must be a semver consisting of 3 digit groups, rest is not important // e.g. 1.22.33-SNAPSHOT assertTrue(Pattern.matches("^\\d+[.]\\d+[.]\\d+.*", SDKInfo.VERSION)); diff --git a/src/test/java/com/unzer/payment/webhook/WebhookTest.java b/src/test/java/com/unzer/payment/webhook/WebhookTest.java index f75895d0..78b31786 100644 --- a/src/test/java/com/unzer/payment/webhook/WebhookTest.java +++ b/src/test/java/com/unzer/payment/webhook/WebhookTest.java @@ -16,7 +16,7 @@ @Execution(ExecutionMode.SAME_THREAD) -public class WebhookTest extends AbstractPaymentTest { +class WebhookTest extends AbstractPaymentTest { @BeforeEach public void clearDataBeforeTest() { @@ -31,7 +31,7 @@ public void clearDataAfterTest() { } @Test - public void testRegisterSingleWebhookWithValidEvent() { + void testRegisterSingleWebhookWithValidEvent() { Webhook registerRequest = new Webhook("https://domain.com", WebhookEventEnum.AUTHORIZE_CANCELED); Webhook registerResult = getUnzer().registerSingleWebhook(registerRequest); assertNotNull(registerResult); @@ -40,7 +40,7 @@ public void testRegisterSingleWebhookWithValidEvent() { } @Test - public void testRegisterMultiWebhookWithValidEvent() { + void testRegisterMultiWebhookWithValidEvent() { List listWebhookEvents = Arrays.asList(WebhookEventEnum.CHARGE_CANCELED, WebhookEventEnum.AUTHORIZE_CANCELED, WebhookEventEnum.PREAUTHORIZE_CANCELED, WebhookEventEnum.BASKET_CREATE); Webhook registerRequest = new Webhook("https://domain.com", listWebhookEvents); WebhookList registerResult = getUnzer().registerMultiWebhooks(registerRequest); @@ -53,7 +53,7 @@ public void testRegisterMultiWebhookWithValidEvent() { } @Test - public void testDeleteSingleWebhook() { + void testDeleteSingleWebhook() { Webhook registerRequest = new Webhook("https://domain.com", WebhookEventEnum.AUTHORIZE_CANCELED); Webhook registerResult = getUnzer().registerSingleWebhook(registerRequest); assertNotNull(registerResult); @@ -66,7 +66,7 @@ public void testDeleteSingleWebhook() { } @Test - public void updateSingleWebhook() { + void updateSingleWebhook() { Webhook registerRequest = new Webhook("https://domain.com", WebhookEventEnum.AUTHORIZE_CANCELED); Webhook registerResult = getUnzer().registerSingleWebhook(registerRequest); assertNotNull(registerResult); From a09a151f9e1c6ef9da7503d3b57a216df7783726 Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Wed, 20 Aug 2025 17:15:19 +0200 Subject: [PATCH 11/15] [CC-2673] Cleanup tests. --- .../payment/{service => integration}/TokenServiceTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename src/test/java/com/unzer/payment/{service => integration}/TokenServiceTest.java (94%) diff --git a/src/test/java/com/unzer/payment/service/TokenServiceTest.java b/src/test/java/com/unzer/payment/integration/TokenServiceTest.java similarity index 94% rename from src/test/java/com/unzer/payment/service/TokenServiceTest.java rename to src/test/java/com/unzer/payment/integration/TokenServiceTest.java index 2b8e2797..570ec1d5 100644 --- a/src/test/java/com/unzer/payment/service/TokenServiceTest.java +++ b/src/test/java/com/unzer/payment/integration/TokenServiceTest.java @@ -1,4 +1,4 @@ -package com.unzer.payment.service; +package com.unzer.payment.integration; import com.unzer.payment.AuthToken; import com.unzer.payment.Unzer; @@ -6,6 +6,7 @@ import com.unzer.payment.communication.HttpCommunicationMockUtils; import com.unzer.payment.communication.JsonParser; import com.unzer.payment.communication.UnzerRestCommunication; +import com.unzer.payment.service.TokenService; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; From 2945b2b19a1dad15f10d6bc55de5ef897494a05b Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Thu, 21 Aug 2025 16:17:19 +0200 Subject: [PATCH 12/15] [CC-2673] Cleanup tests. --- .../payment/business/AbstractPaymentTest.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/unzer/payment/business/AbstractPaymentTest.java b/src/test/java/com/unzer/payment/business/AbstractPaymentTest.java index 5979c683..b0266b74 100644 --- a/src/test/java/com/unzer/payment/business/AbstractPaymentTest.java +++ b/src/test/java/com/unzer/payment/business/AbstractPaymentTest.java @@ -1,7 +1,17 @@ package com.unzer.payment.business; -import com.unzer.payment.*; +import com.unzer.payment.Address; +import com.unzer.payment.Authorization; +import com.unzer.payment.BasketItem; +import com.unzer.payment.Cancel; +import com.unzer.payment.Charge; +import com.unzer.payment.CompanyInfo; +import com.unzer.payment.Customer; import com.unzer.payment.Customer.Salutation; +import com.unzer.payment.Metadata; +import com.unzer.payment.Processing; +import com.unzer.payment.ShippingAddress; +import com.unzer.payment.Unzer; import com.unzer.payment.communication.impl.HttpClientBasedRestCommunication; import com.unzer.payment.marketplace.MarketplaceAuthorization; import com.unzer.payment.marketplace.MarketplaceCancelBasket; @@ -27,7 +37,13 @@ import java.time.LocalDate; import java.time.ZoneId; import java.time.format.DateTimeFormatter; -import java.util.*; +import java.util.ArrayList; +import java.util.Currency; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; import static com.unzer.payment.util.Types.unsafeUrl; import static com.unzer.payment.util.Uuid.generateUuid; @@ -236,7 +252,7 @@ protected Customer getMaximumCustomer(String customerId) { customer .setCustomerId(customerId) .setSalutation(Salutation.MR) - .setEmail("support@unzer.com") + .setEmail("accept@unzer.com") .setMobile("+4315136633669") .setPhone("+4962216471100") .setBirthDate(getDate("03.10.1974")) @@ -244,8 +260,8 @@ protected Customer getMaximumCustomer(String customerId) { .setLanguage(Locale.GERMAN) .setShippingAddress( ShippingAddress.of( - getAddress("Mustermann", "Vangerowstraße 18", "Heidelberg", "BW", "69115", "DE"), - ShippingAddress.Type.DIFFERENT_ADDRESS + getAddress(), + ShippingAddress.Type.EQUALS_BILLING ) ); return customer; @@ -346,7 +362,7 @@ protected Address getFactoringOKAddress() { } protected Address getAddress() { - return getAddress("Peter Universum", "Hugo-Junkers-Str. 6", "Frankfurt am Main", "DE-BO", "60386", "DE"); + return getAddress("Max Mustermann", "Hugo-Junkers-Str. 6", "Frankfurt am Main", "DE-BO", "60386", "DE"); } protected Address getAddress(String name, String street, String city, String state, String zip, String country) { From 245bfe68058a0725f149bcf63529e7e3d6d88388 Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Fri, 19 Sep 2025 16:17:10 +0200 Subject: [PATCH 13/15] [CC-2673] Update class name for EventDependentPayment. --- ...Payment.java => WeroEventDependentPayment.java} | 2 +- .../unzer/payment/models/WeroTransactionData.java | 2 +- .../models/paypage/PaymentMethodConfig.java | 4 ++-- .../AdditionalTransactionDataWeroTest.java | 14 +++++++------- .../payment/integration/paymenttypes/WeroTest.java | 14 +++++++------- .../integration/resources/PaypageV2Test.java | 14 +++++++------- 6 files changed, 25 insertions(+), 25 deletions(-) rename src/main/java/com/unzer/payment/models/{EventDependentPayment.java => WeroEventDependentPayment.java} (95%) diff --git a/src/main/java/com/unzer/payment/models/EventDependentPayment.java b/src/main/java/com/unzer/payment/models/WeroEventDependentPayment.java similarity index 95% rename from src/main/java/com/unzer/payment/models/EventDependentPayment.java rename to src/main/java/com/unzer/payment/models/WeroEventDependentPayment.java index 840e529d..f4bf5db0 100644 --- a/src/main/java/com/unzer/payment/models/EventDependentPayment.java +++ b/src/main/java/com/unzer/payment/models/WeroEventDependentPayment.java @@ -7,7 +7,7 @@ * Event dependent payment configuration for Wero payments. */ @Data -public class EventDependentPayment { +public class WeroEventDependentPayment { private CaptureTrigger captureTrigger; private AmountPaymentType amountPaymentType; /** diff --git a/src/main/java/com/unzer/payment/models/WeroTransactionData.java b/src/main/java/com/unzer/payment/models/WeroTransactionData.java index 49ed11e3..0cc62e10 100644 --- a/src/main/java/com/unzer/payment/models/WeroTransactionData.java +++ b/src/main/java/com/unzer/payment/models/WeroTransactionData.java @@ -12,5 +12,5 @@ @JsonTypeName("wero") @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME) public class WeroTransactionData { - private EventDependentPayment eventDependentPayment; + private WeroEventDependentPayment eventDependentPayment; } diff --git a/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java b/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java index 9742d63a..516e5d30 100644 --- a/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java +++ b/src/main/java/com/unzer/payment/models/paypage/PaymentMethodConfig.java @@ -1,6 +1,6 @@ package com.unzer.payment.models.paypage; -import com.unzer.payment.models.EventDependentPayment; +import com.unzer.payment.models.WeroEventDependentPayment; import lombok.Data; @Data @@ -14,7 +14,7 @@ public class PaymentMethodConfig { private Boolean credentialOnFile = null; // card only. private String exemption; // card only. - private EventDependentPayment eventDependentPayment; // wero only + private WeroEventDependentPayment eventDependentPayment; // wero only public PaymentMethodConfig(boolean enabled, Integer order) { this.enabled = enabled; diff --git a/src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java b/src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java index 083ab0d2..43b57dd8 100644 --- a/src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java +++ b/src/test/java/com/unzer/payment/business/AdditionalTransactionDataWeroTest.java @@ -4,7 +4,7 @@ import com.google.gson.JsonObject; import com.unzer.payment.communication.JsonParser; import com.unzer.payment.models.AdditionalTransactionData; -import com.unzer.payment.models.EventDependentPayment; +import com.unzer.payment.models.WeroEventDependentPayment; import com.unzer.payment.models.WeroTransactionData; import org.junit.jupiter.api.Test; @@ -18,9 +18,9 @@ class AdditionalTransactionDataWeroTest { @Test void serializationIncludesWeroDataWithExpectedFieldsAndValues() { // Arrange - EventDependentPayment edp = new EventDependentPayment() - .setCaptureTrigger(EventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) - .setAmountPaymentType(EventDependentPayment.AmountPaymentType.PAY) + WeroEventDependentPayment edp = new WeroEventDependentPayment() + .setCaptureTrigger(WeroEventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(WeroEventDependentPayment.AmountPaymentType.PAY) .setMaxAuthToCaptureTime(300) .setMultiCapturesAllowed(false); @@ -72,9 +72,9 @@ void deserializationParsesWeroDataCorrectly() { assertNotNull(atd); assertNotNull(atd.getWero()); assertNotNull(atd.getWero().getEventDependentPayment()); - EventDependentPayment edp = atd.getWero().getEventDependentPayment(); - assertEquals(EventDependentPayment.CaptureTrigger.SERVICEFULFILMENT, edp.getCaptureTrigger()); - assertEquals(EventDependentPayment.AmountPaymentType.PAY, edp.getAmountPaymentType()); + WeroEventDependentPayment edp = atd.getWero().getEventDependentPayment(); + assertEquals(WeroEventDependentPayment.CaptureTrigger.SERVICEFULFILMENT, edp.getCaptureTrigger()); + assertEquals(WeroEventDependentPayment.AmountPaymentType.PAY, edp.getAmountPaymentType()); assertEquals(300, edp.getMaxAuthToCaptureTime()); assertFalse(edp.getMultiCapturesAllowed()); } diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java index 3af4d309..d629d1bb 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java @@ -4,7 +4,7 @@ import com.unzer.payment.Charge; import com.unzer.payment.business.AbstractPaymentTest; import com.unzer.payment.models.AdditionalTransactionData; -import com.unzer.payment.models.EventDependentPayment; +import com.unzer.payment.models.WeroEventDependentPayment; import com.unzer.payment.models.WeroTransactionData; import com.unzer.payment.paymenttypes.Wero; import org.junit.jupiter.api.Disabled; @@ -63,9 +63,9 @@ void testChargeWeroTypeWithAdditionalTransactionData() { URL returnUrl = unsafeUrl("https://www.unzer.com"); // Build Wero additional transaction data - EventDependentPayment edp = new EventDependentPayment() - .setCaptureTrigger(EventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) - .setAmountPaymentType(EventDependentPayment.AmountPaymentType.PAY) + WeroEventDependentPayment edp = new WeroEventDependentPayment() + .setCaptureTrigger(WeroEventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(WeroEventDependentPayment.AmountPaymentType.PAY) .setMaxAuthToCaptureTime(600) .setMultiCapturesAllowed(true); AdditionalTransactionData atd = new AdditionalTransactionData() @@ -92,9 +92,9 @@ void testAuthorizeWeroTypeWithAdditionalTransactionData() { URL returnUrl = unsafeUrl("https://www.unzer.com"); // Build Wero additional transaction data - EventDependentPayment edp = new EventDependentPayment() - .setCaptureTrigger(EventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) - .setAmountPaymentType(EventDependentPayment.AmountPaymentType.PAYUPTO) + WeroEventDependentPayment edp = new WeroEventDependentPayment() + .setCaptureTrigger(WeroEventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(WeroEventDependentPayment.AmountPaymentType.PAYUPTO) .setMaxAuthToCaptureTime(300) .setMultiCapturesAllowed(false); AdditionalTransactionData atd = new AdditionalTransactionData() diff --git a/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java b/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java index 5342480f..e3204908 100644 --- a/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java +++ b/src/test/java/com/unzer/payment/integration/resources/PaypageV2Test.java @@ -5,8 +5,8 @@ import com.unzer.payment.Metadata; import com.unzer.payment.business.BasketV2TestData; import com.unzer.payment.models.CardTransactionData; -import com.unzer.payment.models.EventDependentPayment; import com.unzer.payment.models.RiskData; +import com.unzer.payment.models.WeroEventDependentPayment; import com.unzer.payment.models.paypage.PaymentMethodConfig; import com.unzer.payment.models.paypage.PaypagePayment; import com.unzer.payment.models.paypage.Resources; @@ -177,15 +177,15 @@ public static Stream getPaymentMethodsConfigs() { .setLabel("Paylater"); // Wero configurations with eventDependentPayment - EventDependentPayment weroEventDependent1 = new EventDependentPayment() - .setCaptureTrigger(EventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) - .setAmountPaymentType(EventDependentPayment.AmountPaymentType.PAY) + WeroEventDependentPayment weroEventDependent1 = new WeroEventDependentPayment() + .setCaptureTrigger(WeroEventDependentPayment.CaptureTrigger.SERVICEFULFILMENT) + .setAmountPaymentType(WeroEventDependentPayment.AmountPaymentType.PAY) .setMaxAuthToCaptureTime(600) .setMultiCapturesAllowed(true); - EventDependentPayment weroEventDependent2 = new EventDependentPayment() - .setCaptureTrigger(EventDependentPayment.CaptureTrigger.DELIVERY) - .setAmountPaymentType(EventDependentPayment.AmountPaymentType.PAYUPTO) + WeroEventDependentPayment weroEventDependent2 = new WeroEventDependentPayment() + .setCaptureTrigger(WeroEventDependentPayment.CaptureTrigger.DELIVERY) + .setAmountPaymentType(WeroEventDependentPayment.AmountPaymentType.PAYUPTO) .setMaxAuthToCaptureTime(300) .setMultiCapturesAllowed(false); From 16762b8130766d857e8e38b3f5705883ee3a9ab8 Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Tue, 23 Sep 2025 13:59:49 +0200 Subject: [PATCH 14/15] [CC-2673] Combine Wero test cases to minimize redundancy --- .../unzer/payment/integration/paymenttypes/WeroTest.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java index d629d1bb..1958e094 100644 --- a/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java +++ b/src/test/java/com/unzer/payment/integration/paymenttypes/WeroTest.java @@ -21,14 +21,7 @@ class WeroTest extends AbstractPaymentTest { @Test - void testCreateWeroType() { - Wero wero = new Wero(); - wero = getUnzer().createPaymentType(wero); - assertNotNull(wero.getId()); - } - - @Test - void testFetchWeroType() { + void testCreateAndFetchWeroType() { Wero wero = getUnzer().createPaymentType(new Wero()); assertNotNull(wero.getId()); Wero fetched = (Wero) getUnzer().fetchPaymentType(wero.getId()); From 49f623a604c4c3249511072dbc179ef812f5fa6c Mon Sep 17 00:00:00 2001 From: "david.owusu" Date: Tue, 23 Sep 2025 16:34:07 +0200 Subject: [PATCH 15/15] [CC-2673] Fix basket test assertThat usage. --- src/test/java/com/unzer/payment/business/BasketV2Test.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/unzer/payment/business/BasketV2Test.java b/src/test/java/com/unzer/payment/business/BasketV2Test.java index d8fac76d..edb48567 100644 --- a/src/test/java/com/unzer/payment/business/BasketV2Test.java +++ b/src/test/java/com/unzer/payment/business/BasketV2Test.java @@ -34,10 +34,10 @@ void testCreateFetchBasket() { } private void assertBasketEquals(Basket expected, Basket actual) { - assertThat(expected) + assertThat(actual) .usingComparatorForType(BigDecimal::compareTo, BigDecimal.class) .usingRecursiveComparison() - .isEqualTo(actual); + .isEqualTo(expected); } @Test