### Question:
CollectionUtils { public static <T> T getSingleValue(List<T> list) { switch (list.size()) { case 0: return null; case 1: return list.get(0); default: throw new IllegalArgumentException("Expected 0 or 1 items in the collection but found " + list.size()); } } private  CollectionUtils(); static void reconcileObjectCollections(Collection<T> existingCollection, Collection<T> updatedCollection,
                                                         CollectionReconciliationHelper<T, K> reconciliationHelper,
                                                         boolean removeMissingObjects); @SuppressWarnings("unchecked") static List<T> toBaseTypedList(List<? extends T> initial); @SuppressWarnings("unchecked") static Collection<T> toBaseTypedCollection(Collection<? extends T> initial); static void addUniqueValues(List<T> source, List<T> target); static T getSingleValue(List<T> list);  }### Answer:
@Test public void getSingleValue_empty() { List<String> list = new ArrayList<String>(); assertThat(CollectionUtils.getSingleValue(list), is(nullValue(String.class))); }
@Test public void getSingleValue_single() { List<String> list = new ArrayList<String>(); list.add("hello"); assertThat(CollectionUtils.getSingleValue(list), is("hello")); }
@Test(expected = IllegalArgumentException.class) public void getSingleValue_multiple() { List<String> list = new ArrayList<String>(); list.add("foo"); list.add("bar"); CollectionUtils.getSingleValue(list); }