### Question:
CollectionUtils { public static <T> Collection<T> populate(final Collection<T> collection, final Collection<? extends T> items) { if (collection != null) { collection.clear(); if (items != null) { collection.addAll(items); } } return collection; } private  CollectionUtils(); static List<?> arrayToList(final Object source); static List<T> filter(final Iterable<? extends T> unfiltered, final Filter<T> filter); static T firstElementOf(final Collection<? extends T> collection); static boolean isEmpty(final Collection<?> collection); static boolean isEmpty(final Map<?, ?> map); static Collection<T> populate(final Collection<T> collection,
      final Collection<? extends T> items);  }### Answer:
@Test public void testPopulateNonNullCollectionWithNonNullCollection() { final Collection<Parent> originalCollection = new ArrayList<Parent>(); originalCollection.add(new Parent()); final Child child = new Child(); final Collection<Parent> result = CollectionUtils.populate(originalCollection, Arrays.asList(child)); assertEquals(Collections.singletonList(child), result); }
@Test public void testPopulateNonNullCollectionWithNullCollection() { final Collection<Parent> collection = new ArrayList<Parent>(); collection.add(new Parent()); final Collection<Parent> result = CollectionUtils.populate(collection, null); assertEquals(0, result.size()); }
@Test public void testPopulateNullCollectionWithNullCollection() { assertNull(CollectionUtils.populate(null, null)); }