@Test public void findByIdShouldThrowExceptionWhenNotPresent() throws Exception { String processInstanceId = "5"; given(repository.findById(processInstanceId)).willReturn(Optional.empty()); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Error"); entityFinder.findById(repository, processInstanceId, "Error"); }
public <T, ID> T findById(CrudRepository<T, ID> repository, ID id, String notFoundMessage) { Optional<T> findResult = repository.findById(id); return getEntity(findResult, notFoundMessage); }
EntityFinder { public <T, ID> T findById(CrudRepository<T, ID> repository, ID id, String notFoundMessage) { Optional<T> findResult = repository.findById(id); return getEntity(findResult, notFoundMessage); } }
EntityFinder { public <T, ID> T findById(CrudRepository<T, ID> repository, ID id, String notFoundMessage) { Optional<T> findResult = repository.findById(id); return getEntity(findResult, notFoundMessage); }  }
EntityFinder { public <T, ID> T findById(CrudRepository<T, ID> repository, ID id, String notFoundMessage) { Optional<T> findResult = repository.findById(id); return getEntity(findResult, notFoundMessage); }  T findById(CrudRepository<T, ID> repository,
                              ID id,
                              String notFoundMessage); T findOne(QuerydslPredicateExecutor<T> predicateExecutor,
                         Predicate predicate,
                         String notFoundMessage); }
EntityFinder { public <T, ID> T findById(CrudRepository<T, ID> repository, ID id, String notFoundMessage) { Optional<T> findResult = repository.findById(id); return getEntity(findResult, notFoundMessage); }  T findById(CrudRepository<T, ID> repository,
                              ID id,
                              String notFoundMessage); T findOne(QuerydslPredicateExecutor<T> predicateExecutor,
                         Predicate predicate,
                         String notFoundMessage);  }