### Question:
JCPermissionFactory implements PermissionFactory { @Override public List<Permission> buildFromNames(List<String> names) { List<Permission> permissions = new ArrayList<>(); permissions.addAll(jtalksPermissionFactory.buildFromNames(names)); permissions.addAll(pluginPermissionFactory.buildFromNames(names)); return permissions; } JCPermissionFactory(JtalksPermissionFactory jtalksPermissionFactory, PluginsPermissionFactory pluginPermissionFactory); @Override Permission buildFromMask(int mask); @Override Permission buildFromName(String name); @Override List<Permission> buildFromNames(List<String> names);  }### Answer:
@Test public void buildFromNamesShouldReturnBothOfCommonAndPluginPermissions() { JtalksPermission commonPermission = BranchPermission.VIEW_TOPICS; JtalksPermission pluginPermission = BranchPermission.CLOSE_TOPICS; List<String> names = Arrays.asList(commonPermission.getName(), pluginPermission.getName()); List<Permission> expected = Arrays.asList((Permission)commonPermission, (Permission)pluginPermission); when(jtalksPermissionFactory.buildFromNames(names)).thenReturn(Arrays.asList((Permission)commonPermission)); when(pluginsPermissionFactory.buildFromNames(names)).thenReturn(Arrays.asList((Permission)pluginPermission)); JCPermissionFactory permissionFactory = new JCPermissionFactory(jtalksPermissionFactory,pluginsPermissionFactory); List<Permission> actual = permissionFactory.buildFromNames(names); assertEquals(actual, expected); verify(jtalksPermissionFactory).buildFromNames(names); verify(pluginsPermissionFactory).buildFromNames(names); }
@Test public void buildFromNamesShouldReturnEmptyListIfNoPermissionsFound() { when(jtalksPermissionFactory.buildFromNames(any(List.class))).thenReturn(Collections.EMPTY_LIST); when(pluginsPermissionFactory.buildFromNames(any(List.class))).thenReturn(Collections.EMPTY_LIST); List<String> names = Arrays.asList("permission1", "permission2"); JCPermissionFactory permissionFactory = new JCPermissionFactory(jtalksPermissionFactory,pluginsPermissionFactory); List<Permission> result = permissionFactory.buildFromNames(names); assertEquals(result, Collections.EMPTY_LIST); verify(jtalksPermissionFactory).buildFromNames(names); verify(pluginsPermissionFactory).buildFromNames(names); }