예제 #1
0
  @Test
  public void create() throws AppException {
    SampleEntity sample = createSampleEntity(ID, "IPI");
    Mockito.when(repository.save(sample)).thenReturn(createSampleEntity(ID, "IPI"));

    SampleEntity newSample = service.create(sample);

    Mockito.verify(repository).save(sample);
    MatcherAssert.assertThat(newSample.id, Matchers.equalTo(ID));
  }
예제 #2
0
 @Test(expected = AppException.class)
 public void createWithError() throws AppException {
   when(repository.save(createSampleEntity(ID, null)))
       .thenThrow(new IllegalArgumentException("Error"));
   service.create(createSampleEntity(ID, null));
 }