Skip to content

Commit

Permalink
Merge pull request #79 from uphold/enhancement/update-user-model
Browse files Browse the repository at this point in the history
Update user model
  • Loading branch information
ruipenso committed Apr 12, 2016
2 parents a04e84a + a025ebe commit d5ab6df
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ public void getUserShouldReturnTheUser() throws Exception {
"\"email\": \"[email protected]\"," +
"\"firstName\": \"foo\"," +
"\"lastName\": \"bar\"," +
"\"memberAt\": \"Foobar\"," +
"\"name\": \"Foo Bar\"," +
"\"country\": \"BAR\"," +
"\"state\": \"FOO\"," +
Expand Down Expand Up @@ -342,6 +343,7 @@ public Promise<User> call(UpholdRestAdapter adapter) {
Assert.assertEquals(user.getEmail(), "[email protected]");
Assert.assertEquals(user.getFirstName(), "foo");
Assert.assertEquals(user.getLastName(), "bar");
Assert.assertEquals(user.getMemberAt(), "Foobar");
Assert.assertEquals(user.getName(), "Foo Bar");
Assert.assertEquals(user.getSettings().getCurrency(), "USD");
Assert.assertEquals(user.getSettings().getIntl().getDateTimeFormat().getLocale(), "en-US");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ public static User loadUser(HashMap<String, String> fields) {
put("internationalizationUserSettingLanguage", faker.lorem().fixedString(5));
put("internationalizationUserSettingNumberFormat", faker.lorem().fixedString(5));
put("lastName", faker.name().lastName());
put("memberAt", faker.lorem().fixedString(8));
put("name", faker.name().name());
put("settingsOTPLogin", "true");
put("settingsOTPTransactionsSend", "true");
Expand Down Expand Up @@ -295,7 +296,7 @@ public static User loadUser(HashMap<String, String> fields) {
Otp otp = new Otp(new Login(Boolean.valueOf(fakerFields.get("settingsOTPLogin"))), new Transactions(new Send(Boolean.valueOf(fakerFields.get("settingsOTPTransactionsSend"))), new Transfer(Boolean.valueOf(fakerFields.get("settingsOTPTransactionsTransfer"))), new Withdraw(new Crypto(Boolean.valueOf(fakerFields.get("settingsOTPTransactionsWithdrawCrypto"))))));
Settings settings = new Settings(fakerFields.get("currency"), Boolean.valueOf(fakerFields.get("hasNewsSubscription")), Boolean.valueOf(fakerFields.get("hasOtpEnabled")), internationalizationUserSettings, otp, fakerFields.get("theme"));

return new User(fakerFields.get("country"), currencies, fakerFields.get("email"), fakerFields.get("firstName"), fakerFields.get("lastName"), fakerFields.get("name"), settings, fakerFields.get("state"), fakerFields.get("status"), fakerFields.get("username"));
return new User(fakerFields.get("country"), currencies, fakerFields.get("email"), fakerFields.get("firstName"), fakerFields.get("lastName"), fakerFields.get("memberAt"), fakerFields.get("name"), settings, fakerFields.get("state"), fakerFields.get("status"), fakerFields.get("username"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class User extends BaseModel implements Serializable {
private final String email;
private final String firstName;
private final String lastName;
private final String memberAt;
private final String name;
private final Settings settings;
private final String state;
Expand All @@ -52,19 +53,21 @@ public class User extends BaseModel implements Serializable {
* @param email The user email
* @param firstName The user first name
* @param lastName The user last name
* @param memberAt The date when the user has become a verified member
* @param name The user name
* @param settings The user {@link Settings}
* @param state The user state
* @param status The user {@link Status}
* @param username The user username
*/

public User(String country, List<String> currencies, String email, String firstName, String lastName, String name, Settings settings, String state, String status, String username) {
public User(String country, List<String> currencies, String email, String firstName, String lastName, String memberAt, String name, Settings settings, String state, String status, String username) {
this.country = country;
this.currencies = currencies;
this.email = email;
this.firstName = firstName;
this.lastName = lastName;
this.memberAt = memberAt;
this.name = name;
this.settings = settings;
this.state = state;
Expand Down Expand Up @@ -293,6 +296,16 @@ public String getLastName() {
return lastName;
}

/**
* Gets the date when the user has become a verified member
*
* @return the date when the user has become a verified member.
*/

public String getMemberAt() {
return memberAt;
}

/**
* Gets the user name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void shouldBeSerializable() {
Otp otp = new Otp(new Login(false), new Transactions(new Send(false), new Transfer(false), new Withdraw(new Crypto(true))));
Settings settings = new Settings("FIZ", true, false, internationalizationUserSettings, otp, "FUZ");
ArrayList<String> currencies = new ArrayList<>();
User user = new User("foobar", currencies, "[email protected]", "foo", "bar", "Foo Bar", settings, "foobiz", "foobar", "fizbiz");
User user = new User("foobar", currencies, "[email protected]", "foo", "bar", "foobar", "Foo Bar", settings, "foobiz", "foobar", "fizbiz");

currencies.add("EUR");
currencies.add("USD");
Expand All @@ -52,6 +52,7 @@ public void shouldBeSerializable() {
Assert.assertEquals(user.getEmail(), deserializedUser.getEmail());
Assert.assertEquals(user.getFirstName(), deserializedUser.getFirstName());
Assert.assertEquals(user.getLastName(), deserializedUser.getLastName());
Assert.assertEquals(user.getMemberAt(), deserializedUser.getMemberAt());
Assert.assertEquals(user.getName(), deserializedUser.getName());
Assert.assertEquals(user.getSettings().getCurrency(), deserializedUser.getSettings().getCurrency());
Assert.assertEquals(user.getSettings().getHasNewsSubscription(), deserializedUser.getSettings().getHasNewsSubscription());
Expand Down

0 comments on commit d5ab6df

Please sign in to comment.