CollectionFactory { public static <T> Collection<T> createDefaultCollection(PluralAttribute.CollectionType collectionType) { switch (collectionType) { case LIST: return new ArrayList<>(); case SET: case COLLECTION: return new HashSet<>(); default: throw new IllegalArgumentException("Collection type " + collectionType + " is not supported."); } } private  CollectionFactory(); static Collection<?> createInstance(Collection<?> collection); static Collection<T> createDefaultCollection(PluralAttribute.CollectionType collectionType); static Map<Object, Object> createDefaultMap();  }
@Test void createDefaultCollectionReturnsListImplementationForListType() { assertTrue(CollectionFactory.createDefaultCollection(PluralAttribute.CollectionType.LIST) instanceof List); }
@Test void createDefaultCollectionReturnsSetImplementationForSetType() { assertTrue(CollectionFactory.createDefaultCollection(PluralAttribute.CollectionType.SET) instanceof Set); }
@Test void createDefaultCollectionReturnsSetImplementationForCollectionType() { assertTrue(CollectionFactory.createDefaultCollection(PluralAttribute.CollectionType.COLLECTION) instanceof Set); }
@Test void createDefaultCollectionThrowsIllegalArgumentForMapType() { final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> CollectionFactory.createDefaultCollection(PluralAttribute.CollectionType.MAP)); assertEquals("Collection type " + PluralAttribute.CollectionType.MAP + " is not supported.", ex.getMessage()); }