Testing a Persistence Adapter with Integration Tests
For a similar reason, it makes sense to cover persistence adapters with integration tests instead of unit tests, since we not only want to verify the logic within the adapter, but also the mapping into the database.
We want to test the persistence adapter we built in Chapter 6, Implementing a Persistence Adapter. The adapter has two methods, one for loading an Account entity from the database and another to save new account activities to the database:
@DataJpaTest
@Import({AccountPersistenceAdapter.class, AccountMapper.class})
class AccountPersistenceAdapterTest {
  @Autowired
  private AccountPersistenceAdapter adapterUnderTest;
 Â
  @Autowired
  private ActivityRepository activityRepository;
  @Test
  @Sql("AccountPersistenceAdapterTest.sql")
  void loadsAccount() {
    Account account = adapter.loadAccount(
     ...