MapStructAbstractGateway implements Gateway<DE, AP> { @Override public DE findById(String id) { Preconditions.checkArgument(!Strings.isNullOrEmpty(id), "id must not be null or empty"); HE hibernateEntity = dao.findById(id); return hibernateEntityToDomainEntityConverter.convert(hibernateEntity); } protected  MapStructAbstractGateway(
            Converter<AP, HE> domainAddPayloadToHibernateEntityConverter,
            Merger<DE, HE> domainEntityToHibernateEntityMerger,
            Converter<HE, DE> hibernateEntityToDomainEntityConverter,
            Converter<List<HE>, List<DE>> hibernateEntitiesToDomainEntitiesConverter,
            D dao
    ); DE add(AP payload); @Override List<DE> getAll(); @Override DE findById(String id); @Override DE save(String id, DE entity);  }
@Test public void whenFindById() { final String testId = "test.id"; TestHibernateEntity hibernateEntity = mock(TestHibernateEntity.class); when(dao.findById(testId)).thenReturn(hibernateEntity); TestDomainEntity domainEntity = mock(TestDomainEntity.class); when(hibernateEntityToDomainEntityConverter.convert(hibernateEntity)).thenReturn(domainEntity); TestDomainEntity actual = gateway.findById(testId); verify(dao).findById(testId); assertThat(actual).isSameAs(domainEntity); }