Package gov.nasa.arc.mct.platform.spi

Examples of gov.nasa.arc.mct.platform.spi.RoleAccess


        Mockito.when(comp.getComponentTypeID()).thenReturn("");
        Mockito.when(mockUser.getUserId()).thenReturn("");
        Mockito.when(mockRoleService.getAllUsers()).thenReturn(Collections.singleton(""));
        Mockito.when(mockPlatform.getBootstrapComponents()).thenReturn(Collections.<AbstractComponent>emptyList());
        GlobalContext.getGlobalContext().switchUser(mockUser, Mockito.mock(Runnable.class));
        new RoleAccess().addRoleService(mockRoleService);
        new PlatformAccess().setPlatform(mockPlatform);
    }
View Full Code Here


    }
   
    @Test
    public void testUsesRoleService() {
        RoleService mockRoleService = Mockito.mock(RoleService.class);
        new RoleAccess().addRoleService(mockRoleService);
       
        AbstractComponent mockComponent = Mockito.mock(AbstractComponent.class);
       
        Mockito.when(mockPlatform.getCurrentUser()).thenReturn(mockUser);
        Mockito.when(mockUser.getUserId()).thenReturn("testUser1");
        Mockito.when(mockUser.getDisciplineId()).thenReturn("testGroup1");
        Mockito.when(mockComponent.getOwner()).thenReturn("testRole1");
       
        Mockito.verifyZeroInteractions(mockRoleService);
               
        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), pseudoComponent);
       
        Mockito.when(mockRoleService.hasRole(Mockito.<User>any(), Mockito.anyString())).thenReturn(false);
        Assert.assertFalse(ownershipPolicy.execute(context).getStatus());
       
        Mockito.when(mockRoleService.hasRole(Mockito.<User>any(), Mockito.anyString())).thenReturn(true);             
        Assert.assertTrue(ownershipPolicy.execute(context).getStatus());
       
        new RoleAccess().removeRoleService(mockRoleService);
    }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.platform.spi.RoleAccess

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.