-
Notifications
You must be signed in to change notification settings - Fork 9
HW-51229: List PayPal accounts #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fmattos-hw
merged 17 commits into
feature/HW-51227-paypal-account
from
feature/HW-51229_List_PayPal_accounts
May 4, 2019
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
045bcfc
HW-51229: List PayPal accounts
vshcherbyna-epam 53ce03d
optimization
vshcherbyna-epam 6235609
fixes on callouts
vshcherbyna-epam 666f551
add test for PayPalAccount form the list
vshcherbyna-epam bad9f75
HW-51226. PayPalAccount update (#1)
azakrevska-epam 296bb3b
HW-51227. PayPal Account Creation (#2)
azakrevska-epam 6733ab0
HW-51321: Get paypal account (#3)
vshcherbyna-epam 22e89d1
Adding required properties to pom file
fmattos-hw c31df58
Version update and exempt maven local publish task from signing
fmattos-hw eddeb7f
add PayPal get test to Hyperwallet test suite
fmattos-hw f2beb6d
HW-51228. PayPal Account Deactivation (#4)
azakrevska-epam 082b87e
Feature/hw 51228 deactivate pay pal account (#16)
fmattos-hw b43583d
HW-51229: List PayPal accounts
vshcherbyna-epam 47789fb
optimization
vshcherbyna-epam b514c45
fixes on callouts
vshcherbyna-epam 29d9116
add test for PayPalAccount form the list
vshcherbyna-epam f2187a1
Merge remote-tracking branch 'origin/feature/HW-51229_List_PayPal_acc…
fmattos-hw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 138 additions & 28 deletions
166
core/src/main/java/com/hyperwallet/android/Hyperwallet.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
core/src/main/java/com/hyperwallet/android/model/HyperwalletPayPalAccountPagination.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Copyright 2018 Hyperwallet | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
| * documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
| * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
| * to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all copies or substantial portions of | ||
| * the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO | ||
| * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| */ | ||
| package com.hyperwallet.android.model; | ||
|
|
||
| import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodTypes.PAYPAL_ACCOUNT; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
|
|
||
| import com.hyperwallet.android.util.DateUtil; | ||
|
|
||
| import java.util.Date; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Represents the PayPal Account pagination fields | ||
| */ | ||
| public class HyperwalletPayPalAccountPagination extends HyperwalletTransferMethodPagination { | ||
|
|
||
| protected static final String TRANSFER_METHOD_CREATE_ON = "createdOn"; | ||
|
|
||
| private Date mCreatedOn; | ||
|
|
||
| /** | ||
| * Constructs the default implementation of the PayPal Account pagination. | ||
| */ | ||
| public HyperwalletPayPalAccountPagination() { | ||
| super(); | ||
| setType(PAYPAL_ACCOUNT); | ||
| } | ||
|
|
||
| /** | ||
| * Constructs the PayPal Account pagination based in the preview request with extra parameters. | ||
| * | ||
| * @param urlQueryMap the map with properties to build the pagination | ||
| */ | ||
| public HyperwalletPayPalAccountPagination(Map<String, String> urlQueryMap) { | ||
| super(urlQueryMap); | ||
| mCreatedOn = getDateValueBy(urlQueryMap, TRANSFER_METHOD_CREATE_ON); | ||
| setType(PAYPAL_ACCOUNT); | ||
| } | ||
|
|
||
| public Date getCreatedOn() { | ||
| return mCreatedOn; | ||
| } | ||
|
|
||
| @NonNull | ||
| @Override | ||
| public Map<String, String> buildQuery() { | ||
| Map<String, String> query = super.buildQuery(); | ||
| if (mCreatedOn != null) { | ||
| query.put(TRANSFER_METHOD_CREATE_ON, DateUtil.toDateTimeFormat(mCreatedOn)); | ||
| } | ||
| return query; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
core/src/test/java/com/hyperwallet/android/model/HyperwalletPayPalAccountPaginationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| package com.hyperwallet.android.model; | ||
|
|
||
| import static org.hamcrest.CoreMatchers.is; | ||
| import static org.hamcrest.CoreMatchers.nullValue; | ||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
|
|
||
| import static com.hyperwallet.android.model.HyperwalletStatusTransition.StatusDefinition.ACTIVATED; | ||
| import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodTypes.PAYPAL_ACCOUNT; | ||
| import static com.hyperwallet.android.model.HyperwalletTransferMethodPagination.TransferMethodSortable.ASCENDANT_CREATE_ON; | ||
| import static com.hyperwallet.android.model.HyperwalletTransferMethodPagination.TransferMethodSortable.ASCENDANT_STATUS; | ||
|
|
||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| import java.util.Calendar; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class HyperwalletPayPalAccountPaginationTest { | ||
| private final static String OFFSET = "offset"; | ||
| private final static String LIMIT = "limit"; | ||
| private final static String CREATE_BEFORE = "createdBefore"; | ||
| private final static String CREATE_AFTER = "createdAfter"; | ||
| private final static String CREATE_ON = "createdOn"; | ||
| private final static String TRANSFER_METHOD_TYPE = "type"; | ||
| private final static String STATUS = "status"; | ||
| private final static String SORT_BY = "sortBy"; | ||
|
|
||
|
|
||
| @Test | ||
| public void testHyperwalletPayPalAccountPagination_withUrlQueryMap() { | ||
| Map<String, String> query = new HashMap<>(); | ||
| query.put(OFFSET, "100"); | ||
| query.put(LIMIT, "200"); | ||
| query.put(CREATE_BEFORE, "2017-01-01T10:12:22"); | ||
| query.put(CREATE_AFTER, "2017-01-01T00:00:00"); | ||
| query.put(CREATE_ON, "2017-01-01T10:10:00"); | ||
| query.put(TRANSFER_METHOD_TYPE, PAYPAL_ACCOUNT); | ||
| query.put(STATUS, ACTIVATED); | ||
| query.put(SORT_BY, ASCENDANT_STATUS); | ||
|
|
||
| HyperwalletPayPalAccountPagination pagination = new HyperwalletPayPalAccountPagination(query); | ||
|
|
||
| assertThat(pagination.getLimit(), is(200)); | ||
| assertThat(pagination.getOffset(), is(100)); | ||
| assertThat(pagination.getType(), is(PAYPAL_ACCOUNT)); | ||
| assertThat(pagination.getStatus(), is(ACTIVATED)); | ||
| assertThat(pagination.getSortBy(), is(ASCENDANT_STATUS)); | ||
|
|
||
| Calendar createdBefore = Calendar.getInstance(); | ||
| createdBefore.setTime(pagination.getCreatedBefore()); | ||
| assertThat(createdBefore.get(Calendar.YEAR), is(2017)); | ||
| assertThat(createdBefore.get(Calendar.MONTH), is(Calendar.JANUARY)); | ||
| assertThat(createdBefore.get(Calendar.DAY_OF_MONTH), is(1)); | ||
| assertThat(createdBefore.get(Calendar.HOUR), is(10)); | ||
| assertThat(createdBefore.get(Calendar.MINUTE), is(12)); | ||
| assertThat(createdBefore.get(Calendar.SECOND), is(22)); | ||
|
|
||
| Calendar createdAfter = Calendar.getInstance(); | ||
| createdAfter.setTime(pagination.getCreatedAfter()); | ||
| assertThat(createdAfter.get(Calendar.YEAR), is(2017)); | ||
| assertThat(createdAfter.get(Calendar.MONTH), is(Calendar.JANUARY)); | ||
| assertThat(createdAfter.get(Calendar.DAY_OF_MONTH), is(1)); | ||
| assertThat(createdAfter.get(Calendar.HOUR), is(0)); | ||
| assertThat(createdAfter.get(Calendar.MINUTE), is(0)); | ||
| assertThat(createdAfter.get(Calendar.SECOND), is(0)); | ||
|
|
||
| Calendar createdOn = Calendar.getInstance(); | ||
| createdOn.setTime(pagination.getCreatedOn()); | ||
| assertThat(createdOn.get(Calendar.YEAR), is(2017)); | ||
| assertThat(createdOn.get(Calendar.MONTH), is(Calendar.JANUARY)); | ||
| assertThat(createdOn.get(Calendar.DAY_OF_MONTH), is(1)); | ||
| assertThat(createdOn.get(Calendar.HOUR), is(10)); | ||
| assertThat(createdOn.get(Calendar.MINUTE), is(10)); | ||
| assertThat(createdOn.get(Calendar.SECOND), is(0)); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| @Test | ||
| public void testHyperwalletPayPalAccountPagination_verifyDefaultValues() { | ||
|
|
||
| HyperwalletPayPalAccountPagination pagination = new HyperwalletPayPalAccountPagination(); | ||
| assertThat(pagination.getLimit(), is(10)); | ||
| assertThat(pagination.getOffset(), is(0)); | ||
| assertThat(pagination.getType(), is(PAYPAL_ACCOUNT)); | ||
| assertThat(pagination.getStatus(), is(nullValue())); | ||
| assertThat(pagination.getSortBy(), is(nullValue())); | ||
| assertThat(pagination.getCreatedBefore(), is(nullValue())); | ||
| assertThat(pagination.getCreatedAfter(), is(nullValue())); | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| public void testBuildQuery_verifyDefaultValues() { | ||
| HyperwalletPagination pagination = new HyperwalletPagination(); | ||
|
|
||
| Map<String, String> query = pagination.buildQuery(); | ||
|
|
||
| Assert.assertNotNull(query); | ||
| assertThat(query.size(), is(2)); | ||
| assertThat(query.get(OFFSET), is("0")); | ||
| assertThat(query.get(LIMIT), is("10")); | ||
| assertThat(query.get(TRANSFER_METHOD_TYPE), is(nullValue())); | ||
| assertThat(query.get(STATUS), is(nullValue())); | ||
| assertThat(query.get(SORT_BY), is(nullValue())); | ||
| assertThat(query.get(CREATE_BEFORE), is(nullValue())); | ||
| assertThat(query.get(CREATE_AFTER), is(nullValue())); | ||
| assertThat(query.get(CREATE_ON), is(nullValue())); | ||
| assertThat(query.get(TRANSFER_METHOD_TYPE), is(nullValue())); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| @Test | ||
| public void testBuildQuery_returnsQueryParameters() { | ||
|
|
||
| Map<String, String> query = new HashMap<>(); | ||
| query.put(OFFSET, "100"); | ||
| query.put(LIMIT, "200"); | ||
| query.put(CREATE_BEFORE, "2017-01-01T10:12:22"); | ||
| query.put(CREATE_AFTER, "2017-01-01T00:00:000"); | ||
| query.put(CREATE_ON, "2017-01-01T10:10:00"); | ||
| query.put(TRANSFER_METHOD_TYPE, PAYPAL_ACCOUNT); | ||
| query.put(STATUS, ACTIVATED); | ||
| query.put(SORT_BY, ASCENDANT_CREATE_ON); | ||
|
|
||
| HyperwalletPayPalAccountPagination pagination = new HyperwalletPayPalAccountPagination(query); | ||
| Map<String, String> resultQuery = pagination.buildQuery(); | ||
|
|
||
| assertThat(resultQuery.containsKey(STATUS), is(true)); | ||
| assertThat(resultQuery.containsKey(SORT_BY), is(true)); | ||
| assertThat(resultQuery.containsKey(OFFSET), is(true)); | ||
| assertThat(resultQuery.containsKey(LIMIT), is(true)); | ||
| assertThat(resultQuery.containsKey(CREATE_BEFORE), is(true)); | ||
| assertThat(resultQuery.containsKey(CREATE_AFTER), is(true)); | ||
| assertThat(resultQuery.containsKey(TRANSFER_METHOD_TYPE), is(true)); | ||
|
|
||
| assertThat(resultQuery.get(LIMIT), is("200")); | ||
| assertThat(resultQuery.get(OFFSET), is("100")); | ||
| assertThat(resultQuery.get(STATUS), is(ACTIVATED)); | ||
| assertThat(resultQuery.get(SORT_BY), is(ASCENDANT_CREATE_ON)); | ||
| assertThat(resultQuery.get(CREATE_BEFORE), is("2017-01-01T10:12:22")); | ||
| assertThat(resultQuery.get(CREATE_AFTER), is("2017-01-01T00:00:00")); | ||
| assertThat(resultQuery.get(CREATE_ON), is("2017-01-01T10:10:00")); | ||
| assertThat(resultQuery.get(TRANSFER_METHOD_TYPE), is(PAYPAL_ACCOUNT)); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.