ApiKeyRepositoryWrapper implements ApiKeyRepository { @Override public List<ApiKey> findByCriteria(ApiKeyCriteria filter) throws TechnicalException { return wrapped.findByCriteria(filter); } ApiKeyRepositoryWrapper(ApiKeyRepository wrapped, Ehcache cache); @Override Optional<ApiKey> findById(String apiKey); @Override ApiKey create(ApiKey apiKey); @Override Set<ApiKey> findBySubscription(String subscription); @Override Set<ApiKey> findByPlan(String plan); @Override List<ApiKey> findByCriteria(ApiKeyCriteria filter); @Override ApiKey update(ApiKey apiKey);  }
@Test public void shouldFindByCriteria() throws TechnicalException { ApiKeyCriteria apiKeyCriteria = Mockito.mock(ApiKeyCriteria.class); List<ApiKey> mockApiKeys = Arrays.asList(Mockito.mock(ApiKey.class), Mockito.mock(ApiKey.class)); Mockito.when(wrappedRepository.findByCriteria(apiKeyCriteria)).thenReturn(mockApiKeys); List<ApiKey> apiKeys = repository.findByCriteria(apiKeyCriteria); Assert.assertEquals(mockApiKeys, apiKeys); }