JsParamFilter extends RecipeFilter { @Override public Object apply(Object value, Object... params) { Map<String, String> param = (Map<String, String>) value; String name = param.get("name"); ParamType type = CookbookUtils.parseType(param.get("type"), getCookbook()); return (type.isVararg() ? "..." : "") + identifierFilter.apply(name); } JsParamFilter(Cookbook cookbook, Filter identifierFilter); @Override Object apply(Object value, Object... params);  }
@Test public void testApply_outputsParamNameFromIdentifierFilter() { Cookbook cookbook = new Cookbook("test", new ArrayList<>(), new ArrayList<>()); Filter filter = new JsParamFilter(cookbook, identifierFilter); when(identifierFilter.apply("foo")).thenReturn("bar"); assertEquals("bar", filter.apply(param("foo", "string"))); }
@Test public void testApply_outputsEllipsesWhenParamTypeIsVararg() { Cookbook cookbook = new Cookbook("test", new ArrayList<>(), new ArrayList<>()); Filter filter = new JsParamFilter(cookbook, identifierFilter); when(identifierFilter.apply("foo")).thenReturn("foo"); assertEquals("...foo", filter.apply(param("foo", "int..."))); }