@Test public void testUpdate() throws DatabaseException { Project census = new Project("census", 2, 3, 4, 5); Project births = new Project("births", 6, 7, 8, 9); dbProjects.add(census); dbProjects.add(births); census.setTitle("CENSUS"); census.setRecordsperimage(3); census.setFirstycoord(4); census.setRecordheight(5); census.setNumfields(6); births.setTitle("BIRTHS"); births.setRecordsperimage(7); births.setFirstycoord(8); births.setRecordheight(9); births.setNumfields(10); dbProjects.update(census); dbProjects.update(births); List<Project> all = dbProjects.getAll(); assertEquals(2, all.size()); boolean foundAge = false; boolean foundPlace = false; for (Project p : all) { if (!foundAge) { foundAge = areEqual(p, census, false); } if (!foundPlace) { foundPlace = areEqual(p, births, false); } } assertTrue(foundAge && foundPlace); }
@Test(expected = DatabaseException.class) public void testInvalidUpdate() throws DatabaseException { Project invalidProject = new Project(null, -1, -1, -1, -1); dbProjects.update(invalidProject); }