Skip to content
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
@@ -1,20 +1,19 @@
package com.hyperwallet.clientsdk.model;

import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
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;
import java.util.Map;

@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class
HyperwalletVerificationDocument {
public class HyperwalletVerificationDocument {

private String category;

Expand All @@ -24,8 +23,12 @@

private String country;

private List<HyperwalletVerificationDocumentReason> reasons;

public Map<String, String> uploadFiles;

private Date createdOn;

public String getCategory() {
return category;
}
Expand Down Expand Up @@ -90,4 +93,30 @@ public HyperwalletVerificationDocument uploadFiles(Map<String, String> uploadFil
setUploadFiles(uploadFiles);
return this;
}

public List<HyperwalletVerificationDocumentReason> getReasons() {
return reasons;
}

public void setReasons(List<HyperwalletVerificationDocumentReason> reasons) {
this.reasons = reasons;
}

public HyperwalletVerificationDocument reasons(List<HyperwalletVerificationDocumentReason> reasons) {
setReasons(reasons);
return this;
}

public Date getCreatedOn() {
return createdOn;
}

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

public HyperwalletVerificationDocument createdOn(Date createdOn) {
this.createdOn = createdOn;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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;

@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class HyperwalletVerificationDocumentReason {

private RejectReason name;
private String description;

public enum RejectReason {
DOCUMENT_EXPIRED,
DOCUMENT_NOT_RELATED_TO_PROFILE,
DOCUMENT_NOT_READABLE,
DOCUMENT_NOT_DECISIVE,
DOCUMENT_NOT_COMPLETE,
DOCUMENT_CORRECTION_REQUIRED,
DOCUMENT_NOT_VALID_WITH_NOTES,
DOCUMENT_TYPE_NOT_VALID;
}

public RejectReason getName() {
return name;
}

public void setName(RejectReason name) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}
}
88 changes: 81 additions & 7 deletions src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.hyperwallet.clientsdk.model.HyperwalletUser.Gender;
import com.hyperwallet.clientsdk.model.HyperwalletUser.GovernmentIdType;
import com.hyperwallet.clientsdk.model.HyperwalletUser.ProfileType;
import com.hyperwallet.clientsdk.model.HyperwalletVerificationDocumentReason.RejectReason;
import com.hyperwallet.clientsdk.util.Multipart;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.model.HttpRequest;
Expand All @@ -19,7 +20,6 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -85,14 +85,54 @@ public void testUploadUserDocuments() throws Exception {
mockServer.verify(parseRequest(functionality));
throw e;
}
HyperwalletVerificationDocument document =new HyperwalletVerificationDocument();
HyperwalletVerificationDocument document = new HyperwalletVerificationDocument();
assertThat(returnValue.getToken(), is(equalTo("usr-62f24150-5756-4234-9154-90ee4eed328b")));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletUser.Status.PRE_ACTIVATED)));
assertThat(returnValue.getVerificationStatus(), is(equalTo(HyperwalletUser.VerificationStatus.UNDER_REVIEW)));
assertThat(hyperwalletVerificationDocument.getCategory(), is(equalTo("IDENTIFICATION")));
assertThat(hyperwalletVerificationDocument.getType(), is(equalTo("DRIVERS_LICENSE")));
assertThat(hyperwalletVerificationDocument.getCountry(), is(equalTo("US")));
}

@Test
public void uploadUserDocuments_invalidDocumentStatus() throws Exception {
String functionality = "uploadUserDocumentsWithInvalidStatus";
initMockServer(functionality);

HyperwalletUser returnValue;
HyperwalletVerificationDocument hyperwalletVerificationDocument = new HyperwalletVerificationDocument();
try {
String userToken = "usr-62f24150-5756-4234-9154-90ee4eed328b";
Multipart multipart = new Multipart();
List<HyperwalletVerificationDocument> documentList = new ArrayList<>();
hyperwalletVerificationDocument.setType("DRIVERS_LICENSE");
hyperwalletVerificationDocument.setCategory("IDENTIFICATION");
hyperwalletVerificationDocument.setCountry("US");
Map<String, String> fileList = new HashMap<>();
fileList.put("drivers_license_front", "src/test/resources/integration/test.png");
fileList.put("drivers_license_back", "src/test/resources/integration/test.png");
hyperwalletVerificationDocument.setUploadFiles(fileList);
documentList.add(hyperwalletVerificationDocument);
returnValue = client.uploadUserDocuments(userToken, documentList);

} catch (Exception e) {
mockServer.verify(parseRequest(functionality));
throw e;
}
assertThat(returnValue.getToken(), is(equalTo("usr-62f24150-5756-4234-9154-90ee4eed328b")));
assertThat(returnValue.getStatus(), is(equalTo(HyperwalletUser.Status.PRE_ACTIVATED)));
assertThat(returnValue.getVerificationStatus(), is(equalTo(HyperwalletUser.VerificationStatus.UNDER_REVIEW)));
assertThat(returnValue.getDocuments().get(0).getCategory(), is(equalTo("IDENTIFICATION")));
assertThat(returnValue.getDocuments().get(0).getType(), is(equalTo("DRIVERS_LICENSE")));
assertThat(returnValue.getDocuments().get(0).getCountry(), is(equalTo("US")));
assertThat(returnValue.getDocuments().get(0).getStatus(), is("INVALID"));
assertThat(returnValue.getDocuments().get(0).getReasons().size(), is(2));
assertThat(returnValue.getDocuments().get(0).getReasons().get(0).getName(), is(RejectReason.DOCUMENT_CORRECTION_REQUIRED));
assertThat(returnValue.getDocuments().get(0).getReasons().get(0).getDescription(), is("Document requires correction"));
assertThat(returnValue.getDocuments().get(0).getReasons().get(1).getName(), is(RejectReason.DOCUMENT_NOT_DECISIVE));
assertThat(returnValue.getDocuments().get(0).getReasons().get(1).getDescription(),
is("Decision cannot be made based on document. Alternative document required"));
assertThat(returnValue.getDocuments().get(0).getCreatedOn(), is(dateFormat.parse("2020-11-24T19:05:02 UTC")));
}

@Test
Expand Down Expand Up @@ -635,10 +675,6 @@ public void testListBankAccount() throws Exception {
assertEquals(returnValue.getData().get(0).getPostalCode(),"12345");
}





@Test
public void testDeactivateBankCard() throws Exception {
String functionality = "deactivateBankCard";
Expand Down Expand Up @@ -3178,13 +3214,51 @@ public void testUploadStakeholderDocuments() throws Exception {
mockServer.verify(parseRequest(functionality));
throw e;
}
HyperwalletVerificationDocument document =new HyperwalletVerificationDocument();
HyperwalletVerificationDocument document = new HyperwalletVerificationDocument();
assertThat(returnValue.getToken(), is(equalTo("stk-e08f13b8-0e54-43d2-a587-67d513633275")));
assertThat(returnValue.getVerificationStatus(), is(equalTo(HyperwalletBusinessStakeholder.VerificationStatus.UNDER_REVIEW)));
assertThat(hyperwalletVerificationDocument.getCategory(), is(equalTo("IDENTIFICATION")));
assertThat(hyperwalletVerificationDocument.getType(), is(equalTo("DRIVERS_LICENSE")));
assertThat(hyperwalletVerificationDocument.getCountry(), is(equalTo("US")));
}

@Test
public void uploadStakeholderDocuments_invalidDocumentStatus() throws Exception {
String functionality = "uploadStakeholderDocumentsInvalidStatus";
initMockServer(functionality);

HyperwalletBusinessStakeholder returnValue;
HyperwalletVerificationDocument hyperwalletVerificationDocument = new HyperwalletVerificationDocument();
try {
String userToken = "usr-490848fb-8e1f-4f7c-9a18-a5b7a372e602";
String stkToken = "stk-e08f13b8-0e54-43d2-a587-67d513633275";
Multipart multipart = new Multipart();
List<HyperwalletVerificationDocument> documentList = new ArrayList<>();
hyperwalletVerificationDocument.setType("DRIVERS_LICENSE");
hyperwalletVerificationDocument.setCategory("IDENTIFICATION");
hyperwalletVerificationDocument.setCountry("US");
Map<String, String> fileList = new HashMap<>();
fileList.put("drivers_license_front", "src/test/resources/integration/test.png");
fileList.put("drivers_license_back", "src/test/resources/integration/test.png");
hyperwalletVerificationDocument.setUploadFiles(fileList);
documentList.add(hyperwalletVerificationDocument);
returnValue = client.uploadStakeholderDocuments(userToken, stkToken, documentList);
} catch (Exception e) {
mockServer.verify(parseRequest(functionality));
throw e;
}
assertThat(returnValue.getToken(), is(equalTo("stk-e08f13b8-0e54-43d2-a587-67d513633275")));
assertThat(returnValue.getVerificationStatus(), is(equalTo(HyperwalletBusinessStakeholder.VerificationStatus.UNDER_REVIEW)));
assertThat(returnValue.getDocuments().get(0).getCategory(), is(equalTo("IDENTIFICATION")));
assertThat(returnValue.getDocuments().get(0).getType(), is(equalTo("DRIVERS_LICENSE")));
assertThat(returnValue.getDocuments().get(0).getCountry(), is(equalTo("US")));
assertThat(returnValue.getDocuments().get(0).getReasons().size(), is(2));
assertThat(returnValue.getDocuments().get(0).getReasons().get(0).getName(), is(RejectReason.DOCUMENT_CORRECTION_REQUIRED));
assertThat(returnValue.getDocuments().get(0).getReasons().get(0).getDescription(), is("Document requires correction"));
assertThat(returnValue.getDocuments().get(0).getReasons().get(1).getName(), is(RejectReason.DOCUMENT_NOT_DECISIVE));
assertThat(returnValue.getDocuments().get(0).getReasons().get(1).getDescription(),
is("Decision cannot be made based on document. Alternative document required"));
assertThat(returnValue.getDocuments().get(0).getCreatedOn(), is(dateFormat.parse("2020-11-24T19:05:02 UTC")));
}

//
Expand Down
82 changes: 80 additions & 2 deletions src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.hyperwallet.clientsdk.model.HyperwalletUser.GovernmentIdType;
import com.hyperwallet.clientsdk.model.HyperwalletUser.LetterOfAuthorizationStatus;
import com.hyperwallet.clientsdk.model.HyperwalletUser.VerificationStatus;
import com.hyperwallet.clientsdk.model.HyperwalletVerificationDocumentReason.RejectReason;
import com.hyperwallet.clientsdk.util.HyperwalletApiClient;
import net.minidev.json.JSONObject;
import org.mockito.ArgumentCaptor;
Expand All @@ -24,6 +25,7 @@
import java.text.SimpleDateFormat;
import java.util.*;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.testng.Assert.fail;
Expand Down Expand Up @@ -293,6 +295,46 @@ public void testGetUser_successful() throws Exception {
Mockito.verify(mockApiClient).get("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token", userResponse.getClass());
}

@Test
public void getUser_withVerificationDocumentAndRejectReasons() throws Exception {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
HyperwalletUser hyperwalletUser = getHyperwalletUser();
final String url = "https://api.sandbox.hyperwallet.com/rest/v4/users/" + "test-userToken";
Mockito.when(mockApiClient.get(Mockito.eq(url), Mockito.eq(HyperwalletUser.class))).thenReturn(hyperwalletUser);

HyperwalletUser user = client.getUser("test-userToken");

Mockito.verify(mockApiClient).get(Mockito.eq(url), Mockito.eq(HyperwalletUser.class));
assertThat(user.getToken(), is(hyperwalletUser.getToken()));
assertThat(user.getDocuments().size(), is(1));
assertThat(user.getDocuments().get(0).getStatus(), is("INVALID"));
assertThat(user.getDocuments().get(0).getCreatedOn(), is(hyperwalletUser.getDocuments().get(0).getCreatedOn()));
assertThat(user.getDocuments().get(0).getReasons().size(), is(1));
assertThat(user.getDocuments().get(0).getReasons().get(0).getName(), is(RejectReason.DOCUMENT_EXPIRED));
assertThat(user.getDocuments().get(0).getReasons().get(0).getDescription(), is("Document has expired"));
}

private HyperwalletUser getHyperwalletUser() {
HyperwalletUser user = new HyperwalletUser();
user.token("test-userToken")
.verificationStatus(VerificationStatus.FAILED);
HyperwalletVerificationDocument hyperwalletVerificationDocument = new HyperwalletVerificationDocument();
hyperwalletVerificationDocument.setType("test_DRIVERS_LICENSE");
hyperwalletVerificationDocument.setCategory("test_IDENTIFICATION");
hyperwalletVerificationDocument.setCountry("test_US");
Map<String, String> fileList = new HashMap<>();
fileList.put("fileName", "fileData");
hyperwalletVerificationDocument.setStatus("INVALID");
hyperwalletVerificationDocument.setCreatedOn(new Date());
HyperwalletVerificationDocumentReason documentRejectReason = new HyperwalletVerificationDocumentReason();
documentRejectReason.setName(RejectReason.DOCUMENT_EXPIRED);
documentRejectReason.setDescription("Document has expired");
hyperwalletVerificationDocument.reasons(Arrays.asList(documentRejectReason));
user.documents(Arrays.asList(hyperwalletVerificationDocument));
return user;
}

@Test
public void testUpdateUser_noUser() {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
Expand Down Expand Up @@ -6998,10 +7040,47 @@ public void testListBusinessStakeholders_withUserTokenAndSomeOptions() throws Ex
assertThat(resp, is(equalTo(response)));

Mockito.verify(mockApiClient).get(Mockito.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/" + token
+ "/business-stakeholders?createdBefore=2016-06-29T17:58:26Z&limit=10"), Mockito.any(TypeReference.class));
+ "/business-stakeholders?createdBefore=2016-06-29T17:58:26Z&limit=10"), Mockito.any(TypeReference.class));

}

@Test
public void listBusinessStakeholders_withVerificationDocumentAndRejectReasons() throws Exception {
String token = "test-token";
HyperwalletBusinessStakeholder hyperwalletBusinessStakeholder = getHyperwalletBusinessStakeholder();
HyperwalletList<HyperwalletBusinessStakeholder> response = new HyperwalletList<>();
response.setData(Arrays.asList(hyperwalletBusinessStakeholder));

Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
final String url = "https://api.sandbox.hyperwallet.com/rest/v4/users/" + token + "/business-stakeholders";
Mockito.when(mockApiClient.get(Mockito.eq(url), Mockito.any(TypeReference.class))).thenReturn(response);

HyperwalletList<HyperwalletBusinessStakeholder> resp = client.listBusinessStakeholders(token);

Mockito.verify(mockApiClient).get(Mockito.eq(url), Mockito.any(TypeReference.class));
assertThat(resp.getData().size(), is(1));
assertThat(resp.getData().get(0).getToken(), is(hyperwalletBusinessStakeholder.getToken()));
assertThat(resp.getData().get(0).getDocuments().size(), is(1));
assertThat(resp.getData().get(0).getDocuments().get(0).getReasons().get(0).getName(), is(RejectReason.DOCUMENT_EXPIRED));
assertThat(resp.getData().get(0).getDocuments().get(0).getReasons().get(0).getDescription(), is("Document has expired"));
assertThat(resp.getData().get(0).getDocuments().get(0).getCreatedOn(),
is(hyperwalletBusinessStakeholder.getDocuments().get(0).getCreatedOn()));
}

private HyperwalletBusinessStakeholder getHyperwalletBusinessStakeholder() {
HyperwalletBusinessStakeholder businessStakeholder = new HyperwalletBusinessStakeholder();
HyperwalletVerificationDocument hyperwalletVerificationDocument = new HyperwalletVerificationDocument();
HyperwalletVerificationDocumentReason reason = new HyperwalletVerificationDocumentReason();
reason.setName(RejectReason.DOCUMENT_EXPIRED);
reason.setDescription("Document has expired");
hyperwalletVerificationDocument.setReasons(Arrays.asList(reason));
hyperwalletVerificationDocument.setCreatedOn(new Date());
businessStakeholder.token("test-stakeholderToken")
.documents(Arrays.asList(hyperwalletVerificationDocument));
return businessStakeholder;
}


@Test
public void testCreateBusinessStakeholderStatusTransition_noTransition() {
Expand Down Expand Up @@ -8160,7 +8239,6 @@ public void testUploadUserDocument_Error() throws Exception {
}
}


@Test
public void testUploadStakeholderDocuments_noUserToken() {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
curl -X "PUT" "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-490848fb-8e1f-4f7c-9a18-a5b7a372e602/business-stakeholders/stk-e08f13b8-0e54-43d2-a587-67d513633275" \
-u testuser@12345678:myAccPassw0rd \
Loading