Ejemplo n.º 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));
  }
Ejemplo n.º 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));
 }