@Test public void testAddActivity() { User marge = pacemaker.getUserByEmail("*****@*****.**"); Activity activity = pacemaker.createActivity( marge.id, activities[0].type, activities[0].location, activities[0].distance); Activity returnedActivity = pacemaker.getActivity(activity.id); assertEquals(activities[0], returnedActivity); assertNotSame(activities[0], returnedActivity); }
@Test public void testPopulate() { pacemaker = new PacemakerAPI(null); assertEquals(0, pacemaker.getUsers().size()); populate(pacemaker); assertEquals(users.length, pacemaker.getUsers().size()); assertEquals(2, pacemaker.getUserByEmail(users[0].email).activities.size()); assertEquals(2, pacemaker.getUserByEmail(users[1].email).activities.size()); Long activityID = pacemaker.getUserByEmail(users[0].email).activities.keySet().iterator().next(); assertEquals(locations.length, pacemaker.getActivity(activityID).route.size()); }
@Test public void testAddActivityWithSingleLocation() { User marge = pacemaker.getUserByEmail("*****@*****.**"); Long activityId = pacemaker.createActivity( marge.id, activities[0].type, activities[0].location, activities[0].distance) .id; pacemaker.addLocation(activityId, locations[0].latitude, locations[0].longitude); Activity activity = pacemaker.getActivity(activityId); assertEquals(1, activity.route.size()); assertEquals(0.0001, locations[0].latitude, activity.route.get(0).latitude); assertEquals(0.0001, locations[0].longitude, activity.route.get(0).longitude); }
@Test public void testAddActivityWithMultipleLocation() { User marge = pacemaker.getUserByEmail("*****@*****.**"); Long activityId = pacemaker.createActivity( marge.id, activities[0].type, activities[0].location, activities[0].distance) .id; for (Location location : locations) { pacemaker.addLocation(activityId, location.latitude, location.longitude); } Activity activity = pacemaker.getActivity(activityId); assertEquals(locations.length, activity.route.size()); int i = 0; for (Location location : activity.route) { assertEquals(location, locations[i]); i++; } }