Package gov.nasa.arc.mct.policy

Examples of gov.nasa.arc.mct.policy.PolicyContext


        }
    }
   
    protected boolean checkAllowComponentRenamePolicy() {
        boolean rv;
        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), getManifestedComponent());
        context.setProperty("NAME", getManifestedComponent().getDisplayName());
        context.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        String renamingkey = PolicyInfo.CategoryType.ALLOW_COMPONENT_RENAME_POLICY_CATEGORY.getKey();
        rv =  PolicyManagerImpl.getInstance().execute(renamingkey, context).getStatus();
        return rv;
    }
View Full Code Here


        if (!selectedComponent.canBeDeleted()) {
            return false;
        }
       
       
        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), parentComponent);
        context.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY.getKey();
        return PolicyManagerImpl.getInstance().execute(compositionKey, context).getStatus();
    }
View Full Code Here

            public int getSourceActions(JComponent c) {
                return canComponentBeContained()?COPY:NONE;
            }
           
            private boolean canComponentBeContained() {
                PolicyContext policyContext = new PolicyContext();
                policyContext.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(),Collections.singleton(context.getWindowManifestation().getManifestedComponent()));
                String policyCategoryKey = PolicyInfo.CategoryType.CAN_OBJECT_BE_CONTAINED_CATEGORY.getKey();
                ExecutionResult result = PolicyManagerImpl.getInstance().execute(policyCategoryKey, policyContext);
                return result.getStatus();
            }
View Full Code Here

    public void shutDown() {
   }
   
    @Test
    public void testCanDeleteComponentPolicy() {
        PolicyContext context = new  PolicyContext();
       
        context = new  PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), mockPrivateComponent);
        ExecutionResult exResult = policy.execute(context);
       
        Assert.assertTrue(exResult.getStatus());
       
        context = new  PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), mockPrivateComponentWithDifferentOwner);
        exResult = policy.execute(context);
       
        Assert.assertFalse(exResult.getStatus());
       
        MineTaxonomyComponent mockMine = Mockito.mock(MineTaxonomyComponent.class);
        context = new  PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), mockMine);
        exResult = policy.execute(context);
       
        Assert.assertFalse(exResult.getStatus());
    }
View Full Code Here

    }
   
    @Test
    public void testDraggingPolicy() {
        List<AbstractComponent> components = new ArrayList<AbstractComponent>();
        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(),components);
               
        // verify my sandbox cannot be contained
        components.add(mySandbox);
        components.add(component);
        Assert.assertFalse(policy.execute(context).getStatus());
View Full Code Here

       
    }
   
    @Test
    public void testPopupMenuPolicy() {
        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(),null);
                       
        // verify normal components can be contained
        Assert.assertTrue(policy.execute(context).getStatus());       
    }
View Full Code Here

        AbstractComponent componentB = Mockito.mock(AbstractComponent.class);
       
        Mockito.when(componentA.getId()).thenReturn("A");
        Mockito.when(componentB.getId()).thenReturn("B");
       
        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), componentA);
        context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(), Collections.singletonList(componentB));
        Assert.assertTrue(policy.execute(context).getStatus());
    }
View Full Code Here

            String groupID,
            final String compOwner,
            final String compGroup,
            final boolean hasGroupCapability,
            boolean expectedResult) {
        PolicyContext context = new PolicyContext();
       
        // getCapability is final, so we can't just mock....
        pseudoComponent = new AbstractComponent() {
            public String getOwner() {
                return compOwner;
            }
           
            public <T> T handleGetCapability(Class<T> capability) {
                if (capability.isAssignableFrom(Group.class) && hasGroupCapability) {
                    return capability.cast(mockGroup);
                }
                return super.handleGetCapability(capability);
            };
        };
       
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), pseudoComponent);
       
        Mockito.when(mockPlatform.getCurrentUser()).thenReturn(mockUser);
        Mockito.when(mockGroup.getDiscipline()).thenReturn(compGroup);
        Mockito.when(mockUser.getUserId()).thenReturn(userID);
        Mockito.when(mockUser.getDisciplineId()).thenReturn(groupID);
View Full Code Here

        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);             
View Full Code Here

    }
   
    @Test(dataProvider="policies")
    public void testPolicy(AbstractComponent ac, ViewInfo vi, boolean expectedResult) {
        DefaultViewForTaxonomyNode policy = new DefaultViewForTaxonomyNode();
        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), ac);
        context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), vi);
        Assert.assertEquals(policy.execute(context).getStatus(), expectedResult);
    }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.policy.PolicyContext

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.