@Override protected T postProcess(T filter) { for (Map.Entry<String, String> pathConfig : this.pathConfigs.entrySet()) { filter.processPathConfig(pathConfig.getKey(), pathConfig.getValue()); } return filter; } }
@Test public void testPostProcess() { PathMatchingFilter filter = createMock(PathMatchingFilter.class); expect(filter.processPathConfig("/1", "first")).andReturn(filter); expect(filter.processPathConfig("/2", "second")).andReturn(filter); replay(filter); Map<String, String> pathConfigMap = new HashMap<String, String>(); pathConfigMap.put("/1", "first"); pathConfigMap.put("/2", "second"); PathMatchingFilterProvider underTest = new PathMatchingFilterProvider(Key.get(PathMatchingFilter.class), pathConfigMap); underTest.postProcess(filter); verify(filter); }
@Override protected T postProcess(T filter) { for (Map.Entry<String, String> pathConfig : this.pathConfigs.entrySet()) { filter.processPathConfig(pathConfig.getKey(), pathConfig.getValue()); } return filter; } }
@Override public Filter processPathConfig(String path, String config) { Filter result = super.processPathConfig(path, config); String[] configValues = (String[]) appliedPaths.get(path); if (configValues.length != 1) { throw new OctopusConfigurationException(String.format("Configuration of Rate limit filter on path %s is wrong (%s)", path, config)); } rateLimiters.put(path, rateLimitConfig.createRateLimiter(configValues[0])); return result; }