コード例 #1
0
 public void testAddExistingRepresentative() throws Exception {
   patientDAO.addRepresentative(1L, 2L);
   try {
     patientDAO.addRepresentative(1L, 2L);
     fail("exception should have been thrown");
   } catch (iTrustException e) {
     assertEquals("Patient 1 already represents patient 2", e.getMessage());
   }
 }
コード例 #2
0
  public void testRemoveAllRepresented() throws Exception {
    // 2 represents 1, but not 4
    gen.patient1();
    gen.patient4();

    // Add patient 4 to be represented by patient 2
    patientDAO.addRepresentative(2L, 4L);

    // Ensure the representatives were added correctly
    assertEquals(2, patientDAO.getRepresented(2L).size());

    // Remove all patient's from being represented by patient 2
    patientDAO.removeAllRepresented(2L);
    // Assert that no more patients are represented by patient 2
    assertTrue(patientDAO.getRepresented(2L).isEmpty());

    // Test with an evil factory
    patientDAO = new PatientDAO(EvilDAOFactory.getEvilInstance());

    try {
      patientDAO.removeAllRepresented(2L);
      fail("Exception should be caught");
    } catch (DBException e) {
      // Successful test
    }
  }
コード例 #3
0
 public void testAddRepresentative() throws Exception {
   assertEquals(0, patientDAO.getRepresented(1L).size());
   patientDAO.addRepresentative(1L, 2L);
   assertEquals(1, patientDAO.getRepresented(1L).size());
 }