ElasticSearchQuotaSearcher implements QuotaSearcher { @Override public List<Username> search(QuotaQuery query) { try { return searchHits(query) .map(SearchHit::getId) .map(Username::of) .collect(Guavate.toImmutableList()) .block(); } catch (Exception e) { throw new RuntimeException("Unexpected exception while executing " + query, e); } } ElasticSearchQuotaSearcher(ReactorElasticSearchClient client, ReadAliasName readAlias); @Override List<Username> search(QuotaQuery query);  }
@Test void searchShouldNotBeLimitedByElasticSearchDefaultSearchLimit(QuotaSearchTestSystem testSystem) throws Exception { int userCount = 11; testSystem.getDomainList().addDomain(SIMPSON_COM); testSystem.getMaxQuotaManager().setGlobalMaxStorage(QuotaSizeLimit.size(100)); IntStream.range(0, userCount) .boxed() .map(i -> Username.fromLocalPartWithDomain("user" + i, SIMPSON_COM)) .forEach(user -> provisionUser(testSystem, user)); testSystem.await(); assertThat( testSystem.getQuotaSearcher() .search(QuotaQuery.builder() .withLimit(Limit.unlimited()) .build())) .hasSize(userCount); }
@Test void searchShouldNotBeLimitedByElasticSearchDefaultSearchLimitWhenUsingOffset(QuotaSearchTestSystem testSystem) throws Exception { int userCount = 12; testSystem.getDomainList().addDomain(SIMPSON_COM); testSystem.getMaxQuotaManager().setGlobalMaxStorage(QuotaSizeLimit.size(100)); IntStream.range(0, userCount) .boxed() .map(i -> Username.fromLocalPartWithDomain("user" + i, SIMPSON_COM)) .forEach(user -> provisionUser(testSystem, user)); testSystem.await(); assertThat( testSystem.getQuotaSearcher() .search(QuotaQuery.builder() .withLimit(Limit.unlimited()) .withOffset(Offset.of(1)) .build())) .hasSize(userCount - 1); }