### Question:
DomainUtil { public static String[] getCourseNames(List<Course> courses) { List<String> courseNames = new ArrayList<String>(); for (Course c : courses) { courseNames.add(c.getName()); } return courseNames.toArray(new String[0]); }  static String[] getCourseNames(List<Course> courses);  }### Answer:
@Test public void testGetCourseNames() { String[] names = DomainUtil.getCourseNames(courses); assertEquals(names.length, courses.size()); for (int i = 0; i < names.length; i++) { assertEquals(names[i], courses.get(i).getName()); } }
@Test public void testGetCourseNamesWithEmptyList() { String[] names = DomainUtil.getCourseNames(new ArrayList<Course>()); assertEquals(names.length, 0); }