@Test public void whenGetByIdWithExistingIdItShouldReturnEntity() throws EntityNotFoundException { when(gateway.findById(TEST_ID)).thenReturn(domainEntity); TestEntity actual = service.getById(TEST_ID); verify(gateway).findById(TEST_ID); verifyNoMoreInteractions(gateway); assertThat(actual).isSameAs(domainEntity); }
public DE getById(String id) throws EntityNotFoundException { DE entity = gateway.findById(id); if (entity == null) { throw new EntityNotFoundException(domainEntityClass, id); } return entity; }
AbstractEntityService { public DE getById(String id) throws EntityNotFoundException { DE entity = gateway.findById(id); if (entity == null) { throw new EntityNotFoundException(domainEntityClass, id); } return entity; } }
AbstractEntityService { public DE getById(String id) throws EntityNotFoundException { DE entity = gateway.findById(id); if (entity == null) { throw new EntityNotFoundException(domainEntityClass, id); } return entity; } protected  AbstractEntityService(Class<DE> domainEntityClass, G gateway); }
AbstractEntityService { public DE getById(String id) throws EntityNotFoundException { DE entity = gateway.findById(id); if (entity == null) { throw new EntityNotFoundException(domainEntityClass, id); } return entity; } protected  AbstractEntityService(Class<DE> domainEntityClass, G gateway); DE add(AP addPayload); DE getById(String id); List<DE> getAll(); }
AbstractEntityService { public DE getById(String id) throws EntityNotFoundException { DE entity = gateway.findById(id); if (entity == null) { throw new EntityNotFoundException(domainEntityClass, id); } return entity; } protected  AbstractEntityService(Class<DE> domainEntityClass, G gateway); DE add(AP addPayload); DE getById(String id); List<DE> getAll();  }