Skip to content

Commit

Permalink
Merge 801e2b2 into 7ee9746
Browse files Browse the repository at this point in the history
  • Loading branch information
Ssangaran committed Sep 9, 2020
2 parents 7ee9746 + 801e2b2 commit 60841e7
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,7 @@ public HyperwalletStatusTransition deactivatePaperCheck(String userToken, String
*
* @param userToken User token
* @param paperCheckToken Paper Check token
* @param notes user notes
* @return The status transition
*/
public HyperwalletStatusTransition deactivatePaperCheck(String userToken, String paperCheckToken, String notes) {
Expand Down Expand Up @@ -996,7 +997,8 @@ public HyperwalletList<HyperwalletTransfer> listTransfers() {
/**
* Create Transfer Status Transition
*
* @param transferToken Transfer token assigned
* @param transferToken Transfer token assigned
* @param transition transition value
* @return HyperwalletStatusTransition new status for Transfer Request
*/
public HyperwalletStatusTransition createTransferStatusTransition(String transferToken, HyperwalletStatusTransition transition) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,70 +1,129 @@
package com.hyperwallet.clientsdk.model;


import com.fasterxml.jackson.annotation.JsonFilter;
import com.hyperwallet.clientsdk.util.HyperwalletJsonConfiguration;

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
@XmlAccessorType(XmlAccessType.FIELD)
public class HyperwalletProgram {
public class HyperwalletProgram extends HyperwalletBaseMonitor{

private String token;
private Date createdOn;
private String name;
private String parentToken;
private List<HyperwalletLink> links;

public String getToken() {
return token;
}

public void setToken(String token) {
addField("token", token);
this.token = token;
}

public HyperwalletProgram token(String token) {
addField("token", token);
this.token = token;
return this;
}

public HyperwalletProgram clearToken() {
clearField("token");
this.token = null;
return this;
}

public Date getCreatedOn() {
return createdOn;
}

public void setCreatedOn(Date createdOn) {
addField("createdOn", createdOn);
this.createdOn = createdOn;
}

public HyperwalletProgram createdOn(Date createdOn) {
addField("createdOn", createdOn);
this.createdOn = createdOn;
return this;
}

public HyperwalletProgram clearCreatedOn() {
clearField("createdOn");
this.createdOn = null;
return this;
}

public String getName() {
return name;
}

public void setName(String name) {
addField("name", name);
this.name = name;
}

public HyperwalletProgram name(String name) {
addField("name", name);
this.name = name;
return this;
}

public HyperwalletProgram clearName() {
clearField("name");
this.name = null;
return this;
}

public String getParentToken() {
return parentToken;
}

public void setParentToken(String parentToken) {
addField("parentToken", parentToken);
this.parentToken = parentToken;
}

public HyperwalletProgram parentToken(String parentToken) {
addField("parentToken", parentToken);
this.parentToken = parentToken;
return this;
}

public HyperwalletProgram clearParentToken() {
clearField("parentToken");
this.parentToken = null;
return this;
}

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

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

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

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

41 changes: 38 additions & 3 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 @@ -1248,6 +1247,42 @@ public void testCreateBankCardWithErrorResponse() throws Exception {
}
}

//
// Programs
//
@Test
public void testGetProgram() throws Exception {
String functionality = "getProgram";
initMockServer(functionality);

HyperwalletProgram returnValue;
try {
returnValue = client.getProgram("prg-83836cdf-2ce2-4696-8bc5-f1b86077238c");
} 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/programs/prg-83836cdf-2ce2-4696-8bc5-f1b86077238c");
Map<String, String> mapParams = new HashMap<>();
mapParams.put("rel", "self");
hyperwalletLink.setParams(mapParams);
hyperwalletLinks.add(hyperwalletLink);

assertThat(returnValue.getToken(), is(equalTo("prg-83836cdf-2ce2-4696-8bc5-f1b86077238c")));
assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2017-10-04T21:19:24 UTC"))));
assertThat(returnValue.getName(), is(equalTo("Hyperwallet - Portal")));
assertThat(returnValue.getParentToken(), is(equalTo("prg-a4b617e2-24c9-4891-9ee5-741489613f73")));

HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0);
HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0);
assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref())));
assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams());
}


private void initMockServerWithErrorResponse(String functionality) throws IOException {
mockServer.reset();
mockServer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package com.hyperwallet.clientsdk.model;

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

/**
* @author fkrauthan
*/
public class HyperwalletProgramTest extends BaseModelTest<HyperwalletProgram> {
protected HyperwalletProgram createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
HyperwalletProgram program = new HyperwalletProgram();
program
.token("test-token")
.createdOn(new Date())
.name("test-name")
.parentToken("test-parent-token");
.parentToken("test-parent-token")
.links(hyperwalletLinkList);
return program;
}

Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/integration/getProgram-request.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
curl -X "GET" "https://api.sandbox.hyperwallet.com/rest/v4/programs/prg-83836cdf-2ce2-4696-8bc5-f1b86077238c" \
-u testuser@12345678:myAccPassw0rd \
-H "Accept: application/json"
14 changes: 14 additions & 0 deletions src/test/resources/integration/getProgram-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"token": "prg-83836cdf-2ce2-4696-8bc5-f1b86077238c",
"createdOn": "2017-10-04T21:19:24",
"name": "Hyperwallet - Portal",
"parentToken": "prg-a4b617e2-24c9-4891-9ee5-741489613f73",
"links": [
{
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v4/programs/prg-83836cdf-2ce2-4696-8bc5-f1b86077238c"
}
]
}

0 comments on commit 60841e7

Please sign in to comment.