@Test public void testGetFilterDefinitions() { final View view = new View(); final Filter filter1 = new Filter(); filter1.setId(1); filter1.setName("Filter1"); filter1.setClasspath("classpath1"); filter1.setJar("jar1"); final Filter filter2 = new Filter(); filter2.setId(2); filter2.setName("Filter2"); filter2.setClasspath("classpath2"); filter2.setJar("jar2"); final ViewToFilterOptional optional1 = new ViewToFilterOptional(); optional1.setView(view); optional1.setFilter(filter1); final ViewToFilterOptional optional2 = new ViewToFilterOptional(); optional2.setView(view); optional2.setFilter(filter2); view.setOptionalFilters(Sets.newHashSet(optional1, optional2)); final ConsumeRequest consumeRequest = new ConsumeRequest(); final Map<String, String> uiFilter1Options = new HashMap<>(); uiFilter1Options.put("key1", "value1"); uiFilter1Options.put("key2", "value2"); final ConsumeRequest.Filter uiFilter1 = new ConsumeRequest.Filter(); uiFilter1.setFilterId(1L); uiFilter1.setOptions(uiFilter1Options); consumeRequest.setFilters(Lists.newArrayList(uiFilter1)); final ViewCustomizer viewCustomizer = new ViewCustomizer(view, consumeRequest); List<FilterDefinition> filterDefinitions = viewCustomizer.getFilterDefinitions(); assertFalse("Not Empty list", filterDefinitions.isEmpty()); final FilterDefinition filterDefinition = filterDefinitions.get(0); Assert.assertEquals("Has expected filter", filter1, filterDefinition.getFilter()); assertEquals("Has expected filter", uiFilter1Options, filterDefinition.getOptions()); }
public List<FilterDefinition> getFilterDefinitions() { final List<ConsumeRequest.Filter> requestFilters = consumeRequest.getFilters(); final List<FilterDefinition> configuredFilters = new ArrayList<>(); if (requestFilters != null && !requestFilters.isEmpty()) { final Map<Long, Filter> allowedFilters = new HashMap<>(); for (final ViewToFilterOptional allowedFilter : view.getOptionalFilters()) { allowedFilters.put(allowedFilter.getFilter().getId(), allowedFilter.getFilter()); } for (final ConsumeRequest.Filter requestedFilter: requestFilters) { final Long requestedFilterId = requestedFilter.getFilterId(); final Map<String, String> requestedFilterOptions = requestedFilter.getOptions(); if (!allowedFilters.containsKey(requestedFilterId)) { continue; } final Filter filter = allowedFilters.get(requestedFilterId); final FilterDefinition filterDefinition = new FilterDefinition(filter, requestedFilterOptions); configuredFilters.add(filterDefinition); } } return configuredFilters; }
ViewCustomizer { public List<FilterDefinition> getFilterDefinitions() { final List<ConsumeRequest.Filter> requestFilters = consumeRequest.getFilters(); final List<FilterDefinition> configuredFilters = new ArrayList<>(); if (requestFilters != null && !requestFilters.isEmpty()) { final Map<Long, Filter> allowedFilters = new HashMap<>(); for (final ViewToFilterOptional allowedFilter : view.getOptionalFilters()) { allowedFilters.put(allowedFilter.getFilter().getId(), allowedFilter.getFilter()); } for (final ConsumeRequest.Filter requestedFilter: requestFilters) { final Long requestedFilterId = requestedFilter.getFilterId(); final Map<String, String> requestedFilterOptions = requestedFilter.getOptions(); if (!allowedFilters.containsKey(requestedFilterId)) { continue; } final Filter filter = allowedFilters.get(requestedFilterId); final FilterDefinition filterDefinition = new FilterDefinition(filter, requestedFilterOptions); configuredFilters.add(filterDefinition); } } return configuredFilters; } }
ViewCustomizer { public List<FilterDefinition> getFilterDefinitions() { final List<ConsumeRequest.Filter> requestFilters = consumeRequest.getFilters(); final List<FilterDefinition> configuredFilters = new ArrayList<>(); if (requestFilters != null && !requestFilters.isEmpty()) { final Map<Long, Filter> allowedFilters = new HashMap<>(); for (final ViewToFilterOptional allowedFilter : view.getOptionalFilters()) { allowedFilters.put(allowedFilter.getFilter().getId(), allowedFilter.getFilter()); } for (final ConsumeRequest.Filter requestedFilter: requestFilters) { final Long requestedFilterId = requestedFilter.getFilterId(); final Map<String, String> requestedFilterOptions = requestedFilter.getOptions(); if (!allowedFilters.containsKey(requestedFilterId)) { continue; } final Filter filter = allowedFilters.get(requestedFilterId); final FilterDefinition filterDefinition = new FilterDefinition(filter, requestedFilterOptions); configuredFilters.add(filterDefinition); } } return configuredFilters; } ViewCustomizer(final View view, final ConsumeRequest consumeRequest); }
ViewCustomizer { public List<FilterDefinition> getFilterDefinitions() { final List<ConsumeRequest.Filter> requestFilters = consumeRequest.getFilters(); final List<FilterDefinition> configuredFilters = new ArrayList<>(); if (requestFilters != null && !requestFilters.isEmpty()) { final Map<Long, Filter> allowedFilters = new HashMap<>(); for (final ViewToFilterOptional allowedFilter : view.getOptionalFilters()) { allowedFilters.put(allowedFilter.getFilter().getId(), allowedFilter.getFilter()); } for (final ConsumeRequest.Filter requestedFilter: requestFilters) { final Long requestedFilterId = requestedFilter.getFilterId(); final Map<String, String> requestedFilterOptions = requestedFilter.getOptions(); if (!allowedFilters.containsKey(requestedFilterId)) { continue; } final Filter filter = allowedFilters.get(requestedFilterId); final FilterDefinition filterDefinition = new FilterDefinition(filter, requestedFilterOptions); configuredFilters.add(filterDefinition); } } return configuredFilters; } ViewCustomizer(final View view, final ConsumeRequest consumeRequest); View overrideViewSettings(); List<FilterDefinition> getFilterDefinitions(); StartingPosition getStartingPosition(); }
ViewCustomizer { public List<FilterDefinition> getFilterDefinitions() { final List<ConsumeRequest.Filter> requestFilters = consumeRequest.getFilters(); final List<FilterDefinition> configuredFilters = new ArrayList<>(); if (requestFilters != null && !requestFilters.isEmpty()) { final Map<Long, Filter> allowedFilters = new HashMap<>(); for (final ViewToFilterOptional allowedFilter : view.getOptionalFilters()) { allowedFilters.put(allowedFilter.getFilter().getId(), allowedFilter.getFilter()); } for (final ConsumeRequest.Filter requestedFilter: requestFilters) { final Long requestedFilterId = requestedFilter.getFilterId(); final Map<String, String> requestedFilterOptions = requestedFilter.getOptions(); if (!allowedFilters.containsKey(requestedFilterId)) { continue; } final Filter filter = allowedFilters.get(requestedFilterId); final FilterDefinition filterDefinition = new FilterDefinition(filter, requestedFilterOptions); configuredFilters.add(filterDefinition); } } return configuredFilters; } ViewCustomizer(final View view, final ConsumeRequest consumeRequest); View overrideViewSettings(); List<FilterDefinition> getFilterDefinitions(); StartingPosition getStartingPosition();  }