Skip to content

Commit

Permalink
HW-66697-BankCards-ProcessingTime filed is missing in Response.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkurra-hw committed Sep 8, 2020
1 parent 7ee9746 commit 365f487
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import com.fasterxml.jackson.annotation.JsonFormat;
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 @@ -33,6 +34,8 @@ public enum CardType {DEBIT}
private String cvv;

private String userToken;
private String processingTime;
private List<HyperwalletLink> links;

public HyperwalletTransferMethod.Type getType() {
return type;
Expand Down Expand Up @@ -286,4 +289,46 @@ public HyperwalletBankCard clearUserToken() {
this.userToken = null;
return this;
}

public String getProcessingTime() {
return processingTime;
}

public void setProcessingTime(String processingTime) {
addField("processingTime", processingTime);
this.processingTime = processingTime;
}

public HyperwalletBankCard processingTime(String processingTime) {
addField("processingTime", processingTime);
this.processingTime = processingTime;
return this;
}

public HyperwalletBankCard clearProcessingTime() {
clearField("processingTime");
this.processingTime = null;
return this;
}

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

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

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

public HyperwalletBankCard clearLinks() {
clearField("links");
this.links = null;
return this;
}
}
74 changes: 66 additions & 8 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 @@ -147,8 +146,8 @@ public void testCreateBankCard() throws Exception {
.cardNumber("4216701111100114")
.dateOfExpiry(dateFormat.parse("2018-01-01T00:00:00 UTC"))
.cvv("123")
.transferMethodCountry("US")
.transferMethodCurrency("USD");
.transferMethodCountry("US")
.transferMethodCurrency("USD");

HyperwalletBankCard returnValue;
try {
Expand All @@ -157,6 +156,15 @@ public void testCreateBankCard() throws Exception {
mockServer.verify(parseRequest(functionality));
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/bank-cards/trm-7e915660-8c97-47bf-8a4f"
+ "-0c1bc890d46f");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("trm-7e915660-8c97-47bf-8a4f-0c1bc890d46f")));
assertThat(returnValue.getType(), is(equalTo(HyperwalletTransferMethod.Type.BANK_CARD)));
Expand All @@ -169,6 +177,12 @@ public void testCreateBankCard() throws Exception {
assertThat(returnValue.getCardBrand(), is(equalTo(HyperwalletBankCard.Brand.VISA)));
assertThat(returnValue.getDateOfExpiry(), is(equalTo(dateFormat.parse("2018-01-01T00:00:00 UTC"))));
assertThat(returnValue.getCvv(), is(nullValue()));
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 @@ -179,8 +193,8 @@ public void testUpdateBankCard() throws Exception {
HyperwalletBankCard bankCard = new HyperwalletBankCard()
.userToken("usr-c4292f1a-866f-4310-a289-b916853939de")
.token("trm-7e915660-8c97-47bf-8a4f-0c1bc890d46f")
.dateOfExpiry(dateFormat.parse("2018-11-01T00:00:00 UTC"))
.cvv("123");
.dateOfExpiry(dateFormat.parse("2018-11-01T00:00:00 UTC"))
.cvv("123");

HyperwalletBankCard returnValue;
try {
Expand All @@ -189,6 +203,15 @@ public void testUpdateBankCard() throws Exception {
mockServer.verify(parseRequest(functionality));
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/bank-cards/trm-7e915660-8c97-47bf-8a4f"
+ "-0c1bc890d46f");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("trm-7e915660-8c97-47bf-8a4f-0c1bc890d46f")));
assertThat(returnValue.getType(), is(equalTo(HyperwalletTransferMethod.Type.BANK_CARD)));
Expand All @@ -201,6 +224,12 @@ public void testUpdateBankCard() throws Exception {
assertThat(returnValue.getCardBrand(), is(equalTo(HyperwalletBankCard.Brand.VISA)));
assertThat(returnValue.getDateOfExpiry(), is(equalTo(dateFormat.parse("2018-11-01T00:00:00 UTC"))));
assertThat(returnValue.getCvv(), is(nullValue()));
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 @@ -211,11 +240,20 @@ public void testGetBankCard() throws Exception {
HyperwalletBankCard returnValue;
try {
returnValue = client.getBankCard("usr-c4292f1a-866f-4310-a289-b916853939de",
"trm-7e915660-8c97-47bf-8a4f-0c1bc890d46f");
"trm-7e915660-8c97-47bf-8a4f-0c1bc890d46f");
} 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/users/usr-c4292f1a-866f-4310-a289-b916853939de/bank-cards/trm-7e915660-8c97-47bf-8a4f"
+ "-0c1bc890d46f");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("trm-7e915660-8c97-47bf-8a4f-0c1bc890d46f")));
assertThat(returnValue.getType(), is(equalTo(HyperwalletTransferMethod.Type.BANK_CARD)));
Expand All @@ -228,6 +266,12 @@ public void testGetBankCard() throws Exception {
assertThat(returnValue.getCardBrand(), is(equalTo(HyperwalletBankCard.Brand.VISA)));
assertThat(returnValue.getDateOfExpiry(), is(equalTo(dateFormat.parse("2018-12-01T00:00:00 UTC"))));
assertThat(returnValue.getCvv(), is(nullValue()));
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 @@ -242,6 +286,14 @@ public void testListBankCard() throws Exception {
mockServer.verify(parseRequest(functionality));
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/bank-cards?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 @@ -256,6 +308,12 @@ public void testListBankCard() throws Exception {
assertThat(returnValue.getData().get(0).getCardBrand(), is(equalTo(HyperwalletBankCard.Brand.VISA)));
assertThat(returnValue.getData().get(0).getDateOfExpiry(), is(equalTo(dateFormat.parse("2018-11-01T00:00:00 UTC"))));
assertThat(returnValue.getData().get(0).getCvv(), is(nullValue()));
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 Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.hyperwallet.clientsdk.model;

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

public class HyperwalletBankCardTest extends BaseModelTest<HyperwalletBankCard> {
protected HyperwalletBankCard createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
HyperwalletBankCard bankCard = new HyperwalletBankCard();
bankCard
.token("test-token")
Expand All @@ -20,6 +25,8 @@ protected HyperwalletBankCard createBaseModel() {

.dateOfExpiry(new Date())
.cvv("cvv")
.processingTime("processing-time")
.links(hyperwalletLinkList)
.userToken("test-user-token");
return bankCard;
}
Expand Down

0 comments on commit 365f487

Please sign in to comment.