コード例 #1
0
  /**
   * Test the {@link EarlyAlertSuggestionServiceImpl#get(UUID)} method.
   *
   * @throws ObjectNotFoundException Should not be thrown in this test since it uses mocked objects.
   */
  @Test
  public void testGet() throws ObjectNotFoundException {
    final UUID id = UUID.randomUUID();
    final EarlyAlertSuggestion daoOne = new EarlyAlertSuggestion(id);

    expect(dao.get(id)).andReturn(daoOne);

    replay(dao);

    assertNotNull("Get method should have returned a non-null instance.", service.get(id));
    verify(dao);
  }
コード例 #2
0
  /**
   * Test the {@link EarlyAlertSuggestionServiceImpl#save(EarlyAlertSuggestion)} method.
   *
   * @throws ObjectNotFoundException Should not be thrown in this test since it uses mocked objects.
   * @throws ValidationException If there were any validation errors.
   */
  @Test
  public void testSave() throws ObjectNotFoundException, ValidationException {
    final UUID id = UUID.randomUUID();
    final EarlyAlertSuggestion daoOne = new EarlyAlertSuggestion(id);

    expect(dao.save(daoOne)).andReturn(daoOne);

    replay(dao);

    assertNotNull("Save method return model should not have been null.", service.save(daoOne));
    verify(dao);
  }
コード例 #3
0
  /** Test the {@link EarlyAlertSuggestionServiceImpl#getAll(SortingAndPaging)} method. */
  @Test
  public void testGetAll() {
    final List<EarlyAlertSuggestion> daoAll = new ArrayList<EarlyAlertSuggestion>();
    daoAll.add(new EarlyAlertSuggestion());

    expect(dao.getAll(isA(SortingAndPaging.class)))
        .andReturn(new PagingWrapper<EarlyAlertSuggestion>(daoAll));

    replay(dao);

    final Collection<EarlyAlertSuggestion> all =
        service.getAll(new SortingAndPaging(ObjectStatus.ACTIVE)).getRows();
    assertFalse("List should not have been empty.", all.isEmpty());
    verify(dao);
  }
コード例 #4
0
  /**
   * Test the {@link EarlyAlertSuggestionServiceImpl#delete(UUID)} method.
   *
   * @throws ObjectNotFoundException Should not be thrown in this test since it uses mocked objects.
   */
  @Test
  public void testDelete() throws ObjectNotFoundException {
    final UUID id = UUID.randomUUID();
    final EarlyAlertSuggestion daoOne = new EarlyAlertSuggestion(id);

    expect(dao.get(id)).andReturn(daoOne);
    expect(dao.save(daoOne)).andReturn(daoOne);
    expect(dao.get(id)).andThrow(new ObjectNotFoundException(id, "EarlyAlertSuggestion"));

    replay(dao);

    service.delete(id);

    try {
      final EarlyAlertSuggestion daoTwo = service.get(id);
      assertNull("Recently deleted object should not have been able to be reloaded.", daoTwo);
    } catch (final ObjectNotFoundException e) {
      // expected exception
      assertNotNull(
          "Recently deleted object should not have been found when attempting to reload.", e);
    }

    verify(dao);
  }