TsParamFilter 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) + ": " + typeFiler.apply(param.get("type")); } TsParamFilter(Cookbook cookbook, Filter typeFilter, Filter identifierFilter); @Override Object apply(Object value, Object... params);  }
@Test public void testApply_combinesNameAndTypeFromFilters() { Cookbook cookbook = new Cookbook("test", new ArrayList<>(), new ArrayList<>()); Filter filter = new TsParamFilter(cookbook, typeFilter, identifierFilter); when(typeFilter.apply("int[]")).thenReturn("number[]"); when(identifierFilter.apply("foo")).thenReturn("bar"); assertEquals("bar: number[]", filter.apply(param("foo", "int[]"))); }
@Test public void testApply_addsEllipsisToNameWhenVararg() { Cookbook cookbook = new Cookbook("test", new ArrayList<>(), new ArrayList<>()); Filter filter = new TsParamFilter(cookbook, typeFilter, identifierFilter); when(typeFilter.apply("int...")).thenReturn("number[]"); when(identifierFilter.apply("foo")).thenReturn("foo"); assertEquals("...foo: number[]", filter.apply(param("foo", "int..."))); }