### Question:
PluginPermissionManager { public List<JtalksPermission> getPluginsBranchPermissions() { PluginFilter filter = new TypeFilter(PluginWithBranchPermissions.class); List<Plugin> plugins = pluginLoader.getPlugins(filter); List<JtalksPermission> branchPermissions = new ArrayList<>(); for (Plugin plugin : plugins) { if (plugin.isEnabled()) { branchPermissions.addAll(((PluginWithBranchPermissions) plugin).getBranchPermissions()); } } return branchPermissions; } PluginPermissionManager(PluginLoader pluginLoader); List<JtalksPermission> getPluginsBranchPermissions(); JtalksPermission findPluginsBranchPermissionByMask(int mask); JtalksPermission findPluginsBranchPermissionByName(String name);  }### Answer:
@Test public void getPluginsBranchPermissionsShouldReturnAllBranchPermissionsForEnabledPlugins() { List<JtalksPermission> expected = Arrays.asList((JtalksPermission) BranchPermission.VIEW_TOPICS); when(pluginWithBranchPermissions.getBranchPermissions()).thenReturn(expected); when(pluginWithBranchPermissions.isEnabled()).thenReturn(true); PluginPermissionManager pluginPermissionManager = new PluginPermissionManager(pluginLoader); List<JtalksPermission> actual = pluginPermissionManager.getPluginsBranchPermissions(); assertEquals(actual, expected); }
@Test public void getPluginsBranchPermissionsShouldNotReturnPermissionsForDisabledPlugins() { List<JtalksPermission> permissions = Arrays.asList((JtalksPermission) BranchPermission.VIEW_TOPICS); when(pluginWithBranchPermissions.getBranchPermissions()).thenReturn(permissions); when(pluginWithBranchPermissions.isEnabled()).thenReturn(false); PluginPermissionManager pluginPermissionManager = new PluginPermissionManager(pluginLoader); List<JtalksPermission> actual = pluginPermissionManager.getPluginsBranchPermissions(); assertEquals(actual, Collections.EMPTY_LIST); }