Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
import java.util.List;

@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
Expand All @@ -26,6 +27,8 @@ public class HyperwalletPayment extends HyperwalletBaseMonitor {
private String destinationToken;
private String programToken;
private String clientPaymentId;
private Date expiresOn;
private List<HyperwalletLink> links;


public String getToken() {
Expand Down Expand Up @@ -279,4 +282,46 @@ public HyperwalletPayment clearProgramToken() {
this.programToken = null;
return this;
}

public Date getExpiresOn() {
return expiresOn;
}

public void setExpiresOn(Date expiresOn) {
addField("expiresOn", expiresOn);
this.expiresOn = expiresOn;
}

public HyperwalletPayment expiresOn(Date expiresOn) {
addField("expiresOn", expiresOn);
this.expiresOn = expiresOn;
return this;
}

public HyperwalletPayment clearExpiresOn() {
clearField("expiresOn");
this.expiresOn = null;
return this;
}

public List<HyperwalletLink> getLinks() {
return links;
}

public void setLinks(List<HyperwalletLink> links) {
addField("links", links);
this.links = links;
}

public HyperwalletPayment links(List<HyperwalletLink> links) {
addField("links", links);
this.links = links;
return this;
}

public HyperwalletPayment clearLinks() {
clearField("links");
this.links = null;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import com.fasterxml.jackson.annotation.JsonFilter;
import com.hyperwallet.clientsdk.util.HyperwalletJsonConfiguration;

import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
import java.util.List;

@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
Expand All @@ -30,6 +31,8 @@ public enum Status {
private Date createdOn;

private String notes;
private List<HyperwalletLink> links;


public String getToken() {
return token;
Expand Down Expand Up @@ -164,4 +167,25 @@ public HyperwalletStatusTransition clearNotes() {
this.notes = null;
return this;
}

public List<HyperwalletLink> getLinks() {
return links;
}

public void setLinks(List<HyperwalletLink> links) {
addField("links", links);
this.links = links;
}

public HyperwalletStatusTransition links(List<HyperwalletLink> links) {
addField("links", links);
this.links = links;
return this;
}

public HyperwalletStatusTransition clearLinks() {
clearField("links");
this.links = null;
return this;
}
}
53 changes: 48 additions & 5 deletions src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.*;

import static com.hyperwallet.clientsdk.model.HyperwalletStatusTransition.Status.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.mockserver.integration.ClientAndServer.startClientAndServer;
import static org.mockserver.model.Header.header;
import static org.mockserver.model.JsonBody.json;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;

public class HyperwalletIT {
Expand Down Expand Up @@ -1143,6 +1142,14 @@ public void testListPaymentStatusTransitions() throws Exception {
mockServer.verify(parseRequest(functionality));
throw e;
}
List<HyperwalletLink> hyperwalletLinks = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLink.setHref(
"https://uat-api.paylution.com/rest/v4/payments/pmt-2c059341-8281-4d30-a65d-a49d8e2a9b0f/status-transitions?offset=0&limit=10");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.hasNextPage(), is(equalTo(false)));
assertThat(returnValue.hasPreviousPage(), is(equalTo(false)));
Expand All @@ -1151,6 +1158,12 @@ public void testListPaymentStatusTransitions() throws Exception {
assertThat(returnValue.getData().get(1).getTransition(), is(equalTo(RECALLED)));
assertThat(returnValue.getData().get(1).getFromStatus(), is(equalTo(COMPLETED)));
assertThat(returnValue.getData().get(1).getToStatus(), is(equalTo(RECALLED)));
if (returnValue.getLinks() != null) {
HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams());
}
}

@Test
Expand All @@ -1165,18 +1178,33 @@ public void testCreatePaymentStatusTransition() throws Exception {
HyperwalletStatusTransition returnValue;
try {
returnValue = client.createPaymentStatusTransition("pmt-2c059341-8281-4d30-a65d-a49d8e2a9b0f",
transition);
transition);
} catch (Exception e) {
mockServer.verify(parseRequest(functionality));
throw e;
}
List<HyperwalletLink> hyperwalletLinks = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLink.setHref(
"https://api.sandbox.hyperwallet.com/rest/v4/payments/pmt-8716ee36-8b8f-4572-bf68-b9d1f956a3a2/status-transitions/sts-46592b6c-7d8b"
+ "-4e00-abf6-ca5a03880d31");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("sts-46592b6c-7d8b-4e00-abf6-ca5a03880d31")));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-12-21T11:35:43 UTC"))));
assertThat(returnValue.getTransition(), is(equalTo(CANCELLED)));
assertThat(returnValue.getFromStatus(), is(equalTo(SCHEDULED)));
assertThat(returnValue.getToStatus(), is(equalTo(CANCELLED)));
assertThat(returnValue.getNotes(), is(equalTo("Cancel a payment upon customer request.")));
if (returnValue.getLinks() != null) {
HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams());
}
}

@Test
Expand All @@ -1191,17 +1219,32 @@ public void testGetPaymentStatusTransition() throws Exception {
HyperwalletStatusTransition returnValue;
try {
returnValue = client.getPaymentStatusTransition("pmt-2c059341-8281-4d30-a65d-a49d8e2a9b0f",
"sts-1f7f58a9-22e8-4fef-8d6e-a17e2c71db33");
"sts-1f7f58a9-22e8-4fef-8d6e-a17e2c71db33");
} catch (Exception e) {
mockServer.verify(parseRequest(functionality));
throw e;
}
List<HyperwalletLink> hyperwalletLinks = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLink.setHref(
"https://uat-api.paylution.com/rest/v4/payments/pmt-2c059341-8281-4d30-a65d-a49d8e2a9b0f/status-transitions/sts-1f7f58a9-22e8-4fef"
+ "-8d6e-a17e2c71db33");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("sts-1f7f58a9-22e8-4fef-8d6e-a17e2c71db33")));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-11-16T02:04:17 UTC"))));
assertThat(returnValue.getTransition(), is(equalTo(COMPLETED)));
assertThat(returnValue.getFromStatus(), is(equalTo(CREATED)));
assertThat(returnValue.getToStatus(), is(equalTo(COMPLETED)));
if (returnValue.getLinks() != null) {
HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams());
}
}

//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.hyperwallet.clientsdk.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
* @author fkrauthan
*/
public class HyperwalletPaymentTest extends BaseModelTest<HyperwalletPayment> {
protected HyperwalletPayment createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
HyperwalletPayment payment = new HyperwalletPayment();
payment
.status("COMPLETED")
Expand All @@ -23,7 +28,9 @@ protected HyperwalletPayment createBaseModel() {

.destinationToken("test-destination-token")
.programToken("test-program-token")
.clientPaymentId("test-client-payment-id");
.clientPaymentId("test-client-payment-id")
.links(hyperwalletLinkList)
.expiresOn(new Date());
return payment;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
Expand All @@ -12,13 +14,17 @@
*/
public class HyperwalletStatusTransitionTest extends BaseModelTest<HyperwalletStatusTransition> {
protected HyperwalletStatusTransition createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
HyperwalletStatusTransition transition = new HyperwalletStatusTransition();
transition
.token("test-token")
.transition(HyperwalletStatusTransition.Status.ACTIVATED)
.fromStatus(HyperwalletStatusTransition.Status.LOCKED)
.toStatus(HyperwalletStatusTransition.Status.ACTIVATED)
.createdOn(new Date())
.links(hyperwalletLinkList)
.notes("test-notes");
return transition;
}
Expand Down