private boolean areIdentical(Trip one, Trip two) { return(one.id.equals(two.id) && one.title.equals(two.title) && one.duration==two.duration && one.priority==two.priority && areIdentical(one.startTime, two.startTime) && areIdentical(one.creationTime, two.creationTime) && areIdentical(one.updateTime, two.updateTime)); }
private void assertFlight(TripStore store, Flight flight) { List<Flight> results=store.findFlightsForTrip(flight.tripId); assertNotNull(results); assertEquals(1, results.size()); assertTrue(areFlightsIdentical(flight, results.get(0))); }
private void assertLodging(TripStore store, Lodging lodging) { List<Lodging> results=store.findLodgingsForTrip(lodging.tripId); assertNotNull(results); assertEquals(1, results.size()); assertTrue(areLodgingsIdentical(lodging, results.get(0))); }
@Test public void flights() { assertEquals(0, store.selectAllTrips().size()); final Trip trip=new Trip("Foo", 2880, Priority.LOW, new Date()); assertNotNull(trip.id); assertNotEquals(0, trip.id.length()); store.insert(trip); assertTrip(store, trip); final Flight first= new Flight("Northeast Airlines", 185, Priority.HIGH, new Date(), "PHL", "MCO", "NEA", "1734", "26B", trip.id); assertNotNull(first.id); assertNotEquals(0, first.id.length()); store.insert(first); assertFlight(store, first); store.delete(trip); assertEquals(0, store.findFlightsForTrip(trip.id).size()); }
@Test public void lodging() { assertEquals(0, store.selectAllTrips().size()); final Trip trip=new Trip("Foo", 2880, Priority.LOW, new Date()); assertNotNull(trip.id); assertNotEquals(0, trip.id.length()); store.insert(trip); assertTrip(store, trip); final Lodging first= new Lodging("Hotel Von", 2880, Priority.MEDIUM, new Date(), "1313 Mockingbird Lane", trip.id); assertNotNull(first.id); assertNotEquals(0, first.id.length()); store.insert(first); assertLodging(store, first); store.delete(trip); assertEquals(0, store.findLodgingsForTrip(trip.id).size()); }
@Test public void basics() { assertEquals(0, store.selectAllTrips().size()); final Trip first=new Trip("Foo", 2880, Priority.LOW, new Date()); assertNotNull(first.id); assertNotEquals(0, first.id.length()); store.insert(first); assertTrip(store, first); final Trip updated= new Trip(first.id, "Foo!!!", 1440, Priority.MEDIUM, first.startTime, first.creationTime, first.updateTime); store.update(updated); assertTrip(store, updated); store.delete(updated); assertEquals(0, store.selectAllTrips().size()); }
@Test public void notes() { final Trip trip=new Trip("Foo", 2880, Priority.LOW, new Date()); store.insert(trip); assertEquals(0, store.findCommentsForTrip(trip.id).size()); assertEquals(0, store.findLinksForTrip(trip.id).size()); assertEquals(0, store.findNotesForTrip(trip.id).size()); final Comment comment=new Comment("um, hi!", trip); store.insert(comment); assertEquals(1, store.findCommentsForTrip(trip.id).size()); assertEquals(0, store.findLinksForTrip(trip.id).size()); assertEquals(1, store.findNotesForTrip(trip.id).size()); assertTrue(areCommentsIdentical(store.findCommentsForTrip(trip.id).get(0), comment)); final Link link=new Link("Some page", "https://commonsware.com", trip); store.insert(link); assertEquals(1, store.findCommentsForTrip(trip.id).size()); assertEquals(1, store.findLinksForTrip(trip.id).size()); assertEquals(2, store.findNotesForTrip(trip.id).size()); store.delete(comment); assertEquals(0, store.findCommentsForTrip(trip.id).size()); assertEquals(1, store.findLinksForTrip(trip.id).size()); assertEquals(1, store.findNotesForTrip(trip.id).size()); assertTrue(areLinksIdentical(store.findLinksForTrip(trip.id).get(0), link)); }
@Test public void flights() { assertEquals(0, store.selectAllTrips().size()); final Trip trip=new Trip("Foo", 2880, Priority.LOW, new Date()); assertNotNull(trip.id); assertNotEquals(0, trip.id.length()); store.insert(trip); assertTrip(store, trip); final Flight first= new Flight("Northeast Airlines", 185, Priority.HIGH, new Date(), "PHL", "MCO", "NEA", "1734", "26B", trip.id); assertNotNull(first.id); assertNotEquals(0, first.id.length()); store.insert(first); assertFlight(store, first); store.delete(trip); assertEquals(0, store.findFlightsForTrip(trip.id).size()); }
@Test public void lodging() { assertEquals(0, store.selectAllTrips().size()); final Trip trip=new Trip("Foo", 2880, Priority.LOW, new Date()); assertNotNull(trip.id); assertNotEquals(0, trip.id.length()); store.insert(trip); assertTrip(store, trip); final Lodging first= new Lodging("Hotel Von", 2880, Priority.MEDIUM, new Date(), "1313 Mockingbird Lane", trip.id); assertNotNull(first.id); assertNotEquals(0, first.id.length()); store.insert(first); assertLodging(store, first); store.delete(trip); assertEquals(0, store.findLodgingsForTrip(trip.id).size()); }
@Test public void basics() { assertEquals(0, store.selectAllTrips().size()); final Trip first=new Trip("Foo", 2880, Priority.LOW, new Date()); assertNotNull(first.id); assertNotEquals(0, first.id.length()); store.insert(first); assertTrip(store, first); final Trip updated= new Trip(first.id, "Foo!!!", 1440, Priority.MEDIUM, first.startTime, first.creationTime, first.updateTime); store.update(updated); assertTrip(store, updated); store.delete(updated); assertEquals(0, store.selectAllTrips().size()); }
@Test public void notes() { final Trip trip=new Trip("Foo", 2880, Priority.LOW, new Date()); store.insert(trip); assertEquals(0, store.findCommentsForTrip(trip.id).size()); assertEquals(0, store.findLinksForTrip(trip.id).size()); assertEquals(0, store.findNotesForTrip(trip.id).size()); final Note comment=new Comment("um, hi!", trip); store.insert(comment); assertEquals(1, store.findCommentsForTrip(trip.id).size()); assertEquals(0, store.findLinksForTrip(trip.id).size()); assertEquals(1, store.findNotesForTrip(trip.id).size()); assertTrue(areCommentsIdentical(store.findCommentsForTrip(trip.id).get(0), (Comment)store.findNotesForTrip(trip.id).get(0))); final Note link=new Link("Some page", "https://commonsware.com", trip); store.insert(link); assertEquals(1, store.findCommentsForTrip(trip.id).size()); assertEquals(1, store.findLinksForTrip(trip.id).size()); assertEquals(2, store.findNotesForTrip(trip.id).size()); store.delete(comment); assertEquals(0, store.findCommentsForTrip(trip.id).size()); assertEquals(1, store.findLinksForTrip(trip.id).size()); assertEquals(1, store.findNotesForTrip(trip.id).size()); assertTrue(areLinksIdentical(store.findLinksForTrip(trip.id).get(0), (Link)store.findNotesForTrip(trip.id).get(0))); LiveData<PagedList<Link>> notes= new LivePagedListBuilder<>(store.pagedStuffForTrip(trip.id), 20) .build(); }
private boolean areIdentical(Plan one, Plan two) { return(one.id.equals(two.id) && one.title.equals(two.title) && one.duration==two.duration && one.priority==two.priority && areIdentical(one.startTime, two.startTime) && areIdentical(one.creationTime, two.creationTime) && areIdentical(one.updateTime, two.updateTime)); }
@Test public void flights() { assertEquals(0, store.selectAllTrips().size()); final Trip trip=new Trip("Foo", 2880, Priority.LOW, new Date()); assertNotNull(trip.id); assertNotEquals(0, trip.id.length()); store.insert(trip); assertTrip(store, trip); final Flight first= new Flight("Northeast Airlines", 185, Priority.HIGH, new Date(), "PHL", "MCO", "NEA", "1734", "26B", trip.id); assertNotNull(first.id); assertNotEquals(0, first.id.length()); store.insert(first); assertFlight(store, first); store.delete(trip); assertEquals(0, store.findFlightsForTrip(trip.id).size()); }
@Test public void lodging() { assertEquals(0, store.selectAllTrips().size()); final Trip trip=new Trip("Foo", 2880, Priority.LOW, new Date()); assertNotNull(trip.id); assertNotEquals(0, trip.id.length()); store.insert(trip); assertTrip(store, trip); final Lodging first= new Lodging("Hotel Von", 2880, Priority.MEDIUM, new Date(), "1313 Mockingbird Lane", trip.id); assertNotNull(first.id); assertNotEquals(0, first.id.length()); store.insert(first); assertLodging(store, first); store.delete(trip); assertEquals(0, store.findLodgingsForTrip(trip.id).size()); }
@Test public void basics() { assertEquals(0, store.selectAllTrips().size()); final Trip first=new Trip("Foo", 2880, Priority.LOW, new Date()); assertNotNull(first.id); assertNotEquals(0, first.id.length()); store.insert(first); assertTrip(store, first); final Trip updated= new Trip(first.id, "Foo!!!", 1440, Priority.MEDIUM, first.startTime, first.creationTime, first.updateTime); store.update(updated); assertTrip(store, updated); store.delete(updated); assertEquals(0, store.selectAllTrips().size()); }
private void assertLodging(TripStore store, Lodging lodging) { List<Lodging> results=store.findLodgingsForTrip(lodging.tripId); assertNotNull(results); assertEquals(1, results.size()); assertTrue(areLodgingsIdentical(lodging, results.get(0))); }
private void assertFlight(TripStore store, Flight flight) { List<Flight> results=store.findFlightsForTrip(flight.tripId); assertNotNull(results); assertEquals(1, results.size()); assertTrue(areFlightsIdentical(flight, results.get(0))); }
private boolean areIdentical(Plan one, Plan two) { return(one.id.equals(two.id) && one.title.equals(two.title) && one.duration==two.duration && one.priority==two.priority && areIdentical(one.startTime, two.startTime) && areIdentical(one.creationTime, two.creationTime) && areIdentical(one.updateTime, two.updateTime)); }
@Test public void flights() { assertEquals(0, store.selectAllTrips().size()); final Trip trip=new Trip("Foo", 2880, Priority.LOW, new Date()); assertNotNull(trip.id); assertNotEquals(0, trip.id.length()); store.insert(trip); assertTrip(store, trip); final Flight first= new Flight("Northeast Airlines", 185, Priority.HIGH, new Date(), "PHL", "MCO", "NEA", "1734", "26B", trip.id); assertNotNull(first.id); assertNotEquals(0, first.id.length()); store.insert(first); assertFlight(store, first); store.delete(trip); assertEquals(0, store.findFlightsForTrip(trip.id).size()); }
@Test public void lodging() { assertEquals(0, store.selectAllTrips().size()); final Trip trip=new Trip("Foo", 2880, Priority.LOW, new Date()); assertNotNull(trip.id); assertNotEquals(0, trip.id.length()); store.insert(trip); assertTrip(store, trip); final Lodging first= new Lodging("Hotel Von", 2880, Priority.MEDIUM, new Date(), "1313 Mockingbird Lane", trip.id); assertNotNull(first.id); assertNotEquals(0, first.id.length()); store.insert(first); assertLodging(store, first); store.delete(trip); assertEquals(0, store.findLodgingsForTrip(trip.id).size()); }