### Question:
CommaSeparatedCollectionField extends CustomField<Collection> { public void setElementType(Class<?> elementType) { this.elementType = elementType; } CommaSeparatedCollectionField(); @Override Class<? extends Collection> getType(); Class<?> getElementType(); void setElementType(Class<?> elementType); void setInstantiator(FromStringInstantiator instantiator); FromStringInstantiator getInstantiator(); String getJoinSeparator(); void setJoinSeparator(String joinSeparator); String getSplitSeparatorRegexp(); void setSplitSeparatorRegexp(String splitSeparatorRegexp);  }### Answer:
@Test public void testWithValueOfFuction() { ArrayList list = new ArrayList(); CommaSeparatedCollectionField field = new CommaSeparatedCollectionField(); field.setElementType(Test1.class); field.setValue(list); field.textField.userValueChange = true; field.textField.setValue("Foo"); field.textField.userValueChange = false; Test1 get = (Test1) list.get(0); assertEquals("Foo", get.getValue()); field.textField.userValueChange = true; field.textField.setValue("Foo, bar"); field.textField.userValueChange = false; get = (Test1) list.get(1); assertEquals("bar", get.getValue()); list.clear(); list.add(16); field.setElementType(Integer.class); field.setValue(null); field.setValue(list); assertEquals("16", field.textField.getValue()); field.textField.userValueChange = true; field.textField.setValue("2, 1"); field.textField.userValueChange = false; Integer int1 = (Integer) list.get(1); assertEquals(Integer.valueOf(1), int1); }
@Test public void testWithConstructor() { ArrayList list = new ArrayList(); CommaSeparatedCollectionField field = new CommaSeparatedCollectionField(); field.setElementType(Test2.class); field.setValue(list); field.textField.userValueChange = true; field.textField.setValue("Foo"); field.textField.userValueChange = false; Test2 get = (Test2) list.get(0); assertEquals("Foo", get.getValue()); field.textField.userValueChange = true; field.textField.setValue("Foo, bar"); field.textField.userValueChange = false; get = (Test2) list.get(1); assertEquals("bar", get.getValue()); }