### Question:
CompositeKeyGenerator implements KeyGenerator { @Override public Object generate(Object target, Method method, Object... params) { if (params == null) return CompositeKey.EMPTY; switch (params.length) { case 0: return CompositeKey.EMPTY; case 1: Object param = params[0]; if (param != null && !param.getClass().isArray()) { return param; } return new CompositeKey(params); default: return new CompositeKey(params); } }  @Override Object generate(Object target, Method method, Object... params);  }### Answer:
@Test public void generate() throws NoSuchMethodException { CompositeKeyGenerator g = new CompositeKeyGenerator(); Object target = new Object(); Method method = this.getClass().getDeclaredMethod("generate"); assertSame(CompositeKey.EMPTY, g.generate(target, method, (Object[]) null)); assertSame(CompositeKey.EMPTY, g.generate(target, method)); assertEquals("a", g.generate(target, method, "a")); Object param = new Object[]{"a"}; Object response = g.generate(target, method, param); assertTrue(response instanceof CompositeKey); assertEquals(param, ((CompositeKey) response).get(0)); assertEquals(new CompositeKey("a", "b"), g.generate(target, method, "a", "b")); assertEquals(new CompositeKey(new String[]{"a"}, "b"), g.generate(target, method, new String[]{"a"}, "b")); }