|
9 | 9 | import static org.hamcrest.MatcherAssert.assertThat; |
10 | 10 | import static org.hamcrest.Matchers.is; |
11 | 11 | import static org.hamcrest.Matchers.notNullValue; |
| 12 | +import static org.hamcrest.collection.IsMapContaining.hasEntry; |
12 | 13 |
|
13 | 14 | public class UserTest extends JsonTest<User> { |
14 | 15 |
|
15 | | - private static final String json = "{\"connection\":\"auth0\",\"client_id\":\"client123\",\"password\":\"pwd\",\"verify_password\":true,\"username\":\"usr\",\"email\":\"me@auth0.com\",\"email_verified\":true,\"verify_email\":true,\"phone_number\":\"1234567890\",\"phone_verified\":true,\"verify_phone_number\":true,\"picture\":\"https://pic.ture/12\",\"name\":\"John\",\"nickname\":\"Johny\",\"given_name\":\"John\",\"family_name\":\"Walker\",\"app_metadata\":{},\"user_metadata\":{},\"blocked\":true}"; |
| 16 | + private static final String json = "{\"connection\":\"auth0\",\"client_id\":\"client123\",\"password\":\"pwd\",\"verify_password\":true,\"username\":\"usr\",\"email\":\"me@auth0.com\",\"email_verified\":true,\"verify_email\":true,\"phone_number\":\"1234567890\",\"phone_verified\":true,\"verify_phone_number\":true,\"picture\":\"https://pic.ture/12\",\"name\":\"John\",\"nickname\":\"Johny\",\"given_name\":\"John\",\"family_name\":\"Walker\",\"app_metadata\":{},\"user_metadata\":{},\"blocked\":true,\"context\":\"extra information\"}"; |
16 | 17 | private static final String readOnlyJson = "{\"user_id\":\"user|123\",\"last_ip\":\"10.0.0.1\",\"last_login\":\"2016-02-23T19:57:29.532Z\",\"logins_count\":10,\"created_at\":\"2016-02-23T19:57:29.532Z\",\"updated_at\":\"2016-02-23T19:57:29.532Z\",\"identities\":[]}"; |
17 | 18 |
|
| 19 | + @Test |
| 20 | + public void shouldHaveEmptyValuesByDefault() throws Exception{ |
| 21 | + User user = new User(); |
| 22 | + assertThat(user.getValues(), is(notNullValue())); |
| 23 | + |
| 24 | + User user2 = new User("my-connection"); |
| 25 | + assertThat(user2.getConnection(), is("my-connection")); |
| 26 | + assertThat(user2.getValues(), is(notNullValue())); |
| 27 | + } |
| 28 | + |
18 | 29 | @Test |
19 | 30 | public void shouldSerialize() throws Exception { |
20 | 31 | User user = new User("auth0"); |
@@ -85,6 +96,8 @@ public void shouldDeserialize() throws Exception { |
85 | 96 | assertThat(user.getUserMetadata(), is(notNullValue())); |
86 | 97 | assertThat(user.getAppMetadata(), is(notNullValue())); |
87 | 98 | assertThat(user.isBlocked(), is(true)); |
| 99 | + assertThat(user.getValues(), is(notNullValue())); |
| 100 | + assertThat(user.getValues(), hasEntry("context", (Object) "extra information")); |
88 | 101 | } |
89 | 102 |
|
90 | 103 | @Test |
|
0 commit comments