@Test void testGetThrowsException() { Fetch idAttributeFetch = new Fetch().field(entityType.getIdAttribute().getName()); Query<Entity> fetchLessQuery = new QueryImpl<>().eq(COUNTRY, "NL").fetch(idAttributeFetch); when(decoratedRepository.findAll(fetchLessQuery)) .thenThrow(new MolgenisDataException("What table?")); Fetch fetch = mock(Fetch.class); Query<Entity> query = new QueryImpl<>().eq(COUNTRY, "NL").fetch(fetch); try { l3Cache.get(decoratedRepository, query); fail("Get should throw exception"); } catch (UncheckedExecutionException expected) { } try { l3Cache.get(decoratedRepository, query); fail("Get should throw exception"); } catch (UncheckedExecutionException expected) { } verify(decoratedRepository, times(2)).findAll(fetchLessQuery); }
public List<Object> get(Repository<Entity> repository, Query<Entity> query) { LoadingCache<Query<Entity>, List<Object>> cache = getQueryCache(repository); Query<Entity> fetchlessQuery = new QueryImpl<>(query); fetchlessQuery.setFetch(null); return cache.getUnchecked(fetchlessQuery); }
L3Cache implements TransactionListener { public List<Object> get(Repository<Entity> repository, Query<Entity> query) { LoadingCache<Query<Entity>, List<Object>> cache = getQueryCache(repository); Query<Entity> fetchlessQuery = new QueryImpl<>(query); fetchlessQuery.setFetch(null); return cache.getUnchecked(fetchlessQuery); } }
L3Cache implements TransactionListener { public List<Object> get(Repository<Entity> repository, Query<Entity> query) { LoadingCache<Query<Entity>, List<Object>> cache = getQueryCache(repository); Query<Entity> fetchlessQuery = new QueryImpl<>(query); fetchlessQuery.setFetch(null); return cache.getUnchecked(fetchlessQuery); } L3Cache(
      TransactionManager transactionManager,
      TransactionInformation transactionInformation,
      MeterRegistry meterRegistry); }
L3Cache implements TransactionListener { public List<Object> get(Repository<Entity> repository, Query<Entity> query) { LoadingCache<Query<Entity>, List<Object>> cache = getQueryCache(repository); Query<Entity> fetchlessQuery = new QueryImpl<>(query); fetchlessQuery.setFetch(null); return cache.getUnchecked(fetchlessQuery); } L3Cache(
      TransactionManager transactionManager,
      TransactionInformation transactionInformation,
      MeterRegistry meterRegistry); @Override void afterCommitTransaction(String transactionId); List<Object> get(Repository<Entity> repository, Query<Entity> query); @Scheduled(fixedRate = 60000) void logStatistics(); }
L3Cache implements TransactionListener { public List<Object> get(Repository<Entity> repository, Query<Entity> query) { LoadingCache<Query<Entity>, List<Object>> cache = getQueryCache(repository); Query<Entity> fetchlessQuery = new QueryImpl<>(query); fetchlessQuery.setFetch(null); return cache.getUnchecked(fetchlessQuery); } L3Cache(
      TransactionManager transactionManager,
      TransactionInformation transactionInformation,
      MeterRegistry meterRegistry); @Override void afterCommitTransaction(String transactionId); List<Object> get(Repository<Entity> repository, Query<Entity> query); @Scheduled(fixedRate = 60000) void logStatistics();  }