private boolean areEqual(Project a, Project b, boolean compareIDs) { if (compareIDs) { if (a.getId() != b.getId()) { return false; } } return (safeEquals(a.getTitle(), b.getTitle()) && safeEquals(a.getRecordsperimage(), b.getRecordsperimage()) && safeEquals(a.getFirstycoord(), b.getFirstycoord()) && safeEquals(a.getRecordheight(), b.getRecordheight()) && safeEquals(a.getNumfields(), b.getNumfields())); }
@Test public void testAdd() 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); List<Project> all = dbProjects.getAll(); assertEquals(2, all.size()); boolean foundAge = false; boolean foundPlace = false; for (Project p : all) { assertFalse(p.getId() == -1); if (!foundAge) { foundAge = areEqual(p, census, false); } if (!foundPlace) { foundPlace = areEqual(p, births, false); } } assertTrue(foundAge && foundPlace); }
@Test public void testGetNumFields() throws DatabaseException { Project census = new Project("census", 2, 3, 4, 5); dbProjects.add(census); assertEquals(dbProjects.getNumFields(census.getId()), 5); }
@Test public void testGetRecsPerImage() throws DatabaseException { Project census = new Project("census", 2, 3, 4, 5); dbProjects.add(census); assertEquals(dbProjects.getRecsPerImage(census.getId()), 2); }