Skip to content

Commit

Permalink
Merge pull request #58 from uphold/feature/update-transaction-model-w…
Browse files Browse the repository at this point in the history
…ith-account-information

Update transaction model with account information
  • Loading branch information
diogoguimaraes committed Oct 20, 2015
2 parents fb26639 + 6991f45 commit 3a1957a
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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\"," +
Expand All @@ -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\"," +
Expand Down Expand Up @@ -110,7 +114,9 @@ public Promise<Transaction> 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");
Expand All @@ -120,6 +126,8 @@ public Promise<Transaction> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public static Transaction loadTransaction(HashMap<String, String> 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));
Expand All @@ -120,6 +122,8 @@ public static Transaction loadTransaction(HashMap<String, String> 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));
Expand Down Expand Up @@ -154,7 +158,7 @@ public static Transaction loadTransaction(HashMap<String, String> 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<Source> sources = new ArrayList<Source>() {{
ArrayList<String> ids = new ArrayList<>(Arrays.asList(fakerFields.get("originSourcesId").split(",")));
ArrayList<String> amount = new ArrayList<>(Arrays.asList(fakerFields.get("originSourcesAmount").split(",")));
Expand All @@ -163,7 +167,7 @@ public static Transaction loadTransaction(HashMap<String, String> 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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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;
Expand All @@ -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.
*
Expand All @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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<Source> 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<Source> sources, String type, String username) {
this.AccountId = AccountId;
this.CardId = cardId;
this.accountType = accountType;
this.amount = amount;
this.base = base;
this.commission = commission;
Expand All @@ -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.
*
Expand All @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Source> 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);
Expand All @@ -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());
Expand Down

0 comments on commit 3a1957a

Please sign in to comment.