@Test public void testFetchRules() throws Exception { final Rule expected = Rule.builder().withMaxSize(3).build(); final Map<String, Rule> rules = new HashMap<>(); rules.put("like", expected); when(store.fetchCached()).thenReturn(rules); final List<Map<String, Object>> actual = fetcher.get(environment); verify(store).fetchCached(); assertThat(actual).isNotNull(); assertThat(actual.get(0).get("category")).isEqualTo("like"); assertThat(actual.get(0).get("rule")).isEqualTo(expected); }
@Override public List<Map<String, Object>> get(DataFetchingEnvironment environment) { final Map<String, Rule> data = store.fetchCached(); return data.entrySet().stream() .map(e -> ImmutableMap.of("category", e.getKey(), "rule", e.getValue())) .collect(Collectors.toList()); }
RuleDataFetcher implements DataFetcher<List<Map<String, Object>>> { @Override public List<Map<String, Object>> get(DataFetchingEnvironment environment) { final Map<String, Rule> data = store.fetchCached(); return data.entrySet().stream() .map(e -> ImmutableMap.of("category", e.getKey(), "rule", e.getValue())) .collect(Collectors.toList()); } }
RuleDataFetcher implements DataFetcher<List<Map<String, Object>>> { @Override public List<Map<String, Object>> get(DataFetchingEnvironment environment) { final Map<String, Rule> data = store.fetchCached(); return data.entrySet().stream() .map(e -> ImmutableMap.of("category", e.getKey(), "rule", e.getValue())) .collect(Collectors.toList()); } RuleDataFetcher(final RuleStore store); }
RuleDataFetcher implements DataFetcher<List<Map<String, Object>>> { @Override public List<Map<String, Object>> get(DataFetchingEnvironment environment) { final Map<String, Rule> data = store.fetchCached(); return data.entrySet().stream() .map(e -> ImmutableMap.of("category", e.getKey(), "rule", e.getValue())) .collect(Collectors.toList()); } RuleDataFetcher(final RuleStore store); @Override List<Map<String, Object>> get(DataFetchingEnvironment environment); }
RuleDataFetcher implements DataFetcher<List<Map<String, Object>>> { @Override public List<Map<String, Object>> get(DataFetchingEnvironment environment) { final Map<String, Rule> data = store.fetchCached(); return data.entrySet().stream() .map(e -> ImmutableMap.of("category", e.getKey(), "rule", e.getValue())) .collect(Collectors.toList()); } RuleDataFetcher(final RuleStore store); @Override List<Map<String, Object>> get(DataFetchingEnvironment environment);  }