コード例 #1
0
  @Test
  public void testUpdateProfileWithNulls() throws Exception {
    conferenceApi.saveProfile(user, new ProfileForm(DISPLAY_NAME, TEE_SHIRT_SIZE));
    // Update the Profile with null values.
    Profile profile = conferenceApi.saveProfile(user, new ProfileForm(null, null));
    // Expected behavior is that the existing properties do not get overwritten

    // Check the return value first.
    assertEquals(USER_ID, profile.getUserId());
    assertEquals(EMAIL, profile.getMainEmail());
    assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
    assertEquals(DISPLAY_NAME, profile.getDisplayName());
    // Fetch the Profile via Objectify.
    profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
    assertEquals(USER_ID, profile.getUserId());
    assertEquals(EMAIL, profile.getMainEmail());
    assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
    assertEquals(DISPLAY_NAME, profile.getDisplayName());
  }
コード例 #2
0
 @Test
 public void testGetProfile() throws Exception {
   conferenceApi.saveProfile(user, new ProfileForm(DISPLAY_NAME, TEE_SHIRT_SIZE));
   // Fetch the Profile via the API.
   Profile profile = conferenceApi.getProfile(user);
   assertEquals(USER_ID, profile.getUserId());
   assertEquals(EMAIL, profile.getMainEmail());
   assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
   assertEquals(DISPLAY_NAME, profile.getDisplayName());
 }
コード例 #3
0
 @Test
 public void testUpdateProfile() throws Exception {
   // Save for the first time.
   conferenceApi.saveProfile(user, new ProfileForm(DISPLAY_NAME, TEE_SHIRT_SIZE));
   Profile profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
   assertEquals(USER_ID, profile.getUserId());
   assertEquals(EMAIL, profile.getMainEmail());
   assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
   assertEquals(DISPLAY_NAME, profile.getDisplayName());
   // Then try to update it.
   String newDisplayName = "New Name";
   TeeShirtSize newTeeShirtSize = TeeShirtSize.L;
   conferenceApi.saveProfile(user, new ProfileForm(newDisplayName, newTeeShirtSize));
   profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
   assertEquals(USER_ID, profile.getUserId());
   assertEquals(EMAIL, profile.getMainEmail());
   assertEquals(newTeeShirtSize, profile.getTeeShirtSize());
   assertEquals(newDisplayName, profile.getDisplayName());
 }
コード例 #4
0
 @Test
 public void testSaveProfile() throws Exception {
   // Save the profile for the first time.
   Profile profile =
       conferenceApi.saveProfile(user, new ProfileForm(DISPLAY_NAME, TEE_SHIRT_SIZE));
   // Check the return value first.
   assertEquals(USER_ID, profile.getUserId());
   assertEquals(EMAIL, profile.getMainEmail());
   assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
   assertEquals(DISPLAY_NAME, profile.getDisplayName());
   // Fetch the Profile via Objectify.
   profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
   assertEquals(USER_ID, profile.getUserId());
   assertEquals(EMAIL, profile.getMainEmail());
   assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
   assertEquals(DISPLAY_NAME, profile.getDisplayName());
 }
コード例 #5
0
 @Test
 public void testSaveProfileWithNull() throws Exception {
   // Save the profile for the first time with null values.
   Profile profile = conferenceApi.saveProfile(user, new ProfileForm(null, null));
   String displayName = EMAIL.substring(0, EMAIL.indexOf("@"));
   // Check the return value first.
   assertEquals(USER_ID, profile.getUserId());
   assertEquals(EMAIL, profile.getMainEmail());
   assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
   assertEquals(displayName, profile.getDisplayName());
   // Fetch the Profile via Objectify.
   profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
   assertEquals(USER_ID, profile.getUserId());
   assertEquals(EMAIL, profile.getMainEmail());
   assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
   assertEquals(displayName, profile.getDisplayName());
 }