@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);
  }
示例#4
0
 /** Test of isUpdate method, of class Project. */
 @Test
 public void testIsUpdate() {
   try {
     System.out.println("isUpdate");
     Project instance = new Project();
     boolean expResult = false;
     boolean result = instance.isUpdate();
     assertEquals(expResult, result);
   } catch (Exception e) {
     fail("IsUpdate(), test failed");
   }
 }
示例#5
0
  /** Test of isCurrentBurndownChart method, of class Project. */
  @Test
  public void testIsCurrentBurndownChart() {
    try {
      System.out.println("isCurrentBurndownChart");
      Project instance = new Project();

      boolean result = instance.isCurrentBurndownChart();

    } catch (Exception e) {
      fail("IsCurrentBurndownChart(), exception");
    }
  }
示例#6
0
 /** Test of getUsers method, of class Project. */
 @Test
 public void testGetUsers() {
   try {
     System.out.println("getUsers");
     Project instance = new Project();
     instance.addUser("Jannie");
     Object[] result = instance.getUsers();
     if (!result[0].equals("Jannie")) fail("GetUsers(), test failed values not correct");
   } catch (Exception e) {
     fail("GetUsers(), test failed");
   }
 }
示例#7
0
 /** Test of dbUpdate method, of class Project. */
 @Test
 public void testDbUpdate() {
   try {
     System.out.println("dbUpdate");
     Project instance = new Project();
     instance.update = true;
     instance.dbUpdate();
     boolean expResult = false;
     boolean result = instance.isUpdate();
   } catch (Exception e) {
     fail("DbUpdate(), test failed");
   }
 }
示例#8
0
 /** Test of getRowCount method, of class Project. */
 @Test
 public void testGetRowCount() {
   try {
     System.out.println("getRowCount");
     Project instance = new Project();
     instance.setRowCount(1);
     int expResult = 1;
     int result = instance.getRowCount();
     assertEquals(expResult, result);
   } catch (Exception e) {
     fail("GetRowCount(), test failed");
   }
 }
示例#9
0
 /** Test of getBurndownPoints method, of class Project. */
 @Test
 public void testGetBurndownPoints() {
   try {
     System.out.println("getPreviousBurndownCharts");
     Project instance = new Project();
     ArrayList<Integer> tmp = new ArrayList<Integer>();
     tmp.add(0);
     instance.setBurndownPoints(tmp);
     ArrayList result = instance.getBurndownPoints();
   } catch (Exception e) {
     fail("testGetBurndownPoints exception thrown");
   }
 }
示例#10
0
  /** Test of getUsersNotOnProject method, of class Project. */
  @Test
  public void testGetUsersNotOnProject() {
    try {
      System.out.println("getUsersNotOnProject");
      Reference.usernames.add(new User("j", "j", "j", "j"));
      Reference.usernames.add(new User("k", "k", "k", "k"));
      Project instance = new Project();
      instance.addUser("j");

      String[] result = instance.getUsersNotOnProject();
      System.out.println(result[0]);
      for (int i = 0; i < result.length; i++) {
        if (result[i].equals("j")) fail("GetUsersNotOnProject(), value incorrect");
      }

    } catch (Exception e) {
      fail("GetUsersNotOnProject(), exception");
    }
  }
示例#11
0
  /** Test of getProjectStatus method, of class Project. */
  @Test
  public void testGetProjectStatus() {
    try {
      System.out.println("getProjectStatus");
      Project instance = new Project();
      instance.setId("112");
      Tasks t = new Tasks("1", "1");
      t.setProjectID("112");
      t.setStatus("inProgress");
      Reference.tasks = new ArrayList<Tasks>();
      Reference.tasks.add(t);
      String expResult = "In Progress";

      String result = instance.getProjectStatus();
      System.out.println("EXP result: " + expResult + "; " + result);
      assertEquals(expResult, result);
    } catch (Exception e) {
      fail("GetProjectStatus(), exception");
    }
  }
示例#12
0
  @Test
  public void testProjects() {
    try {
      // get row count of experiments in the dataset
      int expected = getDataSet().getTable("Project").getRowCount();

      // get number of experiments from the DAO
      int actual = getProjectDAO().count();

      // test data contains 2 experiments, check size of returned list
      TestCase.assertEquals("Wrong number of Project", expected, actual);

      System.out.println("Expected number of Project: " + expected + ", actual: " + actual);

      for (Project d : random(getProjectDAO(), actual, 5)) {
        TestCase.assertNotNull(d);
        TestCase.assertNotNull(d.getProjectId());
      }
    } catch (Exception e) {
      e.printStackTrace();
      TestCase.fail();
    }
  }
 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 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);
  }