### Question:
MappingTools { public static Set<String> getRoleNames(final Collection<RoleMapping> mappings) { requireNonNull(mappings); return mappings.stream().map(RoleMapping::getRoleName).collect(toCollection(TreeSet::new)); } private  MappingTools(); static Set<String> getPrivilegeNames(final Collection<RoleMapping> mappings); static Set<String> getRoleNames(final Collection<RoleMapping> mappings); static Map<String, Set<String>> asMap(final Collection<RoleMapping> mappings);  }### Answer:
@Test public void testGetRoleNamesEmpty() { final Set<String> result = getRoleNames(Collections.emptySet()); assertThat(result.isEmpty(), is(true)); }
@Test(expected = NullPointerException.class) public void testGetRoleNamesNull() { getRoleNames(null); fail(); }
@Test public void testGetRoleNames() { final Set<String> result = getRoleNames(mappings); assertThat(result.size(), is(1)); assertThat(result, hasItem(role.getName())); }