Package org.jtalks.common.model.permissions

Examples of org.jtalks.common.model.permissions.JtalksPermission


        assertNull(actual);
    }

    @Test
    public void findPluginBranchPermissionByNameShouldReturnPermissionIfPluginEnabled() {
        JtalksPermission targetPermission = BranchPermission.VIEW_TOPICS;
        when(pluginWithBranchPermissions.getBranchPermissionByName(targetPermission.getName())).thenReturn(targetPermission);
        when(pluginWithBranchPermissions.isEnabled()).thenReturn(true);

        PluginPermissionManager pluginPermissionManager = new PluginPermissionManager(pluginLoader);
        JtalksPermission actual = pluginPermissionManager.findPluginsBranchPermissionByName(targetPermission.getName());

        assertEquals(actual, targetPermission);
    }
View Full Code Here


        assertEquals(actual, targetPermission);
    }

    @Test
    public void findPluginBranchPermissionByNameShouldReturnNullIfPluginDisabled() {
        JtalksPermission targetPermission = BranchPermission.VIEW_TOPICS;
        when(pluginWithBranchPermissions.getBranchPermissionByName(targetPermission.getName())).thenReturn(targetPermission);
        when(pluginWithBranchPermissions.isEnabled()).thenReturn(false);

        PluginPermissionManager pluginPermissionManager = new PluginPermissionManager(pluginLoader);
        JtalksPermission result = pluginPermissionManager.findPluginsBranchPermissionByName(targetPermission.getName());

        assertNull(result);
    }
View Full Code Here

    public void findPluginBranchPermissionByNameShouldReturnNullIfNoPermissionFound() {
        when(pluginWithBranchPermissions.getBranchPermissionByName(anyString())).thenReturn(null);
        when(pluginWithBranchPermissions.isEnabled()).thenReturn(true);

        PluginPermissionManager pluginPermissionManager = new PluginPermissionManager(pluginLoader);
        JtalksPermission actual = pluginPermissionManager.findPluginsBranchPermissionByName("anyName");

        assertNull(actual);
    }
View Full Code Here

    }

    @Test
    public void getBranchPermissionByMaskShouldReturnCorrectPermission() {
        QuestionsPluginBranchPermission expectedPermission = QuestionsPluginBranchPermission.CREATE_QUESTIONS;
        JtalksPermission actualPermission = new QuestionsAndAnswersPlugin().getBranchPermissionByMask(31);
        assertEquals(actualPermission, expectedPermission);
    }
View Full Code Here

        assertEquals(actualPermission, expectedPermission);
    }

    @Test
    public void getBranchPermissionByMaskShouldReturnNullIfPermissionNotFound() {
        JtalksPermission actualPermission = new QuestionsAndAnswersPlugin().getBranchPermissionByMask(30);
        assertNull(actualPermission);
    }
View Full Code Here

    }

    @Test
    public void getBranchPermissionByNameShouldReturnCorrectPermission() {
        QuestionsPluginBranchPermission expectedPermission = QuestionsPluginBranchPermission.CREATE_QUESTIONS;
        JtalksPermission actualPermission = new QuestionsAndAnswersPlugin().getBranchPermissionByName("CREATE_QUESTIONS");
        assertEquals(actualPermission, expectedPermission);
    }
View Full Code Here

        assertEquals(actualPermission, expectedPermission);
    }

    @Test
    public void getBranchPermissionByNameShouldReturnNullIfPermissionNotFound() {
        JtalksPermission actualPermission = new QuestionsAndAnswersPlugin().getBranchPermissionByName("ASK_QUESTIONS");
        assertNull(actualPermission);
    }
View Full Code Here

     * @param mask interested permission mask
     * @return permission with specified mask if it exist
     *         <b>null</b> otherwise
     */
    public JtalksPermission findBranchPermissionByMask(int mask) {
        JtalksPermission permission = BranchPermission.findByMask(mask);
        if (permission == null) {
            permission = pluginPermissionManager.findPluginsBranchPermissionByMask(mask);
        }
        return permission;
    }
View Full Code Here

        verify(pluginsPermissionFactory).buildFromMask(targetPermission.getMask());
    }

    @Test
    public void buildFromNameShouldReturnPermissionFromCommons() {
        JtalksPermission targetPermission = BranchPermission.VIEW_TOPICS;
        when(jtalksPermissionFactory.buildFromName(targetPermission.getName())).thenReturn(targetPermission);

        JCPermissionFactory permissionFactory = new JCPermissionFactory(jtalksPermissionFactory,pluginsPermissionFactory);
        Permission result = permissionFactory.buildFromName(targetPermission.getName());

        assertEquals(result, targetPermission);
        verify(pluginsPermissionFactory, never()).buildFromName(anyString());
    }
View Full Code Here

        verify(pluginsPermissionFactory, never()).buildFromName(anyString());
    }

    @Test
    public void buildFromNameShouldReturnPluginPermissionWhenCommonNotFound() {
        JtalksPermission targetPermission = BranchPermission.VIEW_TOPICS;
        when(jtalksPermissionFactory.buildFromName(anyString())).thenReturn(null);
        when(pluginsPermissionFactory.buildFromName(targetPermission.getName())).thenReturn(targetPermission);

        JCPermissionFactory permissionFactory = new JCPermissionFactory(jtalksPermissionFactory,pluginsPermissionFactory);
        Permission result = permissionFactory.buildFromName(targetPermission.getName());

        assertEquals(result, targetPermission);
        verify(jtalksPermissionFactory).buildFromName(targetPermission.getName());
    }
View Full Code Here

TOP

Related Classes of org.jtalks.common.model.permissions.JtalksPermission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.