ParamUtil { public static String getOne(final MultivaluedMap<String, String> values, final String key) { List<String> listValues = values.get(key); if (listValues == null) { throw new InvalidFieldException(key); } if (listValues.size() != 1) { throw new InvalidFieldException(key); } return listValues.get(0); } private  ParamUtil(); static String getOne(final MultivaluedMap<String, String> values,
                                final String key);  }
@Test(expected = InvalidFieldException.class) public void testGetOneMultiResult() { MultivaluedMap<String, String> params = new MultivaluedHashMap<>(); params.add("foo", "one"); params.add("foo", "two"); ParamUtil.getOne(params, "foo"); }
@Test public void testGetOne() { MultivaluedMap<String, String> params = new MultivaluedHashMap<>(); params.add("foo", "bar"); String result = ParamUtil.getOne(params, "foo"); assertEquals("bar", result); }
@Test(expected = InvalidFieldException.class) public void testGetOneNoValue() { MultivaluedMap<String, String> params = new MultivaluedHashMap<>(); ParamUtil.getOne(params, "does_not_exist"); }