@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)); }
@Test(expected = AppException.class) public void editWithError() throws AppException { when(repository.edit(createSampleEntity(ID, null))) .thenThrow(new IllegalArgumentException("Error")); service.edit(createSampleEntity(ID, null)); }