### Question:
MapUtilities { public static <T extends Object> Map buildMap(T ... couples) { ArgumentChecks.ensureNonNull("map values", couples); if (couples.length % 2 != 0) { throw new IllegalArgumentException("Invalid number of values (not divisible per 2)"); } final Map result = new HashMap(couples.length/2); for(int i = 0 ; i < couples.length ;) { result.put(couples[i++], couples[i++]); } return result; } private  MapUtilities(); static Map buildMap(T ... couples);  }### Answer:
@Test public void testBuildMap() { final Integer[] testInt = new Integer[1000]; for (int i = 0; i < testInt.length; i++) { testInt[i] = i; } final String[] testString = new String[100]; for (int i = 0; i < testString.length;) { testString[i] = "key" + i++; testString[i] = "value" + i++; } final Object[] testBadNumber = new Object[51]; try { MapUtilities.buildMap((Object[])null); fail("Should have raised an exception"); } catch (NullArgumentException e) { } try { MapUtilities.buildMap(testBadNumber); fail("Should have raised an exception"); } catch (IllegalArgumentException e) { } final Map resInt = MapUtilities.buildMap(testInt); final Map resString = MapUtilities.buildMap(testString); assertNotNull("null result", testInt); assertNotNull("null result", testString); assertEquals("Wrong size for result map", resInt.size(), testInt.length / 2); assertEquals("Wrong size for result map", resString.size(), testString.length / 2); for (int i = 0; i < testInt.length;) { assertTrue("Expected key not found in result map", resInt.containsKey(i++)); assertTrue("Expected key not found in result map", resInt.containsValue(i++)); } for (int i = 0; i < testString.length;) { assertTrue("Expected key not found in result map : iteration " + i, resString.containsKey("key" + i++)); assertTrue("Expected value not found in result map : iteration " + i, resString.containsValue("value" + i++)); } }