Skip to content

Commit

Permalink
Merge 4d298cf into 7ee9746
Browse files Browse the repository at this point in the history
  • Loading branch information
ramahalingam committed Sep 7, 2020
2 parents 7ee9746 + 4d298cf commit 79d5b08
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 44 deletions.
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,7 @@ public enum Status {
private Date createdOn;

private String notes;
private List<HyperwalletLink> links;

public String getToken() {
return token;
Expand Down Expand Up @@ -164,4 +166,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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import com.fasterxml.jackson.annotation.JsonFilter;
import com.hyperwallet.clientsdk.util.HyperwalletJsonConfiguration;

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

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 @@ -33,6 +32,7 @@ public static enum Status {QUOTED, SCHEDULED, IN_PROGRESS, VERIFICATION_REQUIRED
private String notes;
private String memo;
private Date expiresOn;
private List<HyperwalletLink> links;

public String getToken() {
return token;
Expand Down Expand Up @@ -370,7 +370,29 @@ public HyperwalletTransfer clearForeignExchanges() {
return this;
}

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

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

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

public HyperwalletTransfer clearLinks() {
clearField("links");
this.links = null;
return this;
}

public static class ForeignExchange {

private Double sourceAmount;
private String sourceCurrency;
private Double destinationAmount;
Expand Down
145 changes: 112 additions & 33 deletions src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hyperwallet.clientsdk;

import com.hyperwallet.clientsdk.model.*;
import com.hyperwallet.clientsdk.model.HyperwalletTransfer.ForeignExchange;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;
Expand All @@ -13,9 +14,7 @@
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;
Expand Down Expand Up @@ -628,6 +627,16 @@ public void testCreateTransfer() throws Exception {
throw e;
}

List<HyperwalletLink> hyperwalletLinks = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLink.setHref(
"https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939de/paper-checks/trm-59f67c62-fd06-497e"
+ "-a9ea-99d6eb38b12b");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b")));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletTransfer.Status.QUOTED)));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
Expand All @@ -643,11 +652,21 @@ public void testCreateTransfer() throws Exception {
assertThat(returnValue.getNotes(), is(equalTo("notes")));
assertThat(returnValue.getMemo(), is(equalTo("memo")));
assertThat(returnValue.getExpiresOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
assertThat(returnValue.getForeignExchanges().get(0).getSourceAmount(), is(equalTo(100.00)));
assertThat(returnValue.getForeignExchanges().get(0).getSourceCurrency(), is(equalTo("USD")));
assertThat(returnValue.getForeignExchanges().get(0).getDestinationAmount(), is(equalTo(63.49)));
assertThat(returnValue.getForeignExchanges().get(0).getDestinationCurrency(), is(equalTo("USD")));
assertThat(returnValue.getForeignExchanges().get(0).getRate(), is(equalTo(0.79)));

ForeignExchange foreignExchange = returnValue.getForeignExchanges().get(0);
assertThat(foreignExchange.getSourceAmount(), is(equalTo(100.00)));
assertThat(foreignExchange.getSourceCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getDestinationAmount(), is(equalTo(63.49)));
assertThat(foreignExchange.getDestinationCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getRate(), is(equalTo(0.79)));

if (returnValue.getLinks() != null) {
HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = returnValue.getLinks().get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertThat(actualHyperwalletLink.getParams().keySet(), is(equalTo(expectedHyperwalletLink.getParams().keySet())));
assertThat(actualHyperwalletLink.getParams().values(), is(equalTo(expectedHyperwalletLink.getParams().values())));
}
}

@Test
Expand All @@ -663,6 +682,16 @@ public void testGetTransfer() throws Exception {
throw e;
}

List<HyperwalletLink> hyperwalletLinks = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLink.setHref(
"https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939de/paper-checks/trm-59f67c62-fd06-497e"
+ "-a9ea-99d6eb38b12b");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b")));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletTransfer.Status.QUOTED)));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
Expand All @@ -678,11 +707,21 @@ public void testGetTransfer() throws Exception {
assertThat(returnValue.getNotes(), is(equalTo("notes")));
assertThat(returnValue.getMemo(), is(equalTo("memo")));
assertThat(returnValue.getExpiresOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
assertThat(returnValue.getForeignExchanges().get(0).getSourceAmount(), is(equalTo(100.00)));
assertThat(returnValue.getForeignExchanges().get(0).getSourceCurrency(), is(equalTo("USD")));
assertThat(returnValue.getForeignExchanges().get(0).getDestinationAmount(), is(equalTo(63.49)));
assertThat(returnValue.getForeignExchanges().get(0).getDestinationCurrency(), is(equalTo("USD")));
assertThat(returnValue.getForeignExchanges().get(0).getRate(), is(equalTo(0.79)));

ForeignExchange foreignExchange = returnValue.getForeignExchanges().get(0);
assertThat(foreignExchange.getSourceAmount(), is(equalTo(100.00)));
assertThat(foreignExchange.getSourceCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getDestinationAmount(), is(equalTo(63.49)));
assertThat(foreignExchange.getDestinationCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getRate(), is(equalTo(0.79)));

if (returnValue.getLinks() != null) {
HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = returnValue.getLinks().get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertThat(actualHyperwalletLink.getParams().keySet(), is(equalTo(expectedHyperwalletLink.getParams().keySet())));
assertThat(actualHyperwalletLink.getParams().values(), is(equalTo(expectedHyperwalletLink.getParams().values())));
}
}

@Test
Expand All @@ -698,28 +737,50 @@ public void testListTransfer() throws Exception {
throw e;
}

List<HyperwalletLink> hyperwalletLinks = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLink.setHref(
"https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939de/paper-checks/trm-59f67c62-fd06-497e"
+ "-a9ea-99d6eb38b12b");
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)));
assertThat(returnValue.getData().get(0).getToken(), is(equalTo("trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b")));
assertThat(returnValue.getData().get(0).getStatus(), is(equalTo(HyperwalletTransfer.Status.QUOTED)));
assertThat(returnValue.getData().get(0).getCreatedOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
assertThat(returnValue.getData().get(0).getClientTransferId(), is(equalTo("clientTransferId")));
assertThat(returnValue.getData().get(0).getSourceToken(), is(equalTo("usr-c4292f1a-866f-4310-a289-b916853939de")));
assertThat(returnValue.getData().get(0).getSourceAmount(), is(equalTo(200.4)));
assertThat(returnValue.getData().get(0).getSourceFeeAmount(), is(equalTo(20.3)));
assertThat(returnValue.getData().get(0).getSourceCurrency(), is(equalTo("USD")));
assertThat(returnValue.getData().get(0).getDestinationToken(), is(equalTo("usr-c4292f1a-866f-4310-a289-b916853939de")));
assertThat(returnValue.getData().get(0).getDestinationAmount(), is(equalTo(100.2)));
assertThat(returnValue.getData().get(0).getDestinationFeeAmount(), is(equalTo(30.5)));
assertThat(returnValue.getData().get(0).getDestinationCurrency(), is(equalTo("USD")));
assertThat(returnValue.getData().get(0).getNotes(), is(equalTo("notes")));
assertThat(returnValue.getData().get(0).getMemo(), is(equalTo("memo")));
assertThat(returnValue.getData().get(0).getExpiresOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
assertThat(returnValue.getData().get(0).getForeignExchanges().get(0).getSourceAmount(), is(equalTo(100.00)));
assertThat(returnValue.getData().get(0).getForeignExchanges().get(0).getSourceCurrency(), is(equalTo("USD")));
assertThat(returnValue.getData().get(0).getForeignExchanges().get(0).getDestinationAmount(), is(equalTo(63.49)));
assertThat(returnValue.getData().get(0).getForeignExchanges().get(0).getDestinationCurrency(), is(equalTo("USD")));
assertThat(returnValue.getData().get(0).getForeignExchanges().get(0).getRate(), is(equalTo(0.79)));

HyperwalletTransfer hyperwalletTransfer = returnValue.getData().get(0);
assertThat(hyperwalletTransfer.getToken(), is(equalTo("trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b")));
assertThat(hyperwalletTransfer.getStatus(), is(equalTo(HyperwalletTransfer.Status.QUOTED)));
assertThat(hyperwalletTransfer.getCreatedOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));
assertThat(hyperwalletTransfer.getClientTransferId(), is(equalTo("clientTransferId")));
assertThat(hyperwalletTransfer.getSourceToken(), is(equalTo("usr-c4292f1a-866f-4310-a289-b916853939de")));
assertThat(hyperwalletTransfer.getSourceAmount(), is(equalTo(200.4)));
assertThat(hyperwalletTransfer.getSourceFeeAmount(), is(equalTo(20.3)));
assertThat(hyperwalletTransfer.getSourceCurrency(), is(equalTo("USD")));
assertThat(hyperwalletTransfer.getDestinationToken(), is(equalTo("usr-c4292f1a-866f-4310-a289-b916853939de")));
assertThat(hyperwalletTransfer.getDestinationAmount(), is(equalTo(100.2)));
assertThat(hyperwalletTransfer.getDestinationFeeAmount(), is(equalTo(30.5)));
assertThat(hyperwalletTransfer.getDestinationCurrency(), is(equalTo("USD")));
assertThat(hyperwalletTransfer.getNotes(), is(equalTo("notes")));
assertThat(hyperwalletTransfer.getMemo(), is(equalTo("memo")));
assertThat(hyperwalletTransfer.getExpiresOn(), is(equalTo(dateFormat.parse("2017-10-31T22:32:57 UTC"))));

ForeignExchange foreignExchange = hyperwalletTransfer.getForeignExchanges().get(0);
assertThat(foreignExchange.getSourceAmount(), is(equalTo(100.00)));
assertThat(foreignExchange.getSourceCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getDestinationAmount(), is(equalTo(63.49)));
assertThat(foreignExchange.getDestinationCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getRate(), is(equalTo(0.79)));

if (returnValue.getLinks() != null) {
HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = returnValue.getLinks().get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertThat(actualHyperwalletLink.getParams().keySet(), is(equalTo(expectedHyperwalletLink.getParams().keySet())));
assertThat(actualHyperwalletLink.getParams().values(), is(equalTo(expectedHyperwalletLink.getParams().values())));
}
}

@Test
Expand All @@ -739,12 +800,30 @@ public void testCreateTransferStatusTransition() throws Exception {
throw e;
}

List<HyperwalletLink> hyperwalletLinks = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLink.setHref(
"https://api.sandbox.hyperwallet.com/rest/v4/users/usr-1dea80c9-c73e-4490-91b7-097d4a07550f/paper-checks/trm-9e2e1a06-a33b-4c2f"
+ "-9933-893ae21db442/status-transitions/sts-ed2207f0-39cc-493f-9cd0-24998de0c0f7");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("sts-ed2207f0-39cc-493f-9cd0-24998de0c0f7")));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-10-30T19:50:49 UTC"))));
assertThat(returnValue.getTransition(), is(equalTo(SCHEDULED)));
assertThat(returnValue.getFromStatus(), is(equalTo(QUOTED)));
assertThat(returnValue.getToStatus(), is(equalTo(SCHEDULED)));
assertThat(returnValue.getNotes(), is(equalTo("Closing check.")));

if (returnValue.getLinks() != null) {
HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = returnValue.getLinks().get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertThat(actualHyperwalletLink.getParams().keySet(), is(equalTo(expectedHyperwalletLink.getParams().keySet())));
assertThat(actualHyperwalletLink.getParams().values(), is(equalTo(expectedHyperwalletLink.getParams().values())));
}
}

//
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 @@ -13,13 +15,17 @@
public class HyperwalletStatusTransitionTest extends BaseModelTest<HyperwalletStatusTransition> {
protected HyperwalletStatusTransition createBaseModel() {
HyperwalletStatusTransition transition = new HyperwalletStatusTransition();
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
transition
.token("test-token")
.transition(HyperwalletStatusTransition.Status.ACTIVATED)
.fromStatus(HyperwalletStatusTransition.Status.LOCKED)
.toStatus(HyperwalletStatusTransition.Status.ACTIVATED)
.createdOn(new Date())
.notes("test-notes");
.notes("test-notes")
.links(hyperwalletLinkList);
return transition;
}

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

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

public class HyperwalletTransferTest extends BaseModelTest<HyperwalletTransfer> {
protected HyperwalletTransfer createBaseModel() {
Expand All @@ -12,6 +14,9 @@ protected HyperwalletTransfer createBaseModel() {
foreignExchange.setDestinationAmount(100.0);
foreignExchange.setDestinationCurrency("USD");
foreignExchange.setRate(2.3);
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
transfer
.token("test-token")
.status(HyperwalletTransfer.Status.QUOTED)
Expand All @@ -27,7 +32,8 @@ protected HyperwalletTransfer createBaseModel() {
.destinationCurrency("USD")
.notes("notes")
.memo("memo")
.expiresOn(new Date());
.expiresOn(new Date())
.links(hyperwalletLinkList);
transfer.setForeignExchanges(Collections.singletonList(foreignExchange));
return transfer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939de/paper-checks/trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b"
"href": "https://api.sandbox.hyperwallet.com/rest/v4/transfers/trf-59f67c62-fd06-497e-a9ea-99d6eb38b12b"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-1dea80c9-c73e-4490-91b7-097d4a07550f/paper-checks/trm-9e2e1a06-a33b-4c2f-9933-893ae21db442/status-transitions/sts-ed2207f0-39cc-493f-9cd0-24998de0c0f7"
"href": "https://api.sandbox.hyperwallet.com/rest/v4/transfers/trr-9e2e1a06-a33b-4c2f-9933-893ae21db442/status-transitions/sts-ed2207f0-39cc-493f-9cd0-24998de0c0f7"
}
]
}
2 changes: 1 addition & 1 deletion src/test/resources/integration/getTransfer-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939de/paper-checks/trm-59f67c62-fd06-497e-a9ea-99d6eb38b12b"
"href": "https://api.sandbox.hyperwallet.com/rest/v4/transfers/trf-59f67c62-fd06-497e-a9ea-99d6eb38b12b"
}
]
}

0 comments on commit 79d5b08

Please sign in to comment.