@Test public void addJourneyToApplication() { service.createApplicationNamed(TEST_APP); service.addJourneyTo(TEST_APP, "j", 12, 14); Application found = new ApplicationDao().findByName(TEST_APP); assertTrue(found.getJourneys().iterator().hasNext()); }
@Test public void canAddJoruinesToApplication() { Application found = dao.findByName(TEST_APP); Journey j = new Journey("j", 12, 4); found.add(j); dao.update(found); Application updated = dao.findByName(TEST_APP); assertTrue(updated.getJourneys().iterator().hasNext()); }
@Test public void canRemoveJourneyFromApplication() { Application found = dao.findByName(TEST_APP); found.add(new Journey("j1", 12, 4)); found.add(new Journey("j2", 12, 4)); dao.update(found); Application toDeleteFrom = dao.findByName(TEST_APP); toDeleteFrom.removeJourneNamed("j2"); dao.update(found); }
@Test public void removingJourneysFromOneApplicaionDoesNotRemoveFromTheOther() { Application a = new Application("second"); a.add(new Journey("j1", 2, 3)); a.add(new Journey("j2", 2, 3)); dao.create(a); Application found = dao.findByName(TEST_APP); found.add(new Journey("j1", 2, 3)); found.add(new Journey("j2", 2, 3)); dao.update(found); Application found2 = dao.findByName("second"); found2.removeJourneNamed("j2"); dao.update(found2); found = dao.findByName(TEST_APP); found2 = dao.findByName("second"); assertEquals(2, found.journeyCount()); assertEquals(1, found2.journeyCount()); }