### Question:
TripItAdapter implements ApiAdapter<TripIt> { public UserProfile fetchUserProfile(TripIt tripit) { TripItProfile profile = tripit.getUserProfile(); return new UserProfileBuilder().setName(profile.getPublicDisplayName()).setEmail(profile.getEmailAddress()).setUsername(profile.getScreenName()).build(); }  boolean test(TripIt tripit); void setConnectionValues(TripIt tripit, ConnectionValues values); UserProfile fetchUserProfile(TripIt tripit); void updateStatus(TripIt tripit, String message);  }### Answer:
@Test public void fetchProfile() { Mockito.when(tripit.getUserProfile()).thenReturn(new TripItProfile("habuma", "habuma", "Craig Walls", "cwalls@vmware.com", "Plano, TX", "SpringSource", "people/habuma", "https: UserProfile profile = apiAdapter.fetchUserProfile(tripit); assertEquals("Craig Walls", profile.getName()); assertEquals("Craig", profile.getFirstName()); assertEquals("Walls", profile.getLastName()); assertEquals("cwalls@vmware.com", profile.getEmail()); assertEquals("habuma", profile.getUsername()); }
@Test public void fetchProfileFirstNameOnly() { Mockito.when(tripit.getUserProfile()).thenReturn(new TripItProfile("habuma", "habuma", "Craig", "cwalls@vmware.com", "Plano, TX", "SpringSource", "people/habuma", "https: UserProfile profile = apiAdapter.fetchUserProfile(tripit); assertEquals("Craig", profile.getName()); assertEquals("Craig", profile.getFirstName()); assertNull(profile.getLastName()); assertEquals("cwalls@vmware.com", profile.getEmail()); assertEquals("habuma", profile.getUsername()); }
@Test public void fetchProfileMiddleName() { Mockito.when(tripit.getUserProfile()).thenReturn(new TripItProfile("habuma", "habuma", "Michael Craig Walls", "cwalls@vmware.com", "Plano, TX", "SpringSource", "people/habuma", "https: UserProfile profile = apiAdapter.fetchUserProfile(tripit); assertEquals("Michael Craig Walls", profile.getName()); assertEquals("Michael", profile.getFirstName()); assertEquals("Walls", profile.getLastName()); assertEquals("cwalls@vmware.com", profile.getEmail()); assertEquals("habuma", profile.getUsername()); }
@Test public void fetchProfileExtraWhitespace() { Mockito.when(tripit.getUserProfile()).thenReturn(new TripItProfile("habuma", "habuma", "Michael Craig Walls", "cwalls@vmware.com", "Plano, TX", "SpringSource", "people/habuma", "https: UserProfile profile = apiAdapter.fetchUserProfile(tripit); assertEquals("Michael Craig Walls", profile.getName()); assertEquals("Michael", profile.getFirstName()); assertEquals("Walls", profile.getLastName()); assertEquals("cwalls@vmware.com", profile.getEmail()); assertEquals("habuma", profile.getUsername()); }