topics.add("Google");
topics.add("Cloud");
topics.add("Platform");
ConferenceForm conferenceForm = new ConferenceForm(
NAME, DESCRIPTION, topics, CITY, startDate, endDate, CAP);
Conference conference = conferenceApi.createConference(user, conferenceForm);
// Registration
Boolean result = conferenceApi.registerForConference(
user, conference.getWebsafeKey()).getResult();
conference = conferenceApi.getConference(conference.getWebsafeKey());
Profile profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
assertTrue("registerForConference should succeed.", result);
assertEquals(CAP - 1, conference.getSeatsAvailable());
assertTrue("Profile should have the conferenceId in conferenceIdsToAttend.",
profile.getConferenceKeysToAttend().contains(conference.getWebsafeKey()));
// Unregister
result = conferenceApi.unregisterFromConference(
user, conference.getWebsafeKey()).getResult();
conference = conferenceApi.getConference(conference.getWebsafeKey());
profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
assertTrue("unregisterFromConference should succeed.", result);
assertEquals(CAP, conference.getSeatsAvailable());
assertFalse("Profile shouldn't have the conferenceId in conferenceIdsToAttend.",
profile.getConferenceKeysToAttend().contains(conference.getWebsafeKey()));
}