### Question:
PojoMapper implements Function<Object[], T> { public T apply(Object[] data) { if(data.length > setters.length) { throw new CayenneRuntimeException("Unable to create '%s'. Values length (%d) > fields count (%d)" , type.getName(), data.length, setters.length); } T object = newObject(); for (int i = 0; i < data.length; i++) { if (data[i] != null) { try { setters[i].invoke(object, data[i]); } catch (Throwable ex) { throw new CayenneRuntimeException("Unable to set field of %s.", ex, type.getName()); } } } return object; } PojoMapper(Class<T> type); T apply(Object[] data);  }### Answer:
@Test public void testObjectCreation() { PojoMapper<C1> descriptor = new PojoMapper<>(C1.class); Object o = new Object(); Object[] data = {"123", o, 42}; C1 object = descriptor.apply(data); assertEquals("123", object.a); assertSame(o, object.b); assertEquals(42, object.c); }
@Test(expected = CayenneRuntimeException.class) public void testWrongArgumentCount() { PojoMapper<C1> descriptor = new PojoMapper<>(C1.class); Object[] data = {"123", new Object(), 42, 32}; descriptor.apply(data); }