Пример #1
0
  @Test
  public void testUpdateInstitution() {
    Institution newInst = mock(Institution.class);
    Institution updateInstitution = mock(Institution.class);

    when(newInst.getName()).thenReturn("newInst");
    when(newInst.getCountry()).thenReturn("paisInstitucion");

    when(updateInstitution.getName()).thenReturn("updateInstitucion");
    when(updateInstitution.getCountry()).thenReturn("paisInstitucion");

    try {
      when(institutionDAO.getInstitutionByName("updateInstitucion")).thenReturn(updateInstitution);
      institutionService.updateInstitution(newInst, "validToken");

      verify(institutionDAO).updateInstitution(newInst);
    } catch (InvalidInstitutionException e) {
      Assert.fail();
    } catch (AuthenticationException e) {
      Assert.fail();
    } catch (NullParameterException e) {
      Assert.fail();
    } catch (InstitutionNotFoundException e) {
      Assert.fail();
    }
  }
Пример #2
0
 @Test
 public void testDeleteInstitutionWithoutPermissions() {
   Institution deleteInstitution = mock(Institution.class);
   when(deleteInstitution.getName()).thenReturn("borrarInstitucion");
   when(deleteInstitution.getCountry()).thenReturn("paisInstitucion");
   try {
     when(institutionDAO.getInstitutionByName("delete")).thenReturn(deleteInstitution);
     institutionService.deleteInstitution(deleteInstitution, "invalidToken");
     Assert.fail();
   } catch (AuthenticationException e) {
     Assert.assertTrue(true);
   } catch (InstitutionNotFoundException e) {
     Assert.fail();
   } catch (InvalidInstitutionException e) {
     Assert.fail();
   }
 }