### Question:
CardinalityLimiters { public static Function<String, String> rollup(int n) { return new RollupLimiter(n); } private  CardinalityLimiters(); static Function<String, String> first(int n); static Function<String, String> mostFrequent(int n); static Function<String, String> rollup(int n); static final String OTHERS; static final String AUTO_ROLLUP; }### Answer:
@Test public void rollupNegative() { Function<String, String> f = CardinalityLimiters.rollup(-2); Assertions.assertEquals(CardinalityLimiters.AUTO_ROLLUP, f.apply("a")); Assertions.assertEquals(CardinalityLimiters.AUTO_ROLLUP, f.apply("b")); }
@Test public void rollupZero() { Function<String, String> f = CardinalityLimiters.rollup(0); Assertions.assertEquals(CardinalityLimiters.AUTO_ROLLUP, f.apply("a")); Assertions.assertEquals(CardinalityLimiters.AUTO_ROLLUP, f.apply("b")); }
@Test public void rollup2() { Function<String, String> f = CardinalityLimiters.rollup(2); Assertions.assertEquals("a", f.apply("a")); Assertions.assertEquals("b", f.apply("b")); Assertions.assertEquals(CardinalityLimiters.AUTO_ROLLUP, f.apply("c")); Assertions.assertEquals(CardinalityLimiters.AUTO_ROLLUP, f.apply("a")); }
@Test public void rollupSerializability() { Function<String, String> limiter = CardinalityLimiters.rollup(2); limiter.apply("a"); limiter.apply("b"); limiter.apply("c"); checkSerde(limiter); }