Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Release 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingenico ePayments committed Apr 1, 2016
1 parent 4207cf9 commit 740d1f3
Show file tree
Hide file tree
Showing 74 changed files with 2,572 additions and 1,452 deletions.
16 changes: 13 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

<groupId>com.ingenico.connect.gateway</groupId>
<artifactId>connect-sdk-java</artifactId>
<version>1.0.0</version>
<version>2.0.0</version>
<packaging>jar</packaging>

<name>connect-sdk-java</name>
<description>SDK to communicate with the GlobalCollect platform using the Ingenico Connect Server API</description>
<url>https://github.com/Ingenico-ePayments/connect-sdk-java</url>

<organization>
<name>Ingenico ePayments</name>
<name>Ingenico ePayments</name>
<url>http://www.globalcollect.com/</url>
</organization>

Expand Down Expand Up @@ -49,6 +49,8 @@

<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>

<version.httpclient>4.5.2</version.httpclient>
</properties>

<build>
Expand Down Expand Up @@ -250,7 +252,15 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
<version>${version.httpclient}</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<classifier>tests</classifier>
<version>${version.httpclient}</version>
<scope>test</scope>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ private void testConnectionPooling(int requestCount, int maxConnections) throws
ExecutorService executorService = Executors.newFixedThreadPool(requestCount);
try {

GcDefaultConfiguration defaultConfiguration = getDefaultConfiguration();
defaultConfiguration.setMaxConnections(maxConnections);
GcDefaultConfiguration defaultConfiguration = getDefaultConfiguration()
.withMaxConnections(maxConnections);
GcCommunicator communicator = GcFactory.createCommunicator(defaultConfiguration);
try {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.globalcollect.gateway.sdk.it;

import java.io.IOException;
import java.net.URISyntaxException;

import org.junit.Assert;
import org.junit.Test;

import com.globalcollect.gateway.sdk.java.gc.GcClient;
import com.globalcollect.gateway.sdk.java.gc.merchant.services.ConvertAmountParams;
import com.globalcollect.gateway.sdk.java.gc.services.ConvertAmount;

Expand All @@ -14,15 +16,21 @@ public class ConvertAmountTest extends ItTest {
* Smoke test for convert amount service.
*/
@Test
public void test() throws URISyntaxException {
public void test() throws URISyntaxException, IOException {

ConvertAmountParams request = new ConvertAmountParams();
request.setAmount(123L);
request.setSource("USD");
request.setTarget("EUR");

ConvertAmount response = getGcClient().merchant("9991").services().convertAmount(request);
GcClient client = getGcClient();
try {
ConvertAmount response = client.merchant("9991").services().convertAmount(request);

Assert.assertNotNull(response.getConvertedAmount());
Assert.assertNotNull(response.getConvertedAmount());

} finally {
client.close();
}
}
}
80 changes: 80 additions & 0 deletions src/it/java/com/globalcollect/gateway/sdk/it/IdempotenceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.globalcollect.gateway.sdk.it;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.UUID;

import org.junit.Assert;
import org.junit.Test;

import com.globalcollect.gateway.sdk.java.CallContext;
import com.globalcollect.gateway.sdk.java.gc.GcClient;
import com.globalcollect.gateway.sdk.java.gc.fei.definitions.Address;
import com.globalcollect.gateway.sdk.java.gc.fei.definitions.AmountOfMoney;
import com.globalcollect.gateway.sdk.java.gc.payment.CreatePaymentRequest;
import com.globalcollect.gateway.sdk.java.gc.payment.CreatePaymentResponse;
import com.globalcollect.gateway.sdk.java.gc.payment.definitions.Customer;
import com.globalcollect.gateway.sdk.java.gc.payment.definitions.Order;
import com.globalcollect.gateway.sdk.java.gc.payment.definitions.RedirectPaymentMethodSpecificInput;
import com.globalcollect.gateway.sdk.java.gc.payment.definitions.RedirectPaymentProduct809SpecificInput;

public class IdempotenceTest extends ItTest {

/**
* Smoke test for idempotence.
*/
@Test
public void test() throws URISyntaxException, IOException {

CreatePaymentRequest body = new CreatePaymentRequest();

Order order = new Order();

AmountOfMoney amountOfMoney = new AmountOfMoney();
amountOfMoney.setCurrencyCode("EUR");
amountOfMoney.setAmount(100L);
order.setAmountOfMoney(amountOfMoney);

Customer customer = new Customer();
customer.setLocale("en");

Address billingAddress = new Address();
billingAddress.setCountryCode("NL");
customer.setBillingAddress(billingAddress);

order.setCustomer(customer);
body.setOrder(order);

RedirectPaymentMethodSpecificInput paymentMethodSpecificInput = new RedirectPaymentMethodSpecificInput();
paymentMethodSpecificInput.setReturnUrl("http://example.com/");
paymentMethodSpecificInput.setPaymentProductId(809);

RedirectPaymentProduct809SpecificInput paymentProductSpecificInput = new RedirectPaymentProduct809SpecificInput();
paymentProductSpecificInput.setIssuerId("INGBNL2A");
paymentMethodSpecificInput.setPaymentProduct809SpecificInput(paymentProductSpecificInput);

body.setRedirectPaymentMethodSpecificInput(paymentMethodSpecificInput);

String idempotenceKey = UUID.randomUUID().toString();
CallContext context = new CallContext().withIdempotenceKey(idempotenceKey);

GcClient client = getGcClient();
try {
CreatePaymentResponse response = client.merchant("20000").payments().create(body, context);
String paymentId = response.getPayment().getId();

Assert.assertEquals(idempotenceKey, context.getIdempotenceKey());
Assert.assertNull(context.getIdempotenceRequestTimestamp());

response = client.merchant("20000").payments().create(body, context);

Assert.assertEquals(paymentId, response.getPayment().getId());

Assert.assertEquals(idempotenceKey, context.getIdempotenceKey());
Assert.assertNotNull(context.getIdempotenceRequestTimestamp());

} finally {
client.close();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.globalcollect.gateway.sdk.it;

import java.io.IOException;
import java.net.URISyntaxException;

import org.junit.Assert;
import org.junit.Test;

import com.globalcollect.gateway.sdk.java.gc.GcClient;
import com.globalcollect.gateway.sdk.java.gc.merchant.products.paymentproduct.DirectoryParams;
import com.globalcollect.gateway.sdk.java.gc.product.Directory;

Expand All @@ -14,13 +16,20 @@ public class PaymentProductsTest extends ItTest {
* Smoke test for products service.
*/
@Test
public void test() throws URISyntaxException {
public void test() throws URISyntaxException, IOException {

DirectoryParams params = new DirectoryParams();
params.setCountryCode("NL");
params.setCurrencyCode("EUR");
Directory response = getGcClient().merchant("8500").products().paymentProduct(809).directory(params);

Assert.assertTrue(response.getEntries().size() > 0);
GcClient client = getGcClient();
try {
Directory response = client.merchant("8500").products().paymentProduct(809).directory(params);

Assert.assertTrue(response.getEntries().size() > 0);

} finally {
client.close();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.globalcollect.gateway.sdk.it;

import java.io.IOException;
import java.net.URISyntaxException;

import org.junit.Assert;
import org.junit.Test;

import com.globalcollect.gateway.sdk.java.gc.GcClient;
import com.globalcollect.gateway.sdk.java.gc.fei.definitions.AmountOfMoney;
import com.globalcollect.gateway.sdk.java.gc.fei.definitions.BankAccountBban;
import com.globalcollect.gateway.sdk.java.gc.riskassessments.RiskAssessmentBankAccount;
Expand All @@ -18,7 +20,7 @@ public class RiskAssessmentsTest extends ItTest {
* Smoke test for risk assessments service.
*/
@Test
public void test() throws URISyntaxException {
public void test() throws URISyntaxException, IOException {

RiskAssessmentBankAccount body = new RiskAssessmentBankAccount();

Expand All @@ -41,7 +43,13 @@ public void test() throws URISyntaxException {

body.setOrder(order);

RiskAssessmentResponse riskAssessmentResponse = getGcClient().merchant("8500").riskassessments().bankaccounts(body);
Assert.assertTrue(riskAssessmentResponse.getResults().size() > 0);
GcClient client = getGcClient();
try {
RiskAssessmentResponse riskAssessmentResponse = client.merchant("8500").riskassessments().bankaccounts(body);
Assert.assertTrue(riskAssessmentResponse.getResults().size() > 0);

} finally {
client.close();
}
}
}
24 changes: 16 additions & 8 deletions src/it/java/com/globalcollect/gateway/sdk/it/SDKProxyTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.globalcollect.gateway.sdk.it;

import java.io.IOException;
import java.lang.reflect.Field;
import java.net.URISyntaxException;

Expand All @@ -19,6 +20,7 @@
import com.globalcollect.gateway.sdk.java.defaultimpl.DefaultGcCommunicator;
import com.globalcollect.gateway.sdk.java.defaultimpl.DefaultGcConnection;
import com.globalcollect.gateway.sdk.java.defaultimpl.DefaultGcSession;
import com.globalcollect.gateway.sdk.java.gc.GcClient;
import com.globalcollect.gateway.sdk.java.gc.merchant.services.ConvertAmountParams;
import com.globalcollect.gateway.sdk.java.gc.merchant.services.ServicesClient;
import com.globalcollect.gateway.sdk.java.gc.merchant.services.ServicesClientImpl;
Expand All @@ -30,23 +32,29 @@ public class SDKProxyTest extends ItTest {
* Smoke test for using a proxy configured through SDK properties.
*/
@Test
public void test() throws URISyntaxException {
public void test() throws URISyntaxException, IOException {

ConvertAmountParams request = new ConvertAmountParams();
request.setAmount(123L);
request.setSource("USD");
request.setTarget("EUR");

ServicesClient services = getGcClientWithProxy().merchant("9991").services();
GcClient client = getGcClientWithProxy();
try {
ServicesClient services = client.merchant("9991").services();

Assert.assertTrue(services instanceof ServicesClientImpl);
GcDefaultConfiguration configuration = getDefaultConfigurationWithProxy();
Assert.assertNotNull(configuration.getProxyConfiguration());
assertProxySet((ServicesClientImpl) services, configuration.getProxyConfiguration());
Assert.assertTrue(services instanceof ServicesClientImpl);
GcDefaultConfiguration configuration = getDefaultConfigurationWithProxy();
Assert.assertNotNull(configuration.getProxyConfiguration());
assertProxySet((ServicesClientImpl) services, configuration.getProxyConfiguration());

ConvertAmount response = services.convertAmount(request);
ConvertAmount response = services.convertAmount(request);

Assert.assertNotNull(response.getConvertedAmount());
Assert.assertNotNull(response.getConvertedAmount());

} finally {
client.close();
}
}

private void assertProxySet(GcApiResource resource, GcProxyConfiguration proxyConfiguration) {
Expand Down
18 changes: 13 additions & 5 deletions src/it/java/com/globalcollect/gateway/sdk/it/SystemProxyTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.globalcollect.gateway.sdk.it;

import java.io.IOException;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URISyntaxException;
Expand All @@ -9,6 +10,7 @@

import com.globalcollect.gateway.sdk.java.GcDefaultConfiguration;
import com.globalcollect.gateway.sdk.java.GcFactory;
import com.globalcollect.gateway.sdk.java.gc.GcClient;
import com.globalcollect.gateway.sdk.java.gc.merchant.services.ConvertAmountParams;
import com.globalcollect.gateway.sdk.java.gc.services.ConvertAmount;

Expand All @@ -18,7 +20,7 @@ public class SystemProxyTest extends ItTest {
* Smoke test for using a proxy configured through system properties.
*/
@Test
public void test() throws URISyntaxException {
public void test() throws URISyntaxException, IOException {

final boolean[] authenticationCalled = { false };

Expand Down Expand Up @@ -52,12 +54,18 @@ protected PasswordAuthentication getPasswordAuthentication() {
request.setSource("USD");
request.setTarget("EUR");

GcDefaultConfiguration defaultConfiguration = getDefaultConfiguration();
defaultConfiguration.setProxyConfiguration(null);
GcDefaultConfiguration defaultConfiguration = getDefaultConfiguration()
.withProxyConfiguration(null);

ConvertAmount response = GcFactory.createClient(defaultConfiguration).merchant("9991").services().convertAmount(request);
GcClient client = GcFactory.createClient(defaultConfiguration);
try {
ConvertAmount response = client.merchant("9991").services().convertAmount(request);

Assert.assertNotNull(response.getConvertedAmount());
Assert.assertNotNull(response.getConvertedAmount());

} finally {
client.close();
}

// for https, authentication may not be required
if ("http".equalsIgnoreCase(defaultConfiguration.getBaseUri().getScheme())) {
Expand Down
19 changes: 12 additions & 7 deletions src/it/java/com/globalcollect/gateway/sdk/it/TokenTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.globalcollect.gateway.sdk.it;

import java.io.IOException;
import java.net.URISyntaxException;

import org.junit.Assert;
Expand All @@ -21,9 +22,7 @@ public class TokenTest extends ItTest {
* Smoke test for token calls.
*/
@Test
public void test() throws URISyntaxException {

GcClient gcClient = getGcClient();
public void test() throws URISyntaxException, IOException {

CreateTokenRequest createTokenRequest = new CreateTokenRequest();
createTokenRequest.setPaymentProductId(1);
Expand All @@ -43,12 +42,18 @@ public void test() throws URISyntaxException {
cardWithoutCvv.setCardNumber("4567350000427977");
cardWithoutCvv.setExpiryDate("0820");

CreateTokenResponse createTokenResponse = gcClient.merchant("9991").tokens().create(createTokenRequest);
GcClient client = getGcClient();
try {
CreateTokenResponse createTokenResponse = client.merchant("9991").tokens().create(createTokenRequest);

Assert.assertNotNull(createTokenResponse.getToken());

Assert.assertNotNull(createTokenResponse.getToken());
DeleteParams deleteTokenRequest = new DeleteParams();

DeleteParams deleteTokenRequest = new DeleteParams();
client.merchant("9991").tokens().delete(createTokenResponse.getToken(), deleteTokenRequest);

gcClient.merchant("9991").tokens().delete(createTokenResponse.getToken(), deleteTokenRequest);
} finally {
client.close();
}
}
}
Loading

0 comments on commit 740d1f3

Please sign in to comment.