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
9 changes: 8 additions & 1 deletion src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,15 @@ public HyperwalletList<HyperwalletUser> listUsers() {
* @param options List filter option
* @return HyperwalletList of HyperwalletUser
*/
public HyperwalletList<HyperwalletUser> listUsers(HyperwalletPaginationOptions options) {
public HyperwalletList<HyperwalletUser> listUsers(HyperwalletUsersListPaginationOptions options) {
String url = paginate(this.url + "/users", options);
if (options != null) {
url = addParameter(url, "clientUserId", options.getClientUserId());
url = addParameter(url, "email", options.getEmail());
url = addParameter(url, "programToken", options.getProgramToken());
url = addParameter(url, "status", options.getStatus());
url = addParameter(url, "verificationStatus", options.getVerificationStatus());
}
return apiClient.get(url, new TypeReference<HyperwalletList<HyperwalletUser>>() {
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.hyperwallet.clientsdk.model;

public class HyperwalletUsersListPaginationOptions extends HyperwalletPaginationOptions{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: is your formatter turned on? there should be a space between HyperwalletPaginationOptions and {


private String clientUserId;
private String email;
private String programToken;
private HyperwalletUser.Status status;
private HyperwalletUser.VerificationStatus verificationStatus;

public String getClientUserId() {
return clientUserId;
}

public void setClientUserId(String clientUserId) {
this.clientUserId = clientUserId;
}

public HyperwalletUsersListPaginationOptions clientUserId(String clientUserId) {
this.clientUserId = clientUserId;
return this;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public HyperwalletUsersListPaginationOptions email(String email) {
this.email = email;
return this;
}

public String getProgramToken() {
return programToken;
}

public void setProgramToken(String programToken) {
this.programToken = programToken;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: redundant newLine


public HyperwalletUsersListPaginationOptions programToken(String programToken) {
this.programToken = programToken;
return this;
}

public HyperwalletUser.Status getStatus() {
return status;
}

public void setStatus(HyperwalletUser.Status status) {
this.status = status;
}

public HyperwalletUsersListPaginationOptions status(HyperwalletUser.Status status) {
this.status = status;
return this;
}
public HyperwalletUser.VerificationStatus getVerificationStatus() {
return verificationStatus;
}

public void setVerificationStatus(HyperwalletUser.VerificationStatus verificationStatus) {
this.verificationStatus = verificationStatus;
}

public HyperwalletUsersListPaginationOptions verificationStatus(HyperwalletUser.VerificationStatus verificationStatus) {
this.verificationStatus = verificationStatus;
return this;
}



}
54 changes: 54 additions & 0 deletions src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,60 @@ public void testListUserStatusTransitions() throws Exception {
assertThat(returnValue.getData().get(0).getToStatus(), is(equalTo(DE_ACTIVATED)));
}

@Test
public void testListUsers_withNoParameters() throws Exception {
String functionality = "listUsers";
initMockServer(functionality);

HyperwalletList<HyperwalletUser> returnValue;
try {
returnValue = client.listUsers();
} catch (Exception e) {
mockServer.verify(parseRequest(functionality));
throw e;
}
assertThat(returnValue.getCount(), is(equalTo(2)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls add assert statement for the 2nd index as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

HyperwalletUser userOne = returnValue.getData().get(0);
assertThat(userOne.getToken(), is(equalTo("usr-00c6cfda-a43d-4b29-a20b-1abc7e800b58")));
assertThat(userOne.getCreatedOn(), is(equalTo(dateFormat.parse("2019-10-30T22:15:35 UTC"))));
assertThat(userOne.getStatus(), is(equalTo(HyperwalletUser.Status.PRE_ACTIVATED)));
assertThat(userOne.getVerificationStatus(), is(equalTo(HyperwalletUser.VerificationStatus.NOT_REQUIRED)));
HyperwalletUser userTwo = returnValue.getData().get(1);
assertThat(userTwo.getToken(), is(equalTo("usr-f9154016-94e8-4686-a840-075688ac07b5")));
assertThat(userTwo.getCreatedOn(), is(equalTo(dateFormat.parse("2019-10-30T22:15:45 UTC"))));
assertThat(userTwo.getStatus(), is(equalTo(HyperwalletUser.Status.PRE_ACTIVATED)));
assertThat(userTwo.getVerificationStatus(), is(equalTo(HyperwalletUser.VerificationStatus.REQUIRED)));
}

@Test
public void testListUsers_withParameters() throws Exception {
String functionality = "listUsers";
initMockServer(functionality);

HyperwalletList<HyperwalletUser> returnValue;
try {
HyperwalletUsersListPaginationOptions options = new HyperwalletUsersListPaginationOptions();
options.limit(2);
//options.clientUserId("CSLAJQt7bD");
returnValue = client.listUsers(options);
} catch (Exception e) {
mockServer.verify(parseRequest(functionality));
throw e;
}
assertThat(returnValue.getCount(), is(equalTo(2)));
HyperwalletUser userOne = returnValue.getData().get(0);
assertThat(userOne.getToken(), is(equalTo("usr-00c6cfda-a43d-4b29-a20b-1abc7e800b58")));
assertThat(userOne.getCreatedOn(), is(equalTo(dateFormat.parse("2019-10-30T22:15:35 UTC"))));
assertThat(userOne.getStatus(), is(equalTo(HyperwalletUser.Status.PRE_ACTIVATED)));
assertThat(userOne.getVerificationStatus(), is(equalTo(HyperwalletUser.VerificationStatus.NOT_REQUIRED)));
HyperwalletUser userTwo = returnValue.getData().get(1);
assertThat(userTwo.getToken(), is(equalTo("usr-f9154016-94e8-4686-a840-075688ac07b5")));
assertThat(userTwo.getCreatedOn(), is(equalTo(dateFormat.parse("2019-10-30T22:15:45 UTC"))));
assertThat(userTwo.getStatus(), is(equalTo(HyperwalletUser.Status.PRE_ACTIVATED)));
assertThat(userTwo.getVerificationStatus(), is(equalTo(HyperwalletUser.VerificationStatus.REQUIRED)));

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls add assert statement for the 2nd index as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


@Test
public void testGetUserStatusTransition() throws Exception {
String functionality = "getUserStatusTransition";
Expand Down
23 changes: 14 additions & 9 deletions src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,26 @@ public void testListUsers_withParameters() throws Exception {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);

HyperwalletPaginationOptions options = new HyperwalletPaginationOptions();
options
HyperwalletUsersListPaginationOptions options = new HyperwalletUsersListPaginationOptions();
options.clientUserId("test-cleint-user-id")
.email("test-email")
.programToken("test-program-token")
.status(HyperwalletUser.Status.ACTIVATED)
.verificationStatus(VerificationStatus.REQUESTED)
.createdAfter(convertStringToDate("2016-06-29T17:58:26Z"))
.createdBefore(convertStringToDate("2016-06-29T17:58:26Z"))
.sortBy("test-sort-by")
.offset(5)
.limit(10)
.createdAfter(convertStringToDate("2016-06-29T17:58:26Z"))
.createdBefore(convertStringToDate("2016-06-29T17:58:26Z"));

.limit(10);
Mockito.when(mockApiClient.get(Mockito.anyString(), Mockito.any(TypeReference.class))).thenReturn(response);

HyperwalletList<HyperwalletUser> resp = client.listUsers(options);
assertThat(resp, is(equalTo(response)));

Mockito.verify(mockApiClient).get(Mockito.eq("https://api.sandbox.hyperwallet.com/rest/v3/users?createdAfter=2016-06-29T17:58:26Z&createdBefore=2016-06-29T17:58:26Z&sortBy=test-sort-by&offset=5&limit=10"), Mockito.any(TypeReference.class));
Mockito.verify(mockApiClient).get(Mockito.
eq("https://api.sandbox.hyperwallet.com/rest/v3/users?createdAfter=2016-06-29T17:58:26Z&createdBefore=2016-06-29T17:58:26Z&sortBy=test-sort-by&offset=5&limit=10&clientUserId=test-cleint-user-id&email=test-email&programToken=test-program-token&status=ACTIVATED&verificationStatus=REQUESTED"), Mockito.any(TypeReference.class));


}

@Test
Expand All @@ -333,7 +339,7 @@ public void testListUsers_withSomeParameters() throws Exception {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);

HyperwalletPaginationOptions options = new HyperwalletPaginationOptions();
HyperwalletUsersListPaginationOptions options = new HyperwalletUsersListPaginationOptions();
options
.sortBy("test-sort-by")
.offset(5)
Expand Down Expand Up @@ -7472,7 +7478,6 @@ public void testListTransferRefunds_withAllParameters() throws Exception {
assertThat(resp, is(equalTo(response)));

Mockito.verify(mockApiClient).get(Mockito.eq("https://api.sandbox.hyperwallet.com/rest/v3/transfers/" + transferToken + "/refunds?createdAfter=2016-06-29T17:58:26Z&createdBefore=2016-06-29T17:58:26Z&sortBy=sortByField&limit=10&clientRefundId" + "=destinationToken&sourceToken=sourceToken"), Mockito.any(TypeReference.class));
System.out.println();
}

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

public class HyperwalletUsersListPaginationOptionsTest extends BaseModelTest<HyperwalletUsersListPaginationOptions> {
protected HyperwalletUsersListPaginationOptions createBaseModel() {
HyperwalletUsersListPaginationOptions options = new HyperwalletUsersListPaginationOptions();
options
.clientUserId("test-client-id")
.email("test@test.com")
.programToken("test-prg-token")
.status(HyperwalletUser.Status.ACTIVATED)
.verificationStatus(HyperwalletUser.VerificationStatus.REQUIRED);

return options;
}

protected Class<HyperwalletUsersListPaginationOptions> createModelClass() {
return HyperwalletUsersListPaginationOptions.class;
}
}

3 changes: 3 additions & 0 deletions src/test/resources/integration/listUsers-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/v3/users" \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls add some query parameters for filtering options here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed before this couldnt be done as testing dynamically with query parameters is not feasible in the current mock test setup.

-u testuser@12345678:myAccPassw0rd \
-H "Accept: application/json"
69 changes: 69 additions & 0 deletions src/test/resources/integration/listUsers-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"count": 2,
"offset": 0,
"limit": 10,
"data": [
{
"token": "usr-00c6cfda-a43d-4b29-a20b-1abc7e800b58",
"status": "PRE_ACTIVATED",
"verificationStatus": "NOT_REQUIRED",
"createdOn": "2019-10-30T22:15:35",
"clientUserId": "CSLAJQt7bD",
"profileType": "INDIVIDUAL",
"firstName": "John",
"lastName": "Smith",
"dateOfBirth": "1980-01-01",
"email": "john@company.com",
"addressLine1": "123 Main Street",
"city": "New York",
"stateProvince": "NY",
"country": "US",
"postalCode": "10016",
"language": "en",
"programToken": "prg-83836cdf-2ce2-4696-8bc5-f1b86077238c",
"links": [
{
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v3/users/usr-00c6cfda-a43d-4b29-a20b-1abc7e800b58"
}
]
},
{
"token": "usr-f9154016-94e8-4686-a840-075688ac07b5",
"status": "PRE_ACTIVATED",
"verificationStatus": "REQUIRED",
"createdOn": "2019-10-30T22:15:45",
"clientUserId": "CSK7b8Ffch",
"profileType": "INDIVIDUAL",
"firstName": "John",
"lastName": "Smith",
"dateOfBirth": "1980-01-01",
"email": "john@company.com",
"addressLine1": "123 Smith Street",
"city": "New York",
"stateProvince": "NY",
"country": "US",
"postalCode": "10016",
"language": "en",
"programToken": "prg-83836cdf-2ce2-4696-8bc5-f1b86077238c",
"links": [
{
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v3/users/usr-f9154016-94e8-4686-a840-075688ac07b5"
}
]
}
],
"links": [
{
"params": {
"rel": "self"
},
"href": "https://api.sandbox.hyperwallet.com/rest/v3/users?offset=0&limit=10"
}
]
}