@Test void testFindOneRepositoryClean() { when(transactionInformation.isRepositoryCompletelyClean(entityType)).thenReturn(true); Query<Entity> queryWithPageSizeOne = new QueryImpl<>(query).pageSize(1); when(l3Cache.get(delegateRepository, queryWithPageSizeOne)).thenReturn(singletonList(3)); when(delegateRepository.findOneById(3, fetch)).thenReturn(entity3); assertEquals(entity3, l3CacheRepositoryDecorator.findOne(queryWithPageSizeOne)); verify(delegateRepository, times(1)).findOneById(3, fetch); verify(delegateRepository, atLeast(0)).getEntityType(); verifyNoMoreInteractions(delegateRepository); }
@Override public Entity findOne(Query<Entity> query) { if (transactionInformation.isRepositoryCompletelyClean(getEntityType()) && cacheable) { QueryImpl<Entity> cacheKey = new QueryImpl<>(query).setPageSize(1); List<Object> ids = l3Cache.get(delegate(), cacheKey); if (ids.isEmpty()) { return null; } return delegate().findOneById(ids.get(0), query.getFetch()); } return delegate().findOne(query); }
L3CacheRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Entity findOne(Query<Entity> query) { if (transactionInformation.isRepositoryCompletelyClean(getEntityType()) && cacheable) { QueryImpl<Entity> cacheKey = new QueryImpl<>(query).setPageSize(1); List<Object> ids = l3Cache.get(delegate(), cacheKey); if (ids.isEmpty()) { return null; } return delegate().findOneById(ids.get(0), query.getFetch()); } return delegate().findOne(query); } }
L3CacheRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Entity findOne(Query<Entity> query) { if (transactionInformation.isRepositoryCompletelyClean(getEntityType()) && cacheable) { QueryImpl<Entity> cacheKey = new QueryImpl<>(query).setPageSize(1); List<Object> ids = l3Cache.get(delegate(), cacheKey); if (ids.isEmpty()) { return null; } return delegate().findOneById(ids.get(0), query.getFetch()); } return delegate().findOne(query); } L3CacheRepositoryDecorator(
      Repository<Entity> delegateRepository,
      L3Cache l3Cache,
      TransactionInformation transactionInformation); }
L3CacheRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Entity findOne(Query<Entity> query) { if (transactionInformation.isRepositoryCompletelyClean(getEntityType()) && cacheable) { QueryImpl<Entity> cacheKey = new QueryImpl<>(query).setPageSize(1); List<Object> ids = l3Cache.get(delegate(), cacheKey); if (ids.isEmpty()) { return null; } return delegate().findOneById(ids.get(0), query.getFetch()); } return delegate().findOne(query); } L3CacheRepositoryDecorator(
      Repository<Entity> delegateRepository,
      L3Cache l3Cache,
      TransactionInformation transactionInformation); @Override Stream<Entity> findAll(Query<Entity> query); @Override Entity findOne(Query<Entity> query); }
L3CacheRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Entity findOne(Query<Entity> query) { if (transactionInformation.isRepositoryCompletelyClean(getEntityType()) && cacheable) { QueryImpl<Entity> cacheKey = new QueryImpl<>(query).setPageSize(1); List<Object> ids = l3Cache.get(delegate(), cacheKey); if (ids.isEmpty()) { return null; } return delegate().findOneById(ids.get(0), query.getFetch()); } return delegate().findOne(query); } L3CacheRepositoryDecorator(
      Repository<Entity> delegateRepository,
      L3Cache l3Cache,
      TransactionInformation transactionInformation); @Override Stream<Entity> findAll(Query<Entity> query); @Override Entity findOne(Query<Entity> query);  }