コード例 #1
0
  @Test
  public void testGetNumFields() throws DatabaseException {
    Project census = new Project("census", 2, 3, 4, 5);
    dbProjects.add(census);

    assertEquals(dbProjects.getNumFields(census.getId()), 5);
  }
コード例 #2
0
  @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);
  }
コード例 #3
0
  @Test
  public void testGetRecsPerImage() throws DatabaseException {
    Project census = new Project("census", 2, 3, 4, 5);
    dbProjects.add(census);

    assertEquals(dbProjects.getRecsPerImage(census.getId()), 2);
  }
コード例 #4
0
  @Test
  public void testDelete() 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());

    dbProjects.delete(census);
    dbProjects.delete(births);

    all = dbProjects.getAll();
    assertEquals(0, all.size());
  }
コード例 #5
0
  @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);
  }
コード例 #6
0
  @Test
  public void testGetAll() throws DatabaseException {

    List<Project> all = dbProjects.getAll();
    assertEquals(0, all.size());
  }
コード例 #7
0
  @Test(expected = DatabaseException.class)
  public void testInvalidDelete() throws DatabaseException {

    Project invalidProject = new Project(null, -1, -1, -1, -1);
    dbProjects.delete(invalidProject);
  }