Пример #1
0
  @Test
  public void edit() throws AppException {
    SampleEntity sample = createSampleEntity(ID, "IPI");
    Mockito.when(repository.edit(sample)).thenReturn(createSampleEntity(ID, null));

    SampleEntity newSample = service.edit(sample);

    Mockito.verify(repository).edit(sample);
    Mockito.verify(validator).validate(sample);
    MatcherAssert.assertThat(newSample.id, Matchers.equalTo(ID));
  }
Пример #2
0
 @Test(expected = AppException.class)
 public void editWithError() throws AppException {
   when(repository.edit(createSampleEntity(ID, null)))
       .thenThrow(new IllegalArgumentException("Error"));
   service.edit(createSampleEntity(ID, null));
 }