Skip to content

Commit

Permalink
Merge pull request #83 from hyperwallet/feature/HW-66747-V4Java-Program
Browse files Browse the repository at this point in the history
Feature/hw 66747 v4 java program
  • Loading branch information
akalichety-hw committed Sep 11, 2020
2 parents e5b58f7 + 801e2b2 commit ac57a04
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 3 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 @@ -857,6 +857,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 @@ -1016,7 +1017,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;
}
}

36 changes: 36 additions & 0 deletions src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,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 ac57a04

Please sign in to comment.