From 6991f4555f1f3a59dcebf5145a81a0f042fcefc0 Mon Sep 17 00:00:00 2001 From: Sandro Machado Date: Mon, 19 Oct 2015 16:44:49 +0100 Subject: [PATCH] Update transaction model with account information --- .../test/integration/model/CardTest.java | 8 ++++++ .../test/util/Fixtures.java | 8 ++++-- .../model/transaction/Destination.java | 28 ++++++++++++++++++- .../model/transaction/Origin.java | 28 ++++++++++++++++++- .../test/unit/model/TransactionTest.java | 16 +++++++---- 5 files changed, 78 insertions(+), 10 deletions(-) diff --git a/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/CardTest.java b/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/CardTest.java index 483baf1..dd975fc 100644 --- a/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/CardTest.java +++ b/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/CardTest.java @@ -49,7 +49,9 @@ public void createTransactionShouldReturnTheTransaction() throws Exception { "\"rate\": \"1.00\"" + "}," + "\"origin\": {" + + "\"AccountId\": \"fiz\"," + "\"CardId\": \"bar\"," + + "\"accountType\": \"biz\"," + "\"amount\": \"0.1\"," + "\"base\": \"0.1\"," + "\"commission\": \"0.00\"," + @@ -61,6 +63,8 @@ public void createTransactionShouldReturnTheTransaction() throws Exception { "\"username\": \"foobar\"" + "}," + "\"destination\": {" + + "\"AccountId\": \"fuz\"," + + "\"accountType\": \"buz\"," + "\"amount\": \"0.1\"," + "\"base\": \"0.1\"," + "\"commission\": \"0.00\"," + @@ -110,7 +114,9 @@ public Promise call(UpholdRestAdapter adapter) { Assert.assertEquals(transaction.getDenomination().getCurrency(), "BTC"); Assert.assertEquals(transaction.getDenomination().getPair(), "BTCBTC"); Assert.assertEquals(transaction.getDenomination().getRate(), "1.00"); + Assert.assertEquals(transaction.getOrigin().getAccountId(), "fiz"); Assert.assertEquals(transaction.getOrigin().getCardId(), "bar"); + Assert.assertEquals(transaction.getOrigin().getAccountType(), "biz"); Assert.assertEquals(transaction.getOrigin().getAmount(), "0.1"); Assert.assertEquals(transaction.getOrigin().getBase(), "0.1"); Assert.assertEquals(transaction.getOrigin().getCommission(), "0.00"); @@ -120,6 +126,8 @@ public Promise call(UpholdRestAdapter adapter) { Assert.assertEquals(transaction.getOrigin().getRate(), "1.00"); Assert.assertEquals(transaction.getOrigin().getType(), "card"); Assert.assertEquals(transaction.getOrigin().getUsername(), "foobar"); + Assert.assertEquals(transaction.getDestination().getAccountId(), "fuz"); + Assert.assertEquals(transaction.getDestination().getAccountType(), "buz"); Assert.assertEquals(transaction.getDestination().getAmount(), "0.1"); Assert.assertEquals(transaction.getDestination().getBase(), "0.1"); Assert.assertEquals(transaction.getDestination().getCommission(), "0.00"); diff --git a/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/util/Fixtures.java b/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/util/Fixtures.java index 03bf98c..9075177 100644 --- a/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/util/Fixtures.java +++ b/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/util/Fixtures.java @@ -110,6 +110,8 @@ public static Transaction loadTransaction(HashMap fields) { put("denominationCurrency", faker.lorem().fixedString(3)); put("denominationPair", faker.lorem().fixedString(6)); put("denominationRate", faker.numerify("123456789")); + put("destinationAccountId", faker.numerify("123456789")); + put("destinationAccountType", faker.lorem().fixedString(7)); put("destinationAmount", faker.numerify("123456789")); put("destinationBase", faker.numerify("123456789")); put("destinationCardId", faker.lorem().fixedString(24)); @@ -120,6 +122,8 @@ public static Transaction loadTransaction(HashMap fields) { put("destinationRate", faker.lorem().fixedString(3)); put("destinationType", faker.lorem().fixedString(6)); put("destinationUsername", faker.lorem().fixedString(10)); + put("originAccountId", faker.numerify("123456789")); + put("originAccountType", faker.lorem().fixedString(7)); put("originAmount", faker.numerify("123456789")); put("originBase", faker.numerify("123456789")); put("originCardId", faker.lorem().fixedString(24)); @@ -154,7 +158,7 @@ public static Transaction loadTransaction(HashMap fields) { } Denomination denomination = new Denomination(fakerFields.get("denominationAmount"), fakerFields.get("denominationCurrency"), fakerFields.get("denominationPair"), fakerFields.get("denominationRate")); - Destination destination = new Destination(fakerFields.get("destinationCardId"), fakerFields.get("destinationAmount"), fakerFields.get("destinationBase"), fakerFields.get("destinationCommission"), fakerFields.get("destinationCurrency"), fakerFields.get("destinationDescription"), fakerFields.get("destinationFee"), fakerFields.get("destinationRate"), fakerFields.get("destinationType"), fakerFields.get("destinationUsername")); + Destination destination = new Destination(fakerFields.get("destinationAccountId"), fakerFields.get("destinationCardId"), fakerFields.get("destinationAccountType"), fakerFields.get("destinationAmount"), fakerFields.get("destinationBase"), fakerFields.get("destinationCommission"), fakerFields.get("destinationCurrency"), fakerFields.get("destinationDescription"), fakerFields.get("destinationFee"), fakerFields.get("destinationRate"), fakerFields.get("destinationType"), fakerFields.get("destinationUsername")); ArrayList sources = new ArrayList() {{ ArrayList ids = new ArrayList<>(Arrays.asList(fakerFields.get("originSourcesId").split(","))); ArrayList amount = new ArrayList<>(Arrays.asList(fakerFields.get("originSourcesAmount").split(","))); @@ -163,7 +167,7 @@ public static Transaction loadTransaction(HashMap fields) { add(new Source(ids.get(counter), amount.get(counter))); } }}; - Origin origin = new Origin(fakerFields.get("originCardId"), fakerFields.get("originAmount"), fakerFields.get("originBase"), fakerFields.get("originCommission"), fakerFields.get("originCurrency"), fakerFields.get("originDescription"), fakerFields.get("originFee"), fakerFields.get("originRate"), sources, fakerFields.get("originType"), fakerFields.get("originUsername")); + Origin origin = new Origin(fakerFields.get("originAccountId"), fakerFields.get("originCardId"), fakerFields.get("originAccountType"), fakerFields.get("originAmount"), fakerFields.get("originBase"), fakerFields.get("originCommission"), fakerFields.get("originCurrency"), fakerFields.get("originDescription"), fakerFields.get("originFee"), fakerFields.get("originRate"), sources, fakerFields.get("originType"), fakerFields.get("originUsername")); Parameters parameters = new Parameters(fakerFields.get("parametersCurrency"), fakerFields.get("parametersMargin"), fakerFields.get("parametersPair"), fakerFields.get("parametersProgress"), fakerFields.get("parametersRate"), fakerFields.get("parametersRefunds"), Integer.parseInt(fakerFields.get("parametersTtl")), fakerFields.get("parametersTxid"), fakerFields.get("parametersType")); return new Transaction(fakerFields.get("transactionId"), fakerFields.get("transactionCreatedAt"), denomination, destination, fakerFields.get("transactionMessage"), origin, parameters, fakerFields.get("transactionRefundedById"), fakerFields.get("transactionStatus"), fakerFields.get("transactionType")); diff --git a/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Destination.java b/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Destination.java index 27eaa31..322cd54 100644 --- a/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Destination.java +++ b/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Destination.java @@ -8,7 +8,9 @@ public class Destination implements Serializable { + private final String AccountId; private final String CardId; + private final String accountType; private final String amount; private final String base; private final String commission; @@ -22,7 +24,9 @@ public class Destination implements Serializable { /** * Constructor. * + * @param AccountId The id of the account from the destination of the transaction. * @param cardId The card id of the card from the destination of the transaction. + * @param accountType The type of the account from the destination of the transaction. * @param amount The amount from the destination of the transaction. * @param base The base from the destination of the transaction. * @param commission The commission from the destination of the transaction. @@ -34,8 +38,10 @@ public class Destination implements Serializable { * @param username The username from the destination of the transaction. */ - public Destination(String cardId, String amount, String base, String commission, String currency, String description, String fee, String rate, String type, String username) { + public Destination(String AccountId, String cardId, String accountType, String amount, String base, String commission, String currency, String description, String fee, String rate, String type, String username) { + this.AccountId = AccountId; this.CardId = cardId; + this.accountType = accountType; this.amount = amount; this.base = base; this.commission = commission; @@ -47,6 +53,16 @@ public Destination(String cardId, String amount, String base, String commission, this.username = username; } + /** + * Gets the id of the account from the destination of the transaction. + * + * @return the id of the account from the destination of the transaction. + */ + + public String getAccountId() { + return AccountId; + } + /** * Gets the card id of the card from the destination of the transaction. * @@ -57,6 +73,16 @@ public String getCardId() { return CardId; } + /** + * Gets the type of the account from the destination of the transaction. + * + * @return the type of the account from the destination of the transaction. + */ + + public String getAccountType() { + return accountType; + } + /** * Gets the amount from the destination of the transaction. * diff --git a/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Origin.java b/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Origin.java index cee4efc..58c348f 100644 --- a/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Origin.java +++ b/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Origin.java @@ -9,7 +9,9 @@ public class Origin implements Serializable { + private final String AccountId; private final String CardId; + private final String accountType; private final String amount; private final String base; private final String commission; @@ -24,7 +26,9 @@ public class Origin implements Serializable { /** * Constructor. * + * @param AccountId The id of the account from the origin of the transaction. * @param cardId The card id of the card from the origin of the transaction. + * @param accountType The type of the account from the origin of the transaction. * @param amount The amount from the origin of the transaction. * @param base The base from the origin of the transaction. * @param commission The commission from the origin of the transaction. @@ -37,8 +41,10 @@ public class Origin implements Serializable { * @param username The username from the origin of the transaction. */ - public Origin(String cardId, String amount, String base, String commission, String currency, String description, String fee, String rate, List sources, String type, String username) { + public Origin(String AccountId, String cardId, String accountType, String amount, String base, String commission, String currency, String description, String fee, String rate, List sources, String type, String username) { + this.AccountId = AccountId; this.CardId = cardId; + this.accountType = accountType; this.amount = amount; this.base = base; this.commission = commission; @@ -51,6 +57,16 @@ public Origin(String cardId, String amount, String base, String commission, Stri this.username = username; } + /** + * Gets the id of the account from the origin of the transaction. + * + * @return the id of the account from the origin of the transaction. + */ + + public String getAccountId() { + return AccountId; + } + /** * Gets the card id of the card from the origin of the transaction. * @@ -61,6 +77,16 @@ public String getCardId() { return CardId; } + /** + * Gets the type of the account from the origin of the transaction + * + * @return the type of the account. + */ + + public String getAccountType() { + return accountType; + } + /** * Gets the amount from the origin of the transaction. * diff --git a/src/app/src/test/java/com/uphold/uphold_android_sdk/test/unit/model/TransactionTest.java b/src/app/src/test/java/com/uphold/uphold_android_sdk/test/unit/model/TransactionTest.java index 66e9655..860cce6 100644 --- a/src/app/src/test/java/com/uphold/uphold_android_sdk/test/unit/model/TransactionTest.java +++ b/src/app/src/test/java/com/uphold/uphold_android_sdk/test/unit/model/TransactionTest.java @@ -26,11 +26,11 @@ public class TransactionTest { @Test public void shouldBeSerializable() { Denomination denomination = new Denomination("foo", "bar", "fuz", "buz"); - Destination destination = new Destination("foobar", "foobiz", "foobuz", "fizbuz", "fizbiz", "foo", "bar", "fiz", "biz", "buz"); + Destination destination = new Destination("fizbiz", "foobar", "biz", "foobiz", "foobuz", "fizbuz", "fizbiz", "foo", "bar", "fiz", "biz", "buz"); List sources = new ArrayList<>(); Parameters parameters = new Parameters("foobar", "foobiz", "foobuz", "fizbiz", "fuz", "fiz", 1, "foo", "bar"); Source source = new Source("FUZBUZ", "FIZBIZ"); - Origin origin = new Origin("foo", "bar", "foobar", "foobiz", "fiz", "biz", "fuzbuz", "fuz", sources, "buz", "FOOBAR"); + Origin origin = new Origin("biz", "foo", "fiz", "bar", "foobar", "foobiz", "fiz", "biz", "fuzbuz", "fuz", sources, "buz", "FOOBAR"); Transaction transaction = new Transaction("foobar", "foobiz", denomination, destination, "fuzbuz", origin, parameters, "fizbiz", "foobuz", "foo"); sources.add(source); @@ -43,18 +43,22 @@ public void shouldBeSerializable() { Assert.assertEquals(transaction.getDenomination().getCurrency(), deserializedTransaction.getDenomination().getCurrency()); Assert.assertEquals(transaction.getDenomination().getPair(), deserializedTransaction.getDenomination().getPair()); Assert.assertEquals(transaction.getDenomination().getRate(), deserializedTransaction.getDenomination().getRate()); - Assert.assertEquals(transaction.getDestination().getAmount(), deserializedTransaction.getDestination().getAmount() ); + Assert.assertEquals(transaction.getDestination().getAccountId(), deserializedTransaction.getDestination().getAccountId()); + Assert.assertEquals(transaction.getDestination().getAccountType(), deserializedTransaction.getDestination().getAccountType()); + Assert.assertEquals(transaction.getDestination().getAmount(), deserializedTransaction.getDestination().getAmount()); Assert.assertEquals(transaction.getDestination().getBase(), deserializedTransaction.getDestination().getBase() ); - Assert.assertEquals(transaction.getDestination().getCardId(), deserializedTransaction.getDestination().getCardId() ); - Assert.assertEquals(transaction.getDestination().getCommission(), deserializedTransaction.getDestination().getCommission() ); + Assert.assertEquals(transaction.getDestination().getCardId(), deserializedTransaction.getDestination().getCardId()); + Assert.assertEquals(transaction.getDestination().getCommission(), deserializedTransaction.getDestination().getCommission()); Assert.assertEquals(transaction.getDestination().getCurrency(), deserializedTransaction.getDestination().getCurrency() ); - Assert.assertEquals(transaction.getDestination().getDescription(), deserializedTransaction.getDestination().getDescription() ); + Assert.assertEquals(transaction.getDestination().getDescription(), deserializedTransaction.getDestination().getDescription()); Assert.assertEquals(transaction.getDestination().getFee(), deserializedTransaction.getDestination().getFee()); Assert.assertEquals(transaction.getDestination().getRate(), deserializedTransaction.getDestination().getRate()); Assert.assertEquals(transaction.getDestination().getType(), deserializedTransaction.getDestination().getType()); Assert.assertEquals(transaction.getDestination().getUsername(), deserializedTransaction.getDestination().getUsername()); Assert.assertEquals(transaction.getId(), deserializedTransaction.getId()); Assert.assertEquals(transaction.getMessage(), deserializedTransaction.getMessage()); + Assert.assertEquals(transaction.getOrigin().getAccountId(), deserializedTransaction.getOrigin().getAccountId()); + Assert.assertEquals(transaction.getOrigin().getAccountType(), deserializedTransaction.getOrigin().getAccountType()); Assert.assertEquals(transaction.getOrigin().getAmount(), deserializedTransaction.getOrigin().getAmount()); Assert.assertEquals(transaction.getOrigin().getBase(), deserializedTransaction.getOrigin().getBase()); Assert.assertEquals(transaction.getOrigin().getCardId(), deserializedTransaction.getOrigin().getCardId());