@Test public void testRegistrations() throws Exception { DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); Date startDate = dateFormat.parse("03/25/2014"); Date endDate = dateFormat.parse("03/26/2014"); List<String> topics = new ArrayList<>(); 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); Long conferenceId = conference.getId(); // 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())); }
@Test public void testGetConference() throws Exception { DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); Date startDate = dateFormat.parse("03/25/2014"); Date endDate = dateFormat.parse("03/26/2014"); List<String> topics = new ArrayList<>(); 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); conference = conferenceApi.getConference(conference.getWebsafeKey()); // Check the return value. assertEquals(NAME, conference.getName()); assertEquals(DESCRIPTION, conference.getDescription()); assertEquals(topics, conference.getTopics()); // assertEquals(USER_ID, conference.getOrganizerGplusId()); assertEquals(CITY, conference.getCity()); assertEquals(startDate, conference.getStartDate()); assertEquals(endDate, conference.getEndDate()); assertEquals(CAP, conference.getMaxAttendees()); assertEquals(CAP, conference.getSeatsAvailable()); assertEquals(MONTH, conference.getMonth()); }
@Test public void testCreateConference() throws Exception { DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); Date startDate = dateFormat.parse("03/25/2014"); Date endDate = dateFormat.parse("03/26/2014"); List<String> topics = new ArrayList<>(); 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); // Check the return value. assertEquals(NAME, conference.getName()); assertEquals(DESCRIPTION, conference.getDescription()); assertEquals(topics, conference.getTopics()); // assertEquals(USER_ID, conference.getOrganizerGplusId()); assertEquals(CITY, conference.getCity()); assertEquals(startDate, conference.getStartDate()); assertEquals(endDate, conference.getEndDate()); assertEquals(CAP, conference.getMaxAttendees()); assertEquals(CAP, conference.getSeatsAvailable()); assertEquals(MONTH, conference.getMonth()); // Check if a new Profile is created 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()); String displayName = EMAIL.substring(0, EMAIL.indexOf("@")); assertEquals(displayName, profile.getDisplayName()); }