From d0c38f3b322841a6f1dad6653c921ef76cad4f4c Mon Sep 17 00:00:00 2001 From: renatoma Date: Tue, 9 Apr 2019 11:42:59 +0200 Subject: [PATCH 01/13] [PW-828] Add application info to adyen-java-api-library - Add default library name + version / private set --- .../applicationinfo/ApplicationInfo.java | 5 ----- .../java/com/adyen/ApplicationInfoTest.java | 20 ++++++++----------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/adyen/model/applicationinfo/ApplicationInfo.java b/src/main/java/com/adyen/model/applicationinfo/ApplicationInfo.java index 376102bc1..4045a12c6 100644 --- a/src/main/java/com/adyen/model/applicationinfo/ApplicationInfo.java +++ b/src/main/java/com/adyen/model/applicationinfo/ApplicationInfo.java @@ -61,15 +61,10 @@ public void setPaymentDetailsSource(CommonField paymentDetailsSource) { this.paymentDetailsSource = paymentDetailsSource; } - public CommonField getAdyenLibrary() { return adyenLibrary; } - public void setAdyenLibrary(CommonField adyenLibrary) { - this.adyenLibrary = adyenLibrary; - } - public CommonField getAdyenPaymentSource() { return adyenPaymentSource; } diff --git a/src/test/java/com/adyen/ApplicationInfoTest.java b/src/test/java/com/adyen/ApplicationInfoTest.java index 2385a5586..fec5bfc8e 100644 --- a/src/test/java/com/adyen/ApplicationInfoTest.java +++ b/src/test/java/com/adyen/ApplicationInfoTest.java @@ -1,27 +1,23 @@ package com.adyen; -import org.junit.Test; import com.adyen.model.applicationinfo.ApplicationInfo; -import com.adyen.model.applicationinfo.CommonField; +import org.junit.Test; + import static com.adyen.Client.LIB_NAME; import static com.adyen.Client.LIB_VERSION; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; public class ApplicationInfoTest { @Test public void TestApplicationInfoEquals() { - - CommonField adyenLibrary = new CommonField(); - adyenLibrary.setName(LIB_NAME); - adyenLibrary.setVersion(LIB_VERSION); - ApplicationInfo applicationInfo = new ApplicationInfo(); - applicationInfo.setAdyenLibrary(adyenLibrary); - ApplicationInfo applicationInfo2 = new ApplicationInfo(); - applicationInfo2.setAdyenLibrary(adyenLibrary); - assertTrue(applicationInfo.equals(applicationInfo2)); + assertEquals(applicationInfo, applicationInfo2); + assertNotNull(applicationInfo.getAdyenLibrary()); + assertEquals(LIB_NAME, applicationInfo.getAdyenLibrary().getName()); + assertEquals(LIB_VERSION, applicationInfo.getAdyenLibrary().getVersion()); } } From 73063c5291d126ecdfa35dc606319238280a200c Mon Sep 17 00:00:00 2001 From: renatoma Date: Tue, 9 Apr 2019 14:17:57 +0200 Subject: [PATCH 02/13] [PW-828] Add application info to adyen-java-api-library - Add default library fields test --- src/test/java/com/adyen/ApplicationInfoTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/com/adyen/ApplicationInfoTest.java b/src/test/java/com/adyen/ApplicationInfoTest.java index fec5bfc8e..db8cd45ca 100644 --- a/src/test/java/com/adyen/ApplicationInfoTest.java +++ b/src/test/java/com/adyen/ApplicationInfoTest.java @@ -16,8 +16,16 @@ public void TestApplicationInfoEquals() { ApplicationInfo applicationInfo2 = new ApplicationInfo(); assertEquals(applicationInfo, applicationInfo2); + } + + @Test + public void TestApplicationInfoPrefilledLibraryFields() { + ApplicationInfo applicationInfo = new ApplicationInfo(); + assertNotNull(applicationInfo.getAdyenLibrary()); + assertNotNull(applicationInfo.getAdyenLibrary().getName()); assertEquals(LIB_NAME, applicationInfo.getAdyenLibrary().getName()); + assertNotNull(applicationInfo.getAdyenLibrary().getVersion()); assertEquals(LIB_VERSION, applicationInfo.getAdyenLibrary().getVersion()); } } From 4895eafe3a58fc1dfe162b7ec49678512c66f580 Mon Sep 17 00:00:00 2001 From: renatoma Date: Tue, 9 Apr 2019 14:56:32 +0200 Subject: [PATCH 03/13] [PW-828] Add application info to adyen-java-api-library - Add default application info on requests --- .../adyen/model/AbstractPaymentRequest.java | 5 +- .../model/checkout/PaymentMethodsRequest.java | 10 ++-- .../model/checkout/PaymentSessionRequest.java | 53 ++----------------- .../adyen/model/checkout/PaymentsRequest.java | 8 +-- .../AbstractModificationRequest.java | 5 +- 5 files changed, 15 insertions(+), 66 deletions(-) diff --git a/src/main/java/com/adyen/model/AbstractPaymentRequest.java b/src/main/java/com/adyen/model/AbstractPaymentRequest.java index 309f0d103..9f07e03b0 100644 --- a/src/main/java/com/adyen/model/AbstractPaymentRequest.java +++ b/src/main/java/com/adyen/model/AbstractPaymentRequest.java @@ -162,9 +162,7 @@ public String toString() { private ApplicationInfo applicationInfo; public AbstractPaymentRequest() { - if (this.applicationInfo == null) { - applicationInfo = new ApplicationInfo(); - } + applicationInfo = new ApplicationInfo(); } /** @@ -930,4 +928,3 @@ private String toIndentedString(Object o) { } } - diff --git a/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java b/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java index 756653f83..6cce05a60 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java @@ -64,7 +64,7 @@ public class PaymentMethodsRequest { private AccountInfo accountInfo = null; @SerializedName("applciationInfo") - private ApplicationInfo applicationInfo = null; + private ApplicationInfo applicationInfo; @SerializedName("configId") private String configId = null; @@ -81,6 +81,10 @@ public class PaymentMethodsRequest { @SerializedName("trustedShopper") private Boolean trustedShopper = null; + public PaymentMethodsRequest() { + applicationInfo = new ApplicationInfo(); + } + public Object getAdditionalData() { return additionalData; } @@ -389,8 +393,4 @@ public ChannelEnum read(final JsonReader jsonReader) throws IOException { } } - } - - - diff --git a/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java b/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java index 741c369a4..b1d65ebdb 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java @@ -89,9 +89,6 @@ public class PaymentSessionRequest { @SerializedName("card") private Card card = null; - - - /** * The platform where a payment transaction takes place. This field is optional for filtering out payment methods that are only available on specific platforms. If this value is not set, then we * will try to infer it from the `sdkVersion` or `token`. Possible values: * iOS * Android * Web @@ -448,12 +445,15 @@ public ShopperInteractionEnum read(final JsonReader jsonReader) throws IOExcepti @SerializedName("uniqueTerminalId") private String uniqueTerminalId = null; + public PaymentSessionRequest() { + applicationInfo = new ApplicationInfo(); + } + public PaymentSessionRequest accountInfo(AccountInfo accountInfo) { this.accountInfo = accountInfo; return this; } - public AccountInfo getAccountInfo() { return accountInfo; } @@ -467,7 +467,6 @@ public PaymentSessionRequest additionalAmount(Amount additionalAmount) { return this; } - public Amount getAdditionalAmount() { return additionalAmount; } @@ -481,7 +480,6 @@ public PaymentSessionRequest additionalData(Object additionalData) { return this; } - public Object getAdditionalData() { return additionalData; } @@ -505,7 +503,6 @@ public PaymentSessionRequest addAllowedPaymentMethodsItem(String allowedPaymentM return this; } - public List getAllowedPaymentMethods() { return allowedPaymentMethods; } @@ -519,7 +516,6 @@ public PaymentSessionRequest amount(Amount amount) { return this; } - public Amount getAmount() { return amount; } @@ -546,7 +542,6 @@ public PaymentSessionRequest bankAccount(BankAccount bankAccount) { return this; } - public BankAccount getBankAccount() { return bankAccount; } @@ -560,7 +555,6 @@ public PaymentSessionRequest billingAddress(Address billingAddress) { return this; } - public Address getBillingAddress() { return billingAddress; } @@ -584,7 +578,6 @@ public PaymentSessionRequest addBlockedPaymentMethodsItem(String blockedPaymentM return this; } - public List getBlockedPaymentMethods() { return blockedPaymentMethods; } @@ -611,7 +604,6 @@ public PaymentSessionRequest captureDelayHours(Integer captureDelayHours) { return this; } - public Integer getCaptureDelayHours() { return captureDelayHours; } @@ -638,7 +630,6 @@ public PaymentSessionRequest channel(ChannelEnum channel) { return this; } - public ChannelEnum getChannel() { return channel; } @@ -665,7 +656,6 @@ public PaymentSessionRequest configId(String configId) { return this; } - public String getConfigId() { return configId; } @@ -731,7 +721,6 @@ public PaymentSessionRequest deliveryAddress(Address deliveryAddress) { return this; } - public Address getDeliveryAddress() { return deliveryAddress; } @@ -784,7 +773,6 @@ public PaymentSessionRequest enablePayOut(Boolean enablePayOut) { return this; } - public Boolean isEnablePayOut() { return enablePayOut; } @@ -811,7 +799,6 @@ public PaymentSessionRequest entityType(EntityTypeEnum entityType) { return this; } - public EntityTypeEnum getEntityType() { return entityType; } @@ -825,7 +812,6 @@ public PaymentSessionRequest fraudOffset(Integer fraudOffset) { return this; } - public Integer getFraudOffset() { return fraudOffset; } @@ -852,7 +838,6 @@ public PaymentSessionRequest installments(Installments installments) { return this; } - public Installments getInstallments() { return installments; } @@ -876,7 +861,6 @@ public PaymentSessionRequest addLineItemsItem(LineItem lineItemsItem) { return this; } - public List getLineItems() { return lineItems; } @@ -890,7 +874,6 @@ public PaymentSessionRequest mcc(String mcc) { return this; } - public String getMcc() { return mcc; } @@ -904,7 +887,6 @@ public PaymentSessionRequest merchantAccount(String merchantAccount) { return this; } - public String getMerchantAccount() { return merchantAccount; } @@ -918,7 +900,6 @@ public PaymentSessionRequest merchantOrderReference(String merchantOrderReferenc return this; } - public String getMerchantOrderReference() { return merchantOrderReference; } @@ -932,7 +913,6 @@ public PaymentSessionRequest merchantRiskIndicator(MerchantRiskIndicator merchan return this; } - public MerchantRiskIndicator getMerchantRiskIndicator() { return merchantRiskIndicator; } @@ -946,7 +926,6 @@ public PaymentSessionRequest metadata(Object metadata) { return this; } - public Object getMetadata() { return metadata; } @@ -960,7 +939,6 @@ public PaymentSessionRequest mpiData(ThreeDSecureData mpiData) { return this; } - public ThreeDSecureData getMpiData() { return mpiData; } @@ -974,7 +952,6 @@ public PaymentSessionRequest nationality(String nationality) { return this; } - public String getNationality() { return nationality; } @@ -988,7 +965,6 @@ public PaymentSessionRequest orderReference(String orderReference) { return this; } - public String getOrderReference() { return orderReference; } @@ -1002,7 +978,6 @@ public PaymentSessionRequest origin(String origin) { return this; } - public String getOrigin() { return origin; } @@ -1016,7 +991,6 @@ public PaymentSessionRequest recurring(Recurring recurring) { return this; } - public Recurring getRecurring() { return recurring; } @@ -1030,7 +1004,6 @@ public PaymentSessionRequest recurringProcessingModel(RecurringProcessingModelEn return this; } - public RecurringProcessingModelEnum getRecurringProcessingModel() { return recurringProcessingModel; } @@ -1057,7 +1030,6 @@ public PaymentSessionRequest returnUrl(String returnUrl) { return this; } - public String getReturnUrl() { return returnUrl; } @@ -1071,7 +1043,6 @@ public PaymentSessionRequest sdkVersion(String sdkVersion) { return this; } - public String getSdkVersion() { return sdkVersion; } @@ -1098,7 +1069,6 @@ public PaymentSessionRequest selectedRecurringDetailReference(String selectedRec return this; } - public String getSelectedRecurringDetailReference() { return selectedRecurringDetailReference; } @@ -1112,7 +1082,6 @@ public PaymentSessionRequest sessionId(String sessionId) { return this; } - public String getSessionId() { return sessionId; } @@ -1139,7 +1108,6 @@ public PaymentSessionRequest shopperEmail(String shopperEmail) { return this; } - public String getShopperEmail() { return shopperEmail; } @@ -1153,7 +1121,6 @@ public PaymentSessionRequest shopperIP(String shopperIP) { return this; } - public String getShopperIP() { return shopperIP; } @@ -1167,7 +1134,6 @@ public PaymentSessionRequest shopperInteraction(ShopperInteractionEnum shopperIn return this; } - public ShopperInteractionEnum getShopperInteraction() { return shopperInteraction; } @@ -1181,7 +1147,6 @@ public PaymentSessionRequest shopperLocale(String shopperLocale) { return this; } - public String getShopperLocale() { return shopperLocale; } @@ -1208,7 +1173,6 @@ public PaymentSessionRequest shopperReference(String shopperReference) { return this; } - public String getShopperReference() { return shopperReference; } @@ -1271,7 +1235,6 @@ public PaymentSessionRequest store(String store) { return this; } - public String getStore() { return store; } @@ -1285,7 +1248,6 @@ public PaymentSessionRequest telephoneNumber(String telephoneNumber) { return this; } - public String getTelephoneNumber() { return telephoneNumber; } @@ -1299,7 +1261,6 @@ public PaymentSessionRequest threeDS2RequestData(ThreeDS2RequestData threeDS2Req return this; } - public ThreeDS2RequestData getThreeDS2RequestData() { return threeDS2RequestData; } @@ -1326,7 +1287,6 @@ public PaymentSessionRequest totalsGroup(String totalsGroup) { return this; } - public void setTotalsGroup(String totalsGroup) { this.totalsGroup = totalsGroup; } @@ -1336,7 +1296,6 @@ public PaymentSessionRequest trustedShopper(Boolean trustedShopper) { return this; } - public Boolean isTrustedShopper() { return trustedShopper; } @@ -1350,7 +1309,6 @@ public PaymentSessionRequest uniqueTerminalId(String uniqueTerminalId) { return this; } - public String getUniqueTerminalId() { return uniqueTerminalId; } @@ -1586,7 +1544,4 @@ private String toIndentedString(java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } - - diff --git a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java index 67bcca36d..9297b5318 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java @@ -159,9 +159,7 @@ public class PaymentsRequest { public PaymentsRequest() { - if (this.applicationInfo == null) { - this.applicationInfo = new ApplicationInfo(); - } + this.applicationInfo = new ApplicationInfo(); } public MerchantRiskIndicator getMerchantRiskIndicator() { @@ -1375,8 +1373,4 @@ public ShopperInteractionEnum read(final JsonReader jsonReader) throws IOExcepti } } - } - - - diff --git a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java index 9b1898502..11a2b8a91 100644 --- a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java +++ b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java @@ -56,6 +56,10 @@ public class AbstractModificationRequest splits = null; + public AbstractModificationRequest() { + applicationInfo = new ApplicationInfo(); + } + public T reference(String reference) { this.reference = reference; return (T) this; @@ -288,4 +292,3 @@ private String toIndentedString(Object o) { } } - From da8e5f6683e463620ec9bdc882cd4eae67ef4e4e Mon Sep 17 00:00:00 2001 From: renatoma Date: Tue, 9 Apr 2019 16:37:55 +0200 Subject: [PATCH 04/13] [PW-828] Add application info to adyen-java-api-library - Fixed setters to avoid applicationInfo == null --- .../adyen/model/AbstractPaymentRequest.java | 6 +- .../model/checkout/PaymentMethodsRequest.java | 6 +- .../model/checkout/PaymentSessionRequest.java | 8 +- .../adyen/model/checkout/PaymentsRequest.java | 8 +- .../AbstractModificationRequest.java | 8 +- src/test/java/com/adyen/CheckoutTest.java | 87 ++++++++++++------- 6 files changed, 85 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/adyen/model/AbstractPaymentRequest.java b/src/main/java/com/adyen/model/AbstractPaymentRequest.java index 9f07e03b0..9b71035e6 100644 --- a/src/main/java/com/adyen/model/AbstractPaymentRequest.java +++ b/src/main/java/com/adyen/model/AbstractPaymentRequest.java @@ -756,7 +756,11 @@ public ApplicationInfo getApplicationInfo() { } public void setApplicationInfo(ApplicationInfo applicationInfo) { - this.applicationInfo = applicationInfo; + if (applicationInfo == null) { + this.applicationInfo = new ApplicationInfo(); + } else { + this.applicationInfo = applicationInfo; + } } /** diff --git a/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java b/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java index 6cce05a60..6c38ef473 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java @@ -106,7 +106,11 @@ public ApplicationInfo getApplicationInfo() { } public void setApplicationInfo(ApplicationInfo applicationInfo) { - this.applicationInfo = applicationInfo; + if (applicationInfo == null) { + this.applicationInfo = new ApplicationInfo(); + } else { + this.applicationInfo = applicationInfo; + } } public PaymentMethodsRequest amount(Amount amount) { diff --git a/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java b/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java index b1d65ebdb..ed92cd2e6 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java @@ -525,7 +525,7 @@ public void setAmount(Amount amount) { } public PaymentSessionRequest applicationInfo(ApplicationInfo applicationInfo) { - this.applicationInfo = applicationInfo; + setApplicationInfo(applicationInfo); return this; } @@ -534,7 +534,11 @@ public ApplicationInfo getApplicationInfo() { } public void setApplicationInfo(ApplicationInfo applicationInfo) { - this.applicationInfo = applicationInfo; + if (applicationInfo == null) { + this.applicationInfo = new ApplicationInfo(); + } else { + this.applicationInfo = applicationInfo; + } } public PaymentSessionRequest bankAccount(BankAccount bankAccount) { diff --git a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java index 9297b5318..a7f0f84f1 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java @@ -1031,11 +1031,15 @@ public ApplicationInfo getApplicationInfo() { } public void setApplicationInfo(ApplicationInfo applicationInfo) { - this.applicationInfo = applicationInfo; + if (applicationInfo == null) { + this.applicationInfo = new ApplicationInfo(); + } else { + this.applicationInfo = applicationInfo; + } } public PaymentsRequest applicationInfo(ApplicationInfo applicationInfo) { - this.applicationInfo = applicationInfo; + setApplicationInfo(applicationInfo); return this; } diff --git a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java index 11a2b8a91..ec227effb 100644 --- a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java +++ b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java @@ -137,11 +137,15 @@ public ApplicationInfo getApplicationInfo() { } public void setApplicationInfo(ApplicationInfo applicationInfo) { - this.applicationInfo = applicationInfo; + if (applicationInfo == null) { + this.applicationInfo = new ApplicationInfo(); + } else { + this.applicationInfo = applicationInfo; + } } public T applicationInfo(ApplicationInfo applicationInfo) { - this.applicationInfo = applicationInfo; + setApplicationInfo(applicationInfo); return (T) this; } diff --git a/src/test/java/com/adyen/CheckoutTest.java b/src/test/java/com/adyen/CheckoutTest.java index 413e1c211..58bd5a951 100644 --- a/src/test/java/com/adyen/CheckoutTest.java +++ b/src/test/java/com/adyen/CheckoutTest.java @@ -217,22 +217,28 @@ public void TestPaymentMethodDetails() { String jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest); assertEquals("{\n" - + " \"amount\": {\n" - + " \"value\": 1000,\n" - + " \"currency\": \"USD\"\n" - + " },\n" - + " \"merchantAccount\": \"MagentoMerchantTest\",\n" - + " \"paymentMethod\": {\n" - + " \"type\": \"scheme\",\n" - + " \"number\": \"4111111111111111\",\n" - + " \"expiryMonth\": \"10\",\n" - + " \"expiryYear\": \"2018\",\n" - + " \"holderName\": \"John Smith\",\n" - + " \"cvc\": \"737\"\n" - + " },\n" - + " \"reference\": \"Your order number\",\n" - + " \"returnUrl\": \"https://your-company.com/...\"\n" - + "}", jsonRequest); + + " \"amount\": {\n" + + " \"value\": 1000,\n" + + " \"currency\": \"USD\"\n" + + " },\n" + + " \"merchantAccount\": \"MagentoMerchantTest\",\n" + + " \"paymentMethod\": {\n" + + " \"type\": \"scheme\",\n" + + " \"number\": \"4111111111111111\",\n" + + " \"expiryMonth\": \"10\",\n" + + " \"expiryYear\": \"2018\",\n" + + " \"holderName\": \"John Smith\",\n" + + " \"cvc\": \"737\"\n" + + " },\n" + + " \"reference\": \"Your order number\",\n" + + " \"returnUrl\": \"https://your-company.com/...\",\n" + + " \"applicationInfo\": {\n" + + " \"adyenLibrary\": {\n" + + " \"name\": \"adyen-java-api-library\",\n" + + " \"version\": \"2.0.1\"\n" + + " }\n" + + " }\n" + + "}", jsonRequest); TestPaymentMethodDetails testPaymentMethodDetails = new TestPaymentMethodDetails(); testPaymentMethodDetails.setType("testType"); @@ -241,18 +247,24 @@ public void TestPaymentMethodDetails() { jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest); assertEquals("{\n" - + " \"amount\": {\n" - + " \"value\": 1000,\n" - + " \"currency\": \"USD\"\n" - + " },\n" - + " \"merchantAccount\": \"MagentoMerchantTest\",\n" - + " \"paymentMethod\": {\n" - + " \"testKey\": \"testValue\",\n" - + " \"type\": \"testType\"\n" - + " },\n" - + " \"reference\": \"Your order number\",\n" - + " \"returnUrl\": \"https://your-company.com/...\"\n" - + "}", jsonRequest); + + " \"amount\": {\n" + + " \"value\": 1000,\n" + + " \"currency\": \"USD\"\n" + + " },\n" + + " \"merchantAccount\": \"MagentoMerchantTest\",\n" + + " \"paymentMethod\": {\n" + + " \"testKey\": \"testValue\",\n" + + " \"type\": \"testType\"\n" + + " },\n" + + " \"reference\": \"Your order number\",\n" + + " \"returnUrl\": \"https://your-company.com/...\",\n" + + " \"applicationInfo\": {\n" + + " \"adyenLibrary\": {\n" + + " \"name\": \"adyen-java-api-library\",\n" + + " \"version\": \"2.0.1\"\n" + + " }\n" + + " }\n" + + "}", jsonRequest); } /** @@ -296,7 +308,13 @@ public void TestSepaPaymentMethodDetails() { + " \"sepa.ibanNumber\": \"DE87123456781234567890\"\n" + " },\n" + " \"reference\": \"Your order number\",\n" - + " \"returnUrl\": \"https://your-company.com/...\"\n" + + " \"returnUrl\": \"https://your-company.com/...\",\n" + + " \"applicationInfo\": {\n" + + " \"adyenLibrary\": {\n" + + " \"name\": \"adyen-java-api-library\",\n" + + " \"version\": \"2.0.1\"\n" + + " }\n" + + " }\n" + "}",jsonRequest ); } @@ -312,7 +330,16 @@ public void TestDateSerializers() throws ParseException { paymentsRequest.setDateOfBirth(d); paymentsRequest.setDeliveryDate(d); String jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest); - assertEquals("{\n" + " \"dateOfBirth\": \"2018-10-31\",\n" + " \"deliveryDate\": \"2018-10-31T00:00:00.000Z\"\n" + "}", jsonRequest); + assertEquals("{\n" + + " \"dateOfBirth\": \"2018-10-31\",\n" + + " \"deliveryDate\": \"2018-10-31T00:00:00.000Z\",\n" + + " \"applicationInfo\": {\n" + + " \"adyenLibrary\": {\n" + + " \"name\": \"adyen-java-api-library\",\n" + + " \"version\": \"2.0.1\"\n" + + " }\n" + + " }\n" + + "}",jsonRequest ); } /** From 0513a58221ce94ee4bb650fc3e03c7a9a96e6630 Mon Sep 17 00:00:00 2001 From: renatoma Date: Tue, 9 Apr 2019 16:59:26 +0200 Subject: [PATCH 05/13] [PW-828] Add application info to adyen-java-api-library - Add default library name + version / private set --- src/test/java/com/adyen/PaymentRequestBuilderTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/com/adyen/PaymentRequestBuilderTest.java b/src/test/java/com/adyen/PaymentRequestBuilderTest.java index 673aff817..2186f66c8 100644 --- a/src/test/java/com/adyen/PaymentRequestBuilderTest.java +++ b/src/test/java/com/adyen/PaymentRequestBuilderTest.java @@ -115,6 +115,12 @@ public void TestCSEPaymentRequest() { + " },\n" + " \"additionalData\": {\n" + " \"card.encrypted.json\": \"adyenjs_0_1_4p1$...\"\n" + + " },\n" + + " \"applicationInfo\": {\n" + + " \"adyenLibrary\": {\n" + + " \"name\": \"adyen-java-api-library\",\n" + + " \"version\": \"2.0.1\"\n" + + " }\n" + " }\n" + "}"; From 659d8c6354fee422f474d35f8a51340aa4a8641e Mon Sep 17 00:00:00 2001 From: renatoma <> Date: Wed, 10 Apr 2019 11:32:29 +0200 Subject: [PATCH 06/13] [PW-828] Add application info to adyen-java-api-library - Request creation tests --- .../com/adyen/ModificationRequestTest.java | 72 +++++++++++++++++++ .../com/adyen/PaymentMethodsRequestTest.java | 72 +++++++++++++++++++ .../java/com/adyen/PaymentRequestTest.java | 44 ++++++++++++ .../com/adyen/PaymentSessionRequestTest.java | 72 +++++++++++++++++++ .../java/com/adyen/PaymentsRequestTest.java | 72 +++++++++++++++++++ 5 files changed, 332 insertions(+) create mode 100644 src/test/java/com/adyen/ModificationRequestTest.java create mode 100644 src/test/java/com/adyen/PaymentMethodsRequestTest.java create mode 100644 src/test/java/com/adyen/PaymentSessionRequestTest.java create mode 100644 src/test/java/com/adyen/PaymentsRequestTest.java diff --git a/src/test/java/com/adyen/ModificationRequestTest.java b/src/test/java/com/adyen/ModificationRequestTest.java new file mode 100644 index 000000000..25f1008fe --- /dev/null +++ b/src/test/java/com/adyen/ModificationRequestTest.java @@ -0,0 +1,72 @@ +/** + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2017 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen; + +import com.adyen.model.applicationinfo.ApplicationInfo; +import com.adyen.model.modification.AbstractModificationRequest; +import org.junit.Test; + +import static com.adyen.Client.LIB_NAME; +import static com.adyen.Client.LIB_VERSION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class ModificationRequestTest { + + @Test + public void TestDefaultApplicationInfoAdyenLibrary() { + AbstractModificationRequest modificationRequest = new AbstractModificationRequest(); + + assertNotNull(modificationRequest.getApplicationInfo()); + assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, modificationRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, modificationRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } + + @Test + public void TestCustomApplicationInfoAdyenLibrary() { + AbstractModificationRequest modificationRequest = new AbstractModificationRequest(); + ApplicationInfo applicationInfo = new ApplicationInfo(); + modificationRequest.setApplicationInfo(applicationInfo); + + assertNotNull(modificationRequest.getApplicationInfo()); + assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, modificationRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, modificationRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } + + @Test + public void TestNullApplicationInfoAdyenLibrary() { + AbstractModificationRequest modificationRequest = new AbstractModificationRequest(); + modificationRequest.setApplicationInfo(null); + + assertNotNull(modificationRequest.getApplicationInfo()); + assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, modificationRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, modificationRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } +} \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentMethodsRequestTest.java b/src/test/java/com/adyen/PaymentMethodsRequestTest.java new file mode 100644 index 000000000..1d327d8d0 --- /dev/null +++ b/src/test/java/com/adyen/PaymentMethodsRequestTest.java @@ -0,0 +1,72 @@ +/** + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2017 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen; + +import com.adyen.model.applicationinfo.ApplicationInfo; +import com.adyen.model.checkout.PaymentMethodsRequest; +import org.junit.Test; + +import static com.adyen.Client.LIB_NAME; +import static com.adyen.Client.LIB_VERSION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class PaymentMethodsRequestTest { + + @Test + public void TestDefaultApplicationInfoAdyenLibrary() { + PaymentMethodsRequest paymentMethodsRequest = new PaymentMethodsRequest(); + + assertNotNull(paymentMethodsRequest.getApplicationInfo()); + assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } + + @Test + public void TestCustomApplicationInfoAdyenLibrary() { + PaymentMethodsRequest paymentMethodsRequest = new PaymentMethodsRequest(); + ApplicationInfo applicationInfo = new ApplicationInfo(); + paymentMethodsRequest.setApplicationInfo(applicationInfo); + + assertNotNull(paymentMethodsRequest.getApplicationInfo()); + assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } + + @Test + public void TestNullApplicationInfoAdyenLibrary() { + PaymentMethodsRequest paymentMethodsRequest = new PaymentMethodsRequest(); + paymentMethodsRequest.setApplicationInfo(null); + + assertNotNull(paymentMethodsRequest.getApplicationInfo()); + assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } +} \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentRequestTest.java b/src/test/java/com/adyen/PaymentRequestTest.java index d7578c54a..70eb6d642 100644 --- a/src/test/java/com/adyen/PaymentRequestTest.java +++ b/src/test/java/com/adyen/PaymentRequestTest.java @@ -20,10 +20,15 @@ */ package com.adyen; +import com.adyen.model.applicationinfo.ApplicationInfo; import org.junit.Test; import com.adyen.enums.VatCategory; import com.adyen.model.PaymentRequest; + +import static com.adyen.Client.LIB_NAME; +import static com.adyen.Client.LIB_VERSION; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; public class PaymentRequestTest extends BaseTest { @@ -60,4 +65,43 @@ public void TestPaypalEcsRequest() { assertEquals("EUR", paymentRequest.getAmount().getCurrency()); assertEquals("apaymenttoken", paymentRequest.getAdditionalData().get("payment.token")); } + + @Test + public void TestDefaultApplicationInfoAdyenLibrary() { + PaymentRequest paymentRequest = new PaymentRequest(); + + assertNotNull(paymentRequest.getApplicationInfo()); + assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } + + @Test + public void TestCustomApplicationInfoAdyenLibrary() { + PaymentRequest paymentRequest = new PaymentRequest(); + ApplicationInfo applicationInfo = new ApplicationInfo(); + paymentRequest.setApplicationInfo(applicationInfo); + + assertNotNull(paymentRequest.getApplicationInfo()); + assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } + + @Test + public void TestNullApplicationInfoAdyenLibrary() { + PaymentRequest paymentRequest = new PaymentRequest(); + paymentRequest.setApplicationInfo(null); + + assertNotNull(paymentRequest.getApplicationInfo()); + assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } } \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentSessionRequestTest.java b/src/test/java/com/adyen/PaymentSessionRequestTest.java new file mode 100644 index 000000000..23185a2e7 --- /dev/null +++ b/src/test/java/com/adyen/PaymentSessionRequestTest.java @@ -0,0 +1,72 @@ +/** + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2017 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen; + +import com.adyen.model.applicationinfo.ApplicationInfo; +import com.adyen.model.checkout.PaymentSessionRequest; +import org.junit.Test; + +import static com.adyen.Client.LIB_NAME; +import static com.adyen.Client.LIB_VERSION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class PaymentSessionRequestTest { + + @Test + public void TestDefaultApplicationInfoAdyenLibrary() { + PaymentSessionRequest paymentSessionRequest = new PaymentSessionRequest(); + + assertNotNull(paymentSessionRequest.getApplicationInfo()); + assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } + + @Test + public void TestCustomApplicationInfoAdyenLibrary() { + PaymentSessionRequest paymentSessionRequest = new PaymentSessionRequest(); + ApplicationInfo applicationInfo = new ApplicationInfo(); + paymentSessionRequest.setApplicationInfo(applicationInfo); + + assertNotNull(paymentSessionRequest.getApplicationInfo()); + assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } + + @Test + public void TestNullApplicationInfoAdyenLibrary() { + PaymentSessionRequest paymentSessionRequest = new PaymentSessionRequest(); + paymentSessionRequest.setApplicationInfo(null); + + assertNotNull(paymentSessionRequest.getApplicationInfo()); + assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } +} \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentsRequestTest.java b/src/test/java/com/adyen/PaymentsRequestTest.java new file mode 100644 index 000000000..605702855 --- /dev/null +++ b/src/test/java/com/adyen/PaymentsRequestTest.java @@ -0,0 +1,72 @@ +/** + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2017 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen; + +import com.adyen.model.applicationinfo.ApplicationInfo; +import com.adyen.model.checkout.PaymentsRequest; +import org.junit.Test; + +import static com.adyen.Client.LIB_NAME; +import static com.adyen.Client.LIB_VERSION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class PaymentsRequestTest { + + @Test + public void TestDefaultApplicationInfoAdyenLibrary() { + PaymentsRequest paymentsRequest = new PaymentsRequest(); + + assertNotNull(paymentsRequest.getApplicationInfo()); + assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } + + @Test + public void TestCustomApplicationInfoAdyenLibrary() { + PaymentsRequest paymentsRequest = new PaymentsRequest(); + ApplicationInfo applicationInfo = new ApplicationInfo(); + paymentsRequest.setApplicationInfo(applicationInfo); + + assertNotNull(paymentsRequest.getApplicationInfo()); + assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } + + @Test + public void TestNullApplicationInfoAdyenLibrary() { + PaymentsRequest paymentsRequest = new PaymentsRequest(); + paymentsRequest.setApplicationInfo(null); + + assertNotNull(paymentsRequest.getApplicationInfo()); + assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary()); + assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertEquals(LIB_NAME, paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); + assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + assertEquals(LIB_VERSION, paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); + } +} \ No newline at end of file From 5bd1ed3bb57a7d4275fff0c588b81b896856215c Mon Sep 17 00:00:00 2001 From: renatoma Date: Wed, 10 Apr 2019 13:34:17 +0200 Subject: [PATCH 07/13] [PW-828] Add application info to adyen-java-api-library - Fixed setters when value is null --- .../adyen/model/AbstractPaymentRequest.java | 5 +-- .../model/checkout/PaymentMethodsRequest.java | 5 +-- .../model/checkout/PaymentSessionRequest.java | 5 +-- .../adyen/model/checkout/PaymentsRequest.java | 5 +-- .../AbstractModificationRequest.java | 14 +++---- src/test/java/com/adyen/CheckoutTest.java | 37 ++++++++++--------- .../com/adyen/ModificationRequestTest.java | 9 +---- .../com/adyen/PaymentMethodsRequestTest.java | 9 +---- .../com/adyen/PaymentRequestBuilderTest.java | 29 ++++++--------- .../java/com/adyen/PaymentRequestTest.java | 9 +---- .../com/adyen/PaymentSessionRequestTest.java | 9 +---- .../java/com/adyen/PaymentsRequestTest.java | 9 +---- 12 files changed, 51 insertions(+), 94 deletions(-) diff --git a/src/main/java/com/adyen/model/AbstractPaymentRequest.java b/src/main/java/com/adyen/model/AbstractPaymentRequest.java index 9b71035e6..b2bbdeac5 100644 --- a/src/main/java/com/adyen/model/AbstractPaymentRequest.java +++ b/src/main/java/com/adyen/model/AbstractPaymentRequest.java @@ -757,10 +757,9 @@ public ApplicationInfo getApplicationInfo() { public void setApplicationInfo(ApplicationInfo applicationInfo) { if (applicationInfo == null) { - this.applicationInfo = new ApplicationInfo(); - } else { - this.applicationInfo = applicationInfo; + throw new IllegalArgumentException("ApplicationInfo cannot be null"); } + this.applicationInfo = applicationInfo; } /** diff --git a/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java b/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java index 6c38ef473..bfb73c7b7 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java @@ -107,10 +107,9 @@ public ApplicationInfo getApplicationInfo() { public void setApplicationInfo(ApplicationInfo applicationInfo) { if (applicationInfo == null) { - this.applicationInfo = new ApplicationInfo(); - } else { - this.applicationInfo = applicationInfo; + throw new IllegalArgumentException("ApplicationInfo cannot be null"); } + this.applicationInfo = applicationInfo; } public PaymentMethodsRequest amount(Amount amount) { diff --git a/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java b/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java index ed92cd2e6..d3dd72c70 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java @@ -535,10 +535,9 @@ public ApplicationInfo getApplicationInfo() { public void setApplicationInfo(ApplicationInfo applicationInfo) { if (applicationInfo == null) { - this.applicationInfo = new ApplicationInfo(); - } else { - this.applicationInfo = applicationInfo; + throw new IllegalArgumentException("ApplicationInfo cannot be null"); } + this.applicationInfo = applicationInfo; } public PaymentSessionRequest bankAccount(BankAccount bankAccount) { diff --git a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java index a7f0f84f1..23ef3cfda 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java @@ -1032,10 +1032,9 @@ public ApplicationInfo getApplicationInfo() { public void setApplicationInfo(ApplicationInfo applicationInfo) { if (applicationInfo == null) { - this.applicationInfo = new ApplicationInfo(); - } else { - this.applicationInfo = applicationInfo; + throw new IllegalArgumentException("ApplicationInfo cannot be null"); } + this.applicationInfo = applicationInfo; } public PaymentsRequest applicationInfo(ApplicationInfo applicationInfo) { diff --git a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java index ec227effb..43631e1ba 100644 --- a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java +++ b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java @@ -20,10 +20,6 @@ */ package com.adyen.model.modification; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; import com.adyen.model.Split; import com.adyen.model.additionalData.InvoiceLine; import com.adyen.model.additionalData.SplitPayment; @@ -31,6 +27,11 @@ import com.adyen.model.applicationinfo.ApplicationInfo; import com.google.gson.annotations.SerializedName; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + /** * Abstract class for modification requests */ @@ -138,10 +139,9 @@ public ApplicationInfo getApplicationInfo() { public void setApplicationInfo(ApplicationInfo applicationInfo) { if (applicationInfo == null) { - this.applicationInfo = new ApplicationInfo(); - } else { - this.applicationInfo = applicationInfo; + throw new IllegalArgumentException("ApplicationInfo cannot be null"); } + this.applicationInfo = applicationInfo; } public T applicationInfo(ApplicationInfo applicationInfo) { diff --git a/src/test/java/com/adyen/CheckoutTest.java b/src/test/java/com/adyen/CheckoutTest.java index 58bd5a951..4071aee8c 100644 --- a/src/test/java/com/adyen/CheckoutTest.java +++ b/src/test/java/com/adyen/CheckoutTest.java @@ -20,13 +20,6 @@ */ package com.adyen; -import java.math.BigDecimal; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.TimeZone; -import org.junit.Test; import com.adyen.model.Amount; import com.adyen.model.checkout.DefaultPaymentMethodDetails; import com.adyen.model.checkout.PaymentMethodDetails; @@ -41,6 +34,17 @@ import com.adyen.model.checkout.PaymentsResponse; import com.adyen.service.Checkout; import com.google.gson.annotations.SerializedName; +import org.junit.Test; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +import static com.adyen.Client.LIB_NAME; +import static com.adyen.Client.LIB_VERSION; import static com.adyen.enums.Environment.LIVE; import static junit.framework.TestCase.assertNull; import static org.junit.Assert.assertEquals; @@ -213,7 +217,6 @@ public void TestPaymentMethodsFailureMissingIdentifierOnLive() throws Exception @Test public void TestPaymentMethodDetails() { PaymentsRequest paymentsRequest = createPaymentsCheckoutRequest(); - paymentsRequest.setApplicationInfo(null); String jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest); assertEquals("{\n" @@ -234,8 +237,8 @@ public void TestPaymentMethodDetails() { + " \"returnUrl\": \"https://your-company.com/...\",\n" + " \"applicationInfo\": {\n" + " \"adyenLibrary\": {\n" - + " \"name\": \"adyen-java-api-library\",\n" - + " \"version\": \"2.0.1\"\n" + + " \"name\": \"" + LIB_NAME + "\",\n" + + " \"version\": \"" + LIB_VERSION + "\"\n" + " }\n" + " }\n" + "}", jsonRequest); @@ -260,8 +263,8 @@ public void TestPaymentMethodDetails() { + " \"returnUrl\": \"https://your-company.com/...\",\n" + " \"applicationInfo\": {\n" + " \"adyenLibrary\": {\n" - + " \"name\": \"adyen-java-api-library\",\n" - + " \"version\": \"2.0.1\"\n" + + " \"name\": \"" + LIB_NAME + "\",\n" + + " \"version\": \"" + LIB_VERSION + "\"\n" + " }\n" + " }\n" + "}", jsonRequest); @@ -291,7 +294,6 @@ public void TestSepaPaymentMethodDetails() { defaultPaymentMethodDetails.setSepaIbanNumber("DE87123456781234567890"); PaymentsRequest paymentsRequest = createPaymentsCheckoutRequest(); - paymentsRequest.setApplicationInfo(null); paymentsRequest.setPaymentMethod(defaultPaymentMethodDetails); String jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest); @@ -311,8 +313,8 @@ public void TestSepaPaymentMethodDetails() { + " \"returnUrl\": \"https://your-company.com/...\",\n" + " \"applicationInfo\": {\n" + " \"adyenLibrary\": {\n" - + " \"name\": \"adyen-java-api-library\",\n" - + " \"version\": \"2.0.1\"\n" + + " \"name\": \"" + LIB_NAME + "\",\n" + + " \"version\": \"" + LIB_VERSION + "\"\n" + " }\n" + " }\n" + "}",jsonRequest ); @@ -321,7 +323,6 @@ public void TestSepaPaymentMethodDetails() { @Test public void TestDateSerializers() throws ParseException { PaymentsRequest paymentsRequest = new PaymentsRequest(); - paymentsRequest.setApplicationInfo(null); SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); fmt.setTimeZone(TimeZone.getTimeZone("GMT")); @@ -335,8 +336,8 @@ public void TestDateSerializers() throws ParseException { + " \"deliveryDate\": \"2018-10-31T00:00:00.000Z\",\n" + " \"applicationInfo\": {\n" + " \"adyenLibrary\": {\n" - + " \"name\": \"adyen-java-api-library\",\n" - + " \"version\": \"2.0.1\"\n" + + " \"name\": \"" + LIB_NAME + "\",\n" + + " \"version\": \"" + LIB_VERSION + "\"\n" + " }\n" + " }\n" + "}",jsonRequest ); diff --git a/src/test/java/com/adyen/ModificationRequestTest.java b/src/test/java/com/adyen/ModificationRequestTest.java index 25f1008fe..697dbfe93 100644 --- a/src/test/java/com/adyen/ModificationRequestTest.java +++ b/src/test/java/com/adyen/ModificationRequestTest.java @@ -57,16 +57,9 @@ public void TestCustomApplicationInfoAdyenLibrary() { assertEquals(LIB_VERSION, modificationRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } - @Test + @Test(expected = IllegalArgumentException.class) public void TestNullApplicationInfoAdyenLibrary() { AbstractModificationRequest modificationRequest = new AbstractModificationRequest(); modificationRequest.setApplicationInfo(null); - - assertNotNull(modificationRequest.getApplicationInfo()); - assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary()); - assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertEquals(LIB_NAME, modificationRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - assertEquals(LIB_VERSION, modificationRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } } \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentMethodsRequestTest.java b/src/test/java/com/adyen/PaymentMethodsRequestTest.java index 1d327d8d0..71b691982 100644 --- a/src/test/java/com/adyen/PaymentMethodsRequestTest.java +++ b/src/test/java/com/adyen/PaymentMethodsRequestTest.java @@ -57,16 +57,9 @@ public void TestCustomApplicationInfoAdyenLibrary() { assertEquals(LIB_VERSION, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } - @Test + @Test(expected = IllegalArgumentException.class) public void TestNullApplicationInfoAdyenLibrary() { PaymentMethodsRequest paymentMethodsRequest = new PaymentMethodsRequest(); paymentMethodsRequest.setApplicationInfo(null); - - assertNotNull(paymentMethodsRequest.getApplicationInfo()); - assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary()); - assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertEquals(LIB_NAME, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - assertEquals(LIB_VERSION, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } } \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentRequestBuilderTest.java b/src/test/java/com/adyen/PaymentRequestBuilderTest.java index 2186f66c8..62de2e393 100644 --- a/src/test/java/com/adyen/PaymentRequestBuilderTest.java +++ b/src/test/java/com/adyen/PaymentRequestBuilderTest.java @@ -20,13 +20,17 @@ */ package com.adyen; -import java.util.HashMap; -import org.junit.Test; import com.adyen.constants.ApiConstants; import com.adyen.model.PaymentRequest; import com.adyen.model.PaymentRequest3d; import com.adyen.model.applicationinfo.ApplicationInfo; import com.adyen.model.applicationinfo.ExternalPlatform; +import org.junit.Test; + +import java.util.HashMap; + +import static com.adyen.Client.LIB_NAME; +import static com.adyen.Client.LIB_VERSION; import static org.junit.Assert.assertEquals; public class PaymentRequestBuilderTest extends BaseTest { @@ -76,12 +80,8 @@ public void TestCCPaymentRequest() { + " },\n" + " \"applicationInfo\": {\n" + " \"adyenLibrary\": {\n" - + " \"name\": \"" - + Client.LIB_NAME - + "\",\n" - + " \"version\": \"" - + Client.LIB_VERSION - + "\"\n" + + " \"name\": \"" + LIB_NAME + "\",\n" + + " \"version\": \"" + LIB_VERSION + "\"\n" + " },\n" + " \"externalPlatform\": {\n" + " \"integrator\": \"" @@ -97,7 +97,6 @@ public void TestCCPaymentRequest() { @Test public void TestCSEPaymentRequest() { PaymentRequest paymentRequest = createCSEPaymentRequest(); - paymentRequest.setApplicationInfo(null); String paymentRequestJson = PRETTY_PRINT_GSON.toJson(paymentRequest); @@ -118,8 +117,8 @@ public void TestCSEPaymentRequest() { + " },\n" + " \"applicationInfo\": {\n" + " \"adyenLibrary\": {\n" - + " \"name\": \"adyen-java-api-library\",\n" - + " \"version\": \"2.0.1\"\n" + + " \"name\": \"" + LIB_NAME + "\",\n" + + " \"version\": \"" + LIB_VERSION + "\"\n" + " }\n" + " }\n" + "}"; @@ -143,12 +142,8 @@ public void Test3DSecureRequest() { + " },\n" + " \"applicationInfo\": {\n" + " \"adyenLibrary\": {\n" - + " \"name\": \"" - + Client.LIB_NAME - + "\",\n" - + " \"version\": \"" - + Client.LIB_VERSION - + "\"\n" + + " \"name\": \"" + LIB_NAME + "\",\n" + + " \"version\": \"" + LIB_VERSION + "\"\n" + " }\n" + " }\n" + "}"; diff --git a/src/test/java/com/adyen/PaymentRequestTest.java b/src/test/java/com/adyen/PaymentRequestTest.java index 70eb6d642..90c195f35 100644 --- a/src/test/java/com/adyen/PaymentRequestTest.java +++ b/src/test/java/com/adyen/PaymentRequestTest.java @@ -92,16 +92,9 @@ public void TestCustomApplicationInfoAdyenLibrary() { assertEquals(LIB_VERSION, paymentRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } - @Test + @Test(expected = IllegalArgumentException.class) public void TestNullApplicationInfoAdyenLibrary() { PaymentRequest paymentRequest = new PaymentRequest(); paymentRequest.setApplicationInfo(null); - - assertNotNull(paymentRequest.getApplicationInfo()); - assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary()); - assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertEquals(LIB_NAME, paymentRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - assertEquals(LIB_VERSION, paymentRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } } \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentSessionRequestTest.java b/src/test/java/com/adyen/PaymentSessionRequestTest.java index 23185a2e7..7f613cf59 100644 --- a/src/test/java/com/adyen/PaymentSessionRequestTest.java +++ b/src/test/java/com/adyen/PaymentSessionRequestTest.java @@ -57,16 +57,9 @@ public void TestCustomApplicationInfoAdyenLibrary() { assertEquals(LIB_VERSION, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } - @Test + @Test(expected = IllegalArgumentException.class) public void TestNullApplicationInfoAdyenLibrary() { PaymentSessionRequest paymentSessionRequest = new PaymentSessionRequest(); paymentSessionRequest.setApplicationInfo(null); - - assertNotNull(paymentSessionRequest.getApplicationInfo()); - assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary()); - assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertEquals(LIB_NAME, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - assertEquals(LIB_VERSION, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } } \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentsRequestTest.java b/src/test/java/com/adyen/PaymentsRequestTest.java index 605702855..0bc5662d9 100644 --- a/src/test/java/com/adyen/PaymentsRequestTest.java +++ b/src/test/java/com/adyen/PaymentsRequestTest.java @@ -57,16 +57,9 @@ public void TestCustomApplicationInfoAdyenLibrary() { assertEquals(LIB_VERSION, paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } - @Test + @Test(expected = IllegalArgumentException.class) public void TestNullApplicationInfoAdyenLibrary() { PaymentsRequest paymentsRequest = new PaymentsRequest(); paymentsRequest.setApplicationInfo(null); - - assertNotNull(paymentsRequest.getApplicationInfo()); - assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary()); - assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertEquals(LIB_NAME, paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - assertEquals(LIB_VERSION, paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } } \ No newline at end of file From 33eea3adb19960a8fe5d9101422c1b97784c110a Mon Sep 17 00:00:00 2001 From: renatoma Date: Fri, 12 Apr 2019 11:30:34 +0200 Subject: [PATCH 08/13] [PW-828] Add application info to adyen-java-api-library - Change set method on tests for better coverage --- src/test/java/com/adyen/ModificationRequestTest.java | 6 ++---- src/test/java/com/adyen/PaymentSessionRequestTest.java | 6 ++---- src/test/java/com/adyen/PaymentsRequestTest.java | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/test/java/com/adyen/ModificationRequestTest.java b/src/test/java/com/adyen/ModificationRequestTest.java index 697dbfe93..f454037de 100644 --- a/src/test/java/com/adyen/ModificationRequestTest.java +++ b/src/test/java/com/adyen/ModificationRequestTest.java @@ -45,9 +45,8 @@ public void TestDefaultApplicationInfoAdyenLibrary() { @Test public void TestCustomApplicationInfoAdyenLibrary() { - AbstractModificationRequest modificationRequest = new AbstractModificationRequest(); ApplicationInfo applicationInfo = new ApplicationInfo(); - modificationRequest.setApplicationInfo(applicationInfo); + AbstractModificationRequest modificationRequest = new AbstractModificationRequest().applicationInfo(applicationInfo); assertNotNull(modificationRequest.getApplicationInfo()); assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary()); @@ -59,7 +58,6 @@ public void TestCustomApplicationInfoAdyenLibrary() { @Test(expected = IllegalArgumentException.class) public void TestNullApplicationInfoAdyenLibrary() { - AbstractModificationRequest modificationRequest = new AbstractModificationRequest(); - modificationRequest.setApplicationInfo(null); + AbstractModificationRequest modificationRequest = new AbstractModificationRequest().applicationInfo(null); } } \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentSessionRequestTest.java b/src/test/java/com/adyen/PaymentSessionRequestTest.java index 7f613cf59..f151fea8b 100644 --- a/src/test/java/com/adyen/PaymentSessionRequestTest.java +++ b/src/test/java/com/adyen/PaymentSessionRequestTest.java @@ -45,9 +45,8 @@ public void TestDefaultApplicationInfoAdyenLibrary() { @Test public void TestCustomApplicationInfoAdyenLibrary() { - PaymentSessionRequest paymentSessionRequest = new PaymentSessionRequest(); ApplicationInfo applicationInfo = new ApplicationInfo(); - paymentSessionRequest.setApplicationInfo(applicationInfo); + PaymentSessionRequest paymentSessionRequest = new PaymentSessionRequest().applicationInfo(applicationInfo); assertNotNull(paymentSessionRequest.getApplicationInfo()); assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary()); @@ -59,7 +58,6 @@ public void TestCustomApplicationInfoAdyenLibrary() { @Test(expected = IllegalArgumentException.class) public void TestNullApplicationInfoAdyenLibrary() { - PaymentSessionRequest paymentSessionRequest = new PaymentSessionRequest(); - paymentSessionRequest.setApplicationInfo(null); + PaymentSessionRequest paymentSessionRequest = new PaymentSessionRequest().applicationInfo(null); } } \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentsRequestTest.java b/src/test/java/com/adyen/PaymentsRequestTest.java index 0bc5662d9..6cc863727 100644 --- a/src/test/java/com/adyen/PaymentsRequestTest.java +++ b/src/test/java/com/adyen/PaymentsRequestTest.java @@ -45,9 +45,8 @@ public void TestDefaultApplicationInfoAdyenLibrary() { @Test public void TestCustomApplicationInfoAdyenLibrary() { - PaymentsRequest paymentsRequest = new PaymentsRequest(); ApplicationInfo applicationInfo = new ApplicationInfo(); - paymentsRequest.setApplicationInfo(applicationInfo); + PaymentsRequest paymentsRequest = new PaymentsRequest().applicationInfo(applicationInfo); assertNotNull(paymentsRequest.getApplicationInfo()); assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary()); @@ -59,7 +58,6 @@ public void TestCustomApplicationInfoAdyenLibrary() { @Test(expected = IllegalArgumentException.class) public void TestNullApplicationInfoAdyenLibrary() { - PaymentsRequest paymentsRequest = new PaymentsRequest(); - paymentsRequest.setApplicationInfo(null); + PaymentsRequest paymentsRequest = new PaymentsRequest().applicationInfo(null); } } \ No newline at end of file From 79aa82ac7ddd2c3f84ea80cf424cb931e8598b09 Mon Sep 17 00:00:00 2001 From: alexandros Date: Fri, 12 Apr 2019 14:27:18 +0200 Subject: [PATCH 09/13] Add application info in ToString method for AbstractModificationRequest --- .../adyen/model/modification/AbstractModificationRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java index 9b1898502..9c48a9bc4 100644 --- a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java +++ b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java @@ -268,7 +268,7 @@ public String toString() { sb.append(" authorisationCode: ").append(toIndentedString(authorisationCode)).append("\n"); sb.append(" originalReference: ").append(toIndentedString(originalReference)).append("\n"); sb.append(" merchantAccount: ").append(toIndentedString(merchantAccount)).append("\n"); - sb.append(" applicationInfo: ").append(toIndentedString(additionalData)).append("\n"); + sb.append(" applicationInfo: ").append(toIndentedString(applicationInfo)).append("\n"); sb.append(" additionalData: ").append(toIndentedString(additionalData)).append("\n"); return sb.toString(); From 3473a0478cffadeda34ba4cd9a5f667fd20abf24 Mon Sep 17 00:00:00 2001 From: renatoma Date: Fri, 12 Apr 2019 15:11:09 +0200 Subject: [PATCH 10/13] [PW-828] Add application info to adyen-java-api-library - Reverted changes on requests that are not Payment or Modification - Removed setter from Payment and Modification requests --- .../adyen/model/AbstractPaymentRequest.java | 7 -- .../model/checkout/PaymentMethodsRequest.java | 13 ++-- .../model/checkout/PaymentSessionRequest.java | 58 ++++++++++++++--- .../adyen/model/checkout/PaymentsRequest.java | 13 ++-- .../AbstractModificationRequest.java | 12 ---- .../com/adyen/ModificationRequestTest.java | 15 ++--- .../com/adyen/PaymentMethodsRequestTest.java | 65 ------------------- .../com/adyen/PaymentRequestBuilderTest.java | 5 +- .../java/com/adyen/PaymentRequestTest.java | 15 ++--- .../com/adyen/PaymentSessionRequestTest.java | 63 ------------------ .../java/com/adyen/PaymentsRequestTest.java | 63 ------------------ 11 files changed, 76 insertions(+), 253 deletions(-) delete mode 100644 src/test/java/com/adyen/PaymentMethodsRequestTest.java delete mode 100644 src/test/java/com/adyen/PaymentSessionRequestTest.java delete mode 100644 src/test/java/com/adyen/PaymentsRequestTest.java diff --git a/src/main/java/com/adyen/model/AbstractPaymentRequest.java b/src/main/java/com/adyen/model/AbstractPaymentRequest.java index b2bbdeac5..e846f2614 100644 --- a/src/main/java/com/adyen/model/AbstractPaymentRequest.java +++ b/src/main/java/com/adyen/model/AbstractPaymentRequest.java @@ -755,13 +755,6 @@ public ApplicationInfo getApplicationInfo() { return applicationInfo; } - public void setApplicationInfo(ApplicationInfo applicationInfo) { - if (applicationInfo == null) { - throw new IllegalArgumentException("ApplicationInfo cannot be null"); - } - this.applicationInfo = applicationInfo; - } - /** * a map of key/value pairs of metadata sent by merchant * diff --git a/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java b/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java index bfb73c7b7..756653f83 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentMethodsRequest.java @@ -64,7 +64,7 @@ public class PaymentMethodsRequest { private AccountInfo accountInfo = null; @SerializedName("applciationInfo") - private ApplicationInfo applicationInfo; + private ApplicationInfo applicationInfo = null; @SerializedName("configId") private String configId = null; @@ -81,10 +81,6 @@ public class PaymentMethodsRequest { @SerializedName("trustedShopper") private Boolean trustedShopper = null; - public PaymentMethodsRequest() { - applicationInfo = new ApplicationInfo(); - } - public Object getAdditionalData() { return additionalData; } @@ -106,9 +102,6 @@ public ApplicationInfo getApplicationInfo() { } public void setApplicationInfo(ApplicationInfo applicationInfo) { - if (applicationInfo == null) { - throw new IllegalArgumentException("ApplicationInfo cannot be null"); - } this.applicationInfo = applicationInfo; } @@ -396,4 +389,8 @@ public ChannelEnum read(final JsonReader jsonReader) throws IOException { } } + } + + + diff --git a/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java b/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java index d3dd72c70..741c369a4 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentSessionRequest.java @@ -89,6 +89,9 @@ public class PaymentSessionRequest { @SerializedName("card") private Card card = null; + + + /** * The platform where a payment transaction takes place. This field is optional for filtering out payment methods that are only available on specific platforms. If this value is not set, then we * will try to infer it from the `sdkVersion` or `token`. Possible values: * iOS * Android * Web @@ -445,15 +448,12 @@ public ShopperInteractionEnum read(final JsonReader jsonReader) throws IOExcepti @SerializedName("uniqueTerminalId") private String uniqueTerminalId = null; - public PaymentSessionRequest() { - applicationInfo = new ApplicationInfo(); - } - public PaymentSessionRequest accountInfo(AccountInfo accountInfo) { this.accountInfo = accountInfo; return this; } + public AccountInfo getAccountInfo() { return accountInfo; } @@ -467,6 +467,7 @@ public PaymentSessionRequest additionalAmount(Amount additionalAmount) { return this; } + public Amount getAdditionalAmount() { return additionalAmount; } @@ -480,6 +481,7 @@ public PaymentSessionRequest additionalData(Object additionalData) { return this; } + public Object getAdditionalData() { return additionalData; } @@ -503,6 +505,7 @@ public PaymentSessionRequest addAllowedPaymentMethodsItem(String allowedPaymentM return this; } + public List getAllowedPaymentMethods() { return allowedPaymentMethods; } @@ -516,6 +519,7 @@ public PaymentSessionRequest amount(Amount amount) { return this; } + public Amount getAmount() { return amount; } @@ -525,7 +529,7 @@ public void setAmount(Amount amount) { } public PaymentSessionRequest applicationInfo(ApplicationInfo applicationInfo) { - setApplicationInfo(applicationInfo); + this.applicationInfo = applicationInfo; return this; } @@ -534,9 +538,6 @@ public ApplicationInfo getApplicationInfo() { } public void setApplicationInfo(ApplicationInfo applicationInfo) { - if (applicationInfo == null) { - throw new IllegalArgumentException("ApplicationInfo cannot be null"); - } this.applicationInfo = applicationInfo; } @@ -545,6 +546,7 @@ public PaymentSessionRequest bankAccount(BankAccount bankAccount) { return this; } + public BankAccount getBankAccount() { return bankAccount; } @@ -558,6 +560,7 @@ public PaymentSessionRequest billingAddress(Address billingAddress) { return this; } + public Address getBillingAddress() { return billingAddress; } @@ -581,6 +584,7 @@ public PaymentSessionRequest addBlockedPaymentMethodsItem(String blockedPaymentM return this; } + public List getBlockedPaymentMethods() { return blockedPaymentMethods; } @@ -607,6 +611,7 @@ public PaymentSessionRequest captureDelayHours(Integer captureDelayHours) { return this; } + public Integer getCaptureDelayHours() { return captureDelayHours; } @@ -633,6 +638,7 @@ public PaymentSessionRequest channel(ChannelEnum channel) { return this; } + public ChannelEnum getChannel() { return channel; } @@ -659,6 +665,7 @@ public PaymentSessionRequest configId(String configId) { return this; } + public String getConfigId() { return configId; } @@ -724,6 +731,7 @@ public PaymentSessionRequest deliveryAddress(Address deliveryAddress) { return this; } + public Address getDeliveryAddress() { return deliveryAddress; } @@ -776,6 +784,7 @@ public PaymentSessionRequest enablePayOut(Boolean enablePayOut) { return this; } + public Boolean isEnablePayOut() { return enablePayOut; } @@ -802,6 +811,7 @@ public PaymentSessionRequest entityType(EntityTypeEnum entityType) { return this; } + public EntityTypeEnum getEntityType() { return entityType; } @@ -815,6 +825,7 @@ public PaymentSessionRequest fraudOffset(Integer fraudOffset) { return this; } + public Integer getFraudOffset() { return fraudOffset; } @@ -841,6 +852,7 @@ public PaymentSessionRequest installments(Installments installments) { return this; } + public Installments getInstallments() { return installments; } @@ -864,6 +876,7 @@ public PaymentSessionRequest addLineItemsItem(LineItem lineItemsItem) { return this; } + public List getLineItems() { return lineItems; } @@ -877,6 +890,7 @@ public PaymentSessionRequest mcc(String mcc) { return this; } + public String getMcc() { return mcc; } @@ -890,6 +904,7 @@ public PaymentSessionRequest merchantAccount(String merchantAccount) { return this; } + public String getMerchantAccount() { return merchantAccount; } @@ -903,6 +918,7 @@ public PaymentSessionRequest merchantOrderReference(String merchantOrderReferenc return this; } + public String getMerchantOrderReference() { return merchantOrderReference; } @@ -916,6 +932,7 @@ public PaymentSessionRequest merchantRiskIndicator(MerchantRiskIndicator merchan return this; } + public MerchantRiskIndicator getMerchantRiskIndicator() { return merchantRiskIndicator; } @@ -929,6 +946,7 @@ public PaymentSessionRequest metadata(Object metadata) { return this; } + public Object getMetadata() { return metadata; } @@ -942,6 +960,7 @@ public PaymentSessionRequest mpiData(ThreeDSecureData mpiData) { return this; } + public ThreeDSecureData getMpiData() { return mpiData; } @@ -955,6 +974,7 @@ public PaymentSessionRequest nationality(String nationality) { return this; } + public String getNationality() { return nationality; } @@ -968,6 +988,7 @@ public PaymentSessionRequest orderReference(String orderReference) { return this; } + public String getOrderReference() { return orderReference; } @@ -981,6 +1002,7 @@ public PaymentSessionRequest origin(String origin) { return this; } + public String getOrigin() { return origin; } @@ -994,6 +1016,7 @@ public PaymentSessionRequest recurring(Recurring recurring) { return this; } + public Recurring getRecurring() { return recurring; } @@ -1007,6 +1030,7 @@ public PaymentSessionRequest recurringProcessingModel(RecurringProcessingModelEn return this; } + public RecurringProcessingModelEnum getRecurringProcessingModel() { return recurringProcessingModel; } @@ -1033,6 +1057,7 @@ public PaymentSessionRequest returnUrl(String returnUrl) { return this; } + public String getReturnUrl() { return returnUrl; } @@ -1046,6 +1071,7 @@ public PaymentSessionRequest sdkVersion(String sdkVersion) { return this; } + public String getSdkVersion() { return sdkVersion; } @@ -1072,6 +1098,7 @@ public PaymentSessionRequest selectedRecurringDetailReference(String selectedRec return this; } + public String getSelectedRecurringDetailReference() { return selectedRecurringDetailReference; } @@ -1085,6 +1112,7 @@ public PaymentSessionRequest sessionId(String sessionId) { return this; } + public String getSessionId() { return sessionId; } @@ -1111,6 +1139,7 @@ public PaymentSessionRequest shopperEmail(String shopperEmail) { return this; } + public String getShopperEmail() { return shopperEmail; } @@ -1124,6 +1153,7 @@ public PaymentSessionRequest shopperIP(String shopperIP) { return this; } + public String getShopperIP() { return shopperIP; } @@ -1137,6 +1167,7 @@ public PaymentSessionRequest shopperInteraction(ShopperInteractionEnum shopperIn return this; } + public ShopperInteractionEnum getShopperInteraction() { return shopperInteraction; } @@ -1150,6 +1181,7 @@ public PaymentSessionRequest shopperLocale(String shopperLocale) { return this; } + public String getShopperLocale() { return shopperLocale; } @@ -1176,6 +1208,7 @@ public PaymentSessionRequest shopperReference(String shopperReference) { return this; } + public String getShopperReference() { return shopperReference; } @@ -1238,6 +1271,7 @@ public PaymentSessionRequest store(String store) { return this; } + public String getStore() { return store; } @@ -1251,6 +1285,7 @@ public PaymentSessionRequest telephoneNumber(String telephoneNumber) { return this; } + public String getTelephoneNumber() { return telephoneNumber; } @@ -1264,6 +1299,7 @@ public PaymentSessionRequest threeDS2RequestData(ThreeDS2RequestData threeDS2Req return this; } + public ThreeDS2RequestData getThreeDS2RequestData() { return threeDS2RequestData; } @@ -1290,6 +1326,7 @@ public PaymentSessionRequest totalsGroup(String totalsGroup) { return this; } + public void setTotalsGroup(String totalsGroup) { this.totalsGroup = totalsGroup; } @@ -1299,6 +1336,7 @@ public PaymentSessionRequest trustedShopper(Boolean trustedShopper) { return this; } + public Boolean isTrustedShopper() { return trustedShopper; } @@ -1312,6 +1350,7 @@ public PaymentSessionRequest uniqueTerminalId(String uniqueTerminalId) { return this; } + public String getUniqueTerminalId() { return uniqueTerminalId; } @@ -1547,4 +1586,7 @@ private String toIndentedString(java.lang.Object o) { return o.toString().replace("\n", "\n "); } + } + + diff --git a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java index 23ef3cfda..67bcca36d 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java @@ -159,7 +159,9 @@ public class PaymentsRequest { public PaymentsRequest() { - this.applicationInfo = new ApplicationInfo(); + if (this.applicationInfo == null) { + this.applicationInfo = new ApplicationInfo(); + } } public MerchantRiskIndicator getMerchantRiskIndicator() { @@ -1031,14 +1033,11 @@ public ApplicationInfo getApplicationInfo() { } public void setApplicationInfo(ApplicationInfo applicationInfo) { - if (applicationInfo == null) { - throw new IllegalArgumentException("ApplicationInfo cannot be null"); - } this.applicationInfo = applicationInfo; } public PaymentsRequest applicationInfo(ApplicationInfo applicationInfo) { - setApplicationInfo(applicationInfo); + this.applicationInfo = applicationInfo; return this; } @@ -1376,4 +1375,8 @@ public ShopperInteractionEnum read(final JsonReader jsonReader) throws IOExcepti } } + } + + + diff --git a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java index 43631e1ba..e75bbd51d 100644 --- a/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java +++ b/src/main/java/com/adyen/model/modification/AbstractModificationRequest.java @@ -137,18 +137,6 @@ public ApplicationInfo getApplicationInfo() { return applicationInfo; } - public void setApplicationInfo(ApplicationInfo applicationInfo) { - if (applicationInfo == null) { - throw new IllegalArgumentException("ApplicationInfo cannot be null"); - } - this.applicationInfo = applicationInfo; - } - - public T applicationInfo(ApplicationInfo applicationInfo) { - setApplicationInfo(applicationInfo); - return (T) this; - } - public Map getAdditionalData() { return additionalData; } diff --git a/src/test/java/com/adyen/ModificationRequestTest.java b/src/test/java/com/adyen/ModificationRequestTest.java index f454037de..3f2329b19 100644 --- a/src/test/java/com/adyen/ModificationRequestTest.java +++ b/src/test/java/com/adyen/ModificationRequestTest.java @@ -20,7 +20,7 @@ */ package com.adyen; -import com.adyen.model.applicationinfo.ApplicationInfo; +import com.adyen.model.applicationinfo.ExternalPlatform; import com.adyen.model.modification.AbstractModificationRequest; import org.junit.Test; @@ -44,9 +44,11 @@ public void TestDefaultApplicationInfoAdyenLibrary() { } @Test - public void TestCustomApplicationInfoAdyenLibrary() { - ApplicationInfo applicationInfo = new ApplicationInfo(); - AbstractModificationRequest modificationRequest = new AbstractModificationRequest().applicationInfo(applicationInfo); + public void TestModifiedApplicationInfoAdyenLibrary() { + AbstractModificationRequest modificationRequest = new AbstractModificationRequest(); + ExternalPlatform externalPlatform = new ExternalPlatform(); + externalPlatform.setIntegrator("TEST"); + modificationRequest.getApplicationInfo().setExternalPlatform(externalPlatform); assertNotNull(modificationRequest.getApplicationInfo()); assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary()); @@ -55,9 +57,4 @@ public void TestCustomApplicationInfoAdyenLibrary() { assertNotNull(modificationRequest.getApplicationInfo().getAdyenLibrary().getVersion()); assertEquals(LIB_VERSION, modificationRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } - - @Test(expected = IllegalArgumentException.class) - public void TestNullApplicationInfoAdyenLibrary() { - AbstractModificationRequest modificationRequest = new AbstractModificationRequest().applicationInfo(null); - } } \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentMethodsRequestTest.java b/src/test/java/com/adyen/PaymentMethodsRequestTest.java deleted file mode 100644 index 71b691982..000000000 --- a/src/test/java/com/adyen/PaymentMethodsRequestTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * ###### - * ###### - * ############ ####( ###### #####. ###### ############ ############ - * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ###### - * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - * - * Adyen Java API Library - * - * Copyright (c) 2017 Adyen B.V. - * This file is open source and available under the MIT license. - * See the LICENSE file for more info. - */ -package com.adyen; - -import com.adyen.model.applicationinfo.ApplicationInfo; -import com.adyen.model.checkout.PaymentMethodsRequest; -import org.junit.Test; - -import static com.adyen.Client.LIB_NAME; -import static com.adyen.Client.LIB_VERSION; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -public class PaymentMethodsRequestTest { - - @Test - public void TestDefaultApplicationInfoAdyenLibrary() { - PaymentMethodsRequest paymentMethodsRequest = new PaymentMethodsRequest(); - - assertNotNull(paymentMethodsRequest.getApplicationInfo()); - assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary()); - assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertEquals(LIB_NAME, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - assertEquals(LIB_VERSION, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - } - - @Test - public void TestCustomApplicationInfoAdyenLibrary() { - PaymentMethodsRequest paymentMethodsRequest = new PaymentMethodsRequest(); - ApplicationInfo applicationInfo = new ApplicationInfo(); - paymentMethodsRequest.setApplicationInfo(applicationInfo); - - assertNotNull(paymentMethodsRequest.getApplicationInfo()); - assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary()); - assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertEquals(LIB_NAME, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertNotNull(paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - assertEquals(LIB_VERSION, paymentMethodsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - } - - @Test(expected = IllegalArgumentException.class) - public void TestNullApplicationInfoAdyenLibrary() { - PaymentMethodsRequest paymentMethodsRequest = new PaymentMethodsRequest(); - paymentMethodsRequest.setApplicationInfo(null); - } -} \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentRequestBuilderTest.java b/src/test/java/com/adyen/PaymentRequestBuilderTest.java index 62de2e393..b3c5283be 100644 --- a/src/test/java/com/adyen/PaymentRequestBuilderTest.java +++ b/src/test/java/com/adyen/PaymentRequestBuilderTest.java @@ -40,11 +40,10 @@ public class PaymentRequestBuilderTest extends BaseTest { public void TestCCPaymentRequest() { String integratorName = "TestIntegrator"; PaymentRequest paymentRequest = createFullCardPaymentRequest(); - ApplicationInfo applicationInfo = new ApplicationInfo(); ExternalPlatform externalPlatform = new ExternalPlatform(); externalPlatform.setIntegrator(integratorName); - applicationInfo.setExternalPlatform(externalPlatform); - paymentRequest.setApplicationInfo(applicationInfo); + paymentRequest.getApplicationInfo().setExternalPlatform(externalPlatform); + // Test metadata paymentRequest.setMetadata(new HashMap()); diff --git a/src/test/java/com/adyen/PaymentRequestTest.java b/src/test/java/com/adyen/PaymentRequestTest.java index 90c195f35..50b4c5470 100644 --- a/src/test/java/com/adyen/PaymentRequestTest.java +++ b/src/test/java/com/adyen/PaymentRequestTest.java @@ -20,10 +20,10 @@ */ package com.adyen; -import com.adyen.model.applicationinfo.ApplicationInfo; -import org.junit.Test; import com.adyen.enums.VatCategory; import com.adyen.model.PaymentRequest; +import com.adyen.model.applicationinfo.ExternalPlatform; +import org.junit.Test; import static com.adyen.Client.LIB_NAME; import static com.adyen.Client.LIB_VERSION; @@ -81,8 +81,9 @@ public void TestDefaultApplicationInfoAdyenLibrary() { @Test public void TestCustomApplicationInfoAdyenLibrary() { PaymentRequest paymentRequest = new PaymentRequest(); - ApplicationInfo applicationInfo = new ApplicationInfo(); - paymentRequest.setApplicationInfo(applicationInfo); + ExternalPlatform externalPlatform = new ExternalPlatform(); + externalPlatform.setIntegrator("TEST"); + paymentRequest.getApplicationInfo().setExternalPlatform(externalPlatform); assertNotNull(paymentRequest.getApplicationInfo()); assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary()); @@ -91,10 +92,4 @@ public void TestCustomApplicationInfoAdyenLibrary() { assertNotNull(paymentRequest.getApplicationInfo().getAdyenLibrary().getVersion()); assertEquals(LIB_VERSION, paymentRequest.getApplicationInfo().getAdyenLibrary().getVersion()); } - - @Test(expected = IllegalArgumentException.class) - public void TestNullApplicationInfoAdyenLibrary() { - PaymentRequest paymentRequest = new PaymentRequest(); - paymentRequest.setApplicationInfo(null); - } } \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentSessionRequestTest.java b/src/test/java/com/adyen/PaymentSessionRequestTest.java deleted file mode 100644 index f151fea8b..000000000 --- a/src/test/java/com/adyen/PaymentSessionRequestTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * ###### - * ###### - * ############ ####( ###### #####. ###### ############ ############ - * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ###### - * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - * - * Adyen Java API Library - * - * Copyright (c) 2017 Adyen B.V. - * This file is open source and available under the MIT license. - * See the LICENSE file for more info. - */ -package com.adyen; - -import com.adyen.model.applicationinfo.ApplicationInfo; -import com.adyen.model.checkout.PaymentSessionRequest; -import org.junit.Test; - -import static com.adyen.Client.LIB_NAME; -import static com.adyen.Client.LIB_VERSION; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -public class PaymentSessionRequestTest { - - @Test - public void TestDefaultApplicationInfoAdyenLibrary() { - PaymentSessionRequest paymentSessionRequest = new PaymentSessionRequest(); - - assertNotNull(paymentSessionRequest.getApplicationInfo()); - assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary()); - assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertEquals(LIB_NAME, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - assertEquals(LIB_VERSION, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - } - - @Test - public void TestCustomApplicationInfoAdyenLibrary() { - ApplicationInfo applicationInfo = new ApplicationInfo(); - PaymentSessionRequest paymentSessionRequest = new PaymentSessionRequest().applicationInfo(applicationInfo); - - assertNotNull(paymentSessionRequest.getApplicationInfo()); - assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary()); - assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertEquals(LIB_NAME, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertNotNull(paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - assertEquals(LIB_VERSION, paymentSessionRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - } - - @Test(expected = IllegalArgumentException.class) - public void TestNullApplicationInfoAdyenLibrary() { - PaymentSessionRequest paymentSessionRequest = new PaymentSessionRequest().applicationInfo(null); - } -} \ No newline at end of file diff --git a/src/test/java/com/adyen/PaymentsRequestTest.java b/src/test/java/com/adyen/PaymentsRequestTest.java deleted file mode 100644 index 6cc863727..000000000 --- a/src/test/java/com/adyen/PaymentsRequestTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * ###### - * ###### - * ############ ####( ###### #####. ###### ############ ############ - * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ###### - * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - * - * Adyen Java API Library - * - * Copyright (c) 2017 Adyen B.V. - * This file is open source and available under the MIT license. - * See the LICENSE file for more info. - */ -package com.adyen; - -import com.adyen.model.applicationinfo.ApplicationInfo; -import com.adyen.model.checkout.PaymentsRequest; -import org.junit.Test; - -import static com.adyen.Client.LIB_NAME; -import static com.adyen.Client.LIB_VERSION; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -public class PaymentsRequestTest { - - @Test - public void TestDefaultApplicationInfoAdyenLibrary() { - PaymentsRequest paymentsRequest = new PaymentsRequest(); - - assertNotNull(paymentsRequest.getApplicationInfo()); - assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary()); - assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertEquals(LIB_NAME, paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - assertEquals(LIB_VERSION, paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - } - - @Test - public void TestCustomApplicationInfoAdyenLibrary() { - ApplicationInfo applicationInfo = new ApplicationInfo(); - PaymentsRequest paymentsRequest = new PaymentsRequest().applicationInfo(applicationInfo); - - assertNotNull(paymentsRequest.getApplicationInfo()); - assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary()); - assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertEquals(LIB_NAME, paymentsRequest.getApplicationInfo().getAdyenLibrary().getName()); - assertNotNull(paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - assertEquals(LIB_VERSION, paymentsRequest.getApplicationInfo().getAdyenLibrary().getVersion()); - } - - @Test(expected = IllegalArgumentException.class) - public void TestNullApplicationInfoAdyenLibrary() { - PaymentsRequest paymentsRequest = new PaymentsRequest().applicationInfo(null); - } -} \ No newline at end of file From ce338af86e729caec2583b872213a03d524dbb77 Mon Sep 17 00:00:00 2001 From: alexandros Date: Fri, 12 Apr 2019 15:15:23 +0200 Subject: [PATCH 11/13] Add pending status --- .../java/com/adyen/model/checkout/PaymentResultResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/adyen/model/checkout/PaymentResultResponse.java b/src/main/java/com/adyen/model/checkout/PaymentResultResponse.java index cd1c2d1d7..99e409f5c 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentResultResponse.java +++ b/src/main/java/com/adyen/model/checkout/PaymentResultResponse.java @@ -275,12 +275,12 @@ private String toIndentedString(Object o) { public enum ResultCodeEnum { AUTHORISED("Authorised"), - PARTIALLYAUTHORISED("PartiallyAuthorised"), REFUSED("Refused"), ERROR("Error"), CANCELLED("Cancelled"), RECEIVED("Received"), - REDIRECTSHOPPER("RedirectShopper"); + REDIRECTSHOPPER("RedirectShopper"), + PENDING("Pending"); private String value; From 7b4e0b243292d18e8bacb84d2268e2d6162e0e77 Mon Sep 17 00:00:00 2001 From: renatoma Date: Fri, 12 Apr 2019 16:05:31 +0200 Subject: [PATCH 12/13] [PW-828] Add application info to adyen-java-api-library - Fixed copyright --- src/test/java/com/adyen/ModificationRequestTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/adyen/ModificationRequestTest.java b/src/test/java/com/adyen/ModificationRequestTest.java index 3f2329b19..0e7b04e6f 100644 --- a/src/test/java/com/adyen/ModificationRequestTest.java +++ b/src/test/java/com/adyen/ModificationRequestTest.java @@ -1,4 +1,4 @@ -/** +/* * ###### * ###### * ############ ####( ###### #####. ###### ############ ############ @@ -14,7 +14,7 @@ * * Adyen Java API Library * - * Copyright (c) 2017 Adyen B.V. + * Copyright (c) 2019 Adyen B.V. * This file is open source and available under the MIT license. * See the LICENSE file for more info. */ From 81c3b93ce1f6ae1de28a42cba765f254aea907ba Mon Sep 17 00:00:00 2001 From: alexandros Date: Wed, 17 Apr 2019 11:56:33 +0200 Subject: [PATCH 13/13] Update version to 2.0.2 --- README.md | 8 ++++---- pom.xml | 2 +- src/main/java/com/adyen/Client.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d1509ff16..2ae964f30 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ The Library supports all APIs under the following services: * Java 7 or higher ## Installation - + You can use Maven or simply download the release. - + ### Maven Add this dependency to your project's POM: @@ -35,7 +35,7 @@ Add this dependency to your project's POM: com.adyen adyen-java-api-library - 2.0.1 + 2.0.2 ``` @@ -62,7 +62,7 @@ client.setHttpClient(httpURLConnectionClientWithProxy); ## Support If you have any problems, questions or suggestions, create an issue here or send your inquiry to support@adyen.com. - + ## Licence MIT license. For more information, see the LICENSE file. diff --git a/pom.xml b/pom.xml index 786795b3b..b1b9f20e1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.adyen adyen-java-api-library jar - 2.0.1 + 2.0.2 Adyen Java API Library Adyen API Client Library for Java https://github.com/adyen/adyen-java-api-library diff --git a/src/main/java/com/adyen/Client.java b/src/main/java/com/adyen/Client.java index dbb524765..c02e87c5b 100644 --- a/src/main/java/com/adyen/Client.java +++ b/src/main/java/com/adyen/Client.java @@ -41,7 +41,7 @@ public class Client { public static final String MARKETPAY_FUND_API_VERSION = "v3"; public static final String MARKETPAY_NOTIFICATION_API_VERSION = "v1"; public static final String LIB_NAME = "adyen-java-api-library"; - public static final String LIB_VERSION = "2.0.1"; + public static final String LIB_VERSION = "2.0.2"; public static final String CHECKOUT_ENDPOINT_TEST = "https://checkout-test.adyen.com/checkout"; public static final String CHECKOUT_ENDPOINT_LIVE_SUFFIX = "-checkout-live.adyenpayments.com/checkout"; public static final String CHECKOUT_API_VERSION = "v41";