Package gov.nasa.arc.mct.policy

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


 
  @BeforeTest
  public void setup() {
    MockitoAnnotations.initMocks(this);
    policy = new MultiColViewPolicy();
    context = new PolicyContext();
  }
View Full Code Here


      .thenReturn(Collections.singleton(new ViewInfo(TableViewManifestation.class,"","",ViewType.EMBEDDED)));
    Mockito.when(mockPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(new ExecutionResult(null, true, ""));
    (new PlatformAccess()).setPlatform(mockPlatform);
   
    new ServiceAccess().bind(policyManager);
    success = new ExecutionResult(new PolicyContext(), true, "success");
    failure = new ExecutionResult(new PolicyContext(), false, "failure");

    when(leaf.isLeaf()).thenReturn(true);
    when(leafWithFeed.isLeaf()).thenReturn(true);
    when(leafWithFeed.getCapability(FeedProvider.class)).thenReturn(mockFeedProvider);
  }
View Full Code Here

  }

  @Test
  public void testPolicyExecution() {
    TableViewPolicy policy = new TableViewPolicy();
    PolicyContext context = new PolicyContext();
    context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), new ViewInfo(TableViewManifestation.class,"table", ViewType.OBJECT));
    context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), leafWithFeed);
    Assert.assertTrue(policy.execute(context).getStatus());

    context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), leaf);
    Assert.assertFalse(policy.execute(context).getStatus());
  }
View Full Code Here

  private ExecutionResult checkDropPolicy(
      AbstractComponent targetComponent,
      Collection<AbstractComponent> sourceComponents,
      View targetViewManifesation) {
    // Establish policy context.
    PolicyContext context = new PolicyContext();
    context.setProperty(
        PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
        targetComponent);
    context.setProperty(
        PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(),
        sourceComponents);
    context.setProperty(PolicyContext.PropertyName.ACTION.getName(),
        Character.valueOf('w'));
    context.setProperty(
        PolicyContext.PropertyName.VIEW_MANIFESTATION_PROVIDER
            .getName(), targetViewManifesation);
    String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY
        .getKey();
    // Execute policy
View Full Code Here

            public int getSourceActions(JComponent c) {
                return canComponentBeContained()?COPY:NONE;
            }

            private boolean canComponentBeContained() {
                PolicyContext context = new PolicyContext();
                context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(),Collections.singleton(referencedComponent));
                String policyCategoryKey = PolicyInfo.CategoryType.CAN_OBJECT_BE_CONTAINED_CATEGORY.getKey();
                Platform platform = PlatformAccess.getPlatform();
                PolicyManager policyManager = platform.getPolicyManager();
                ExecutionResult result = policyManager.execute(policyCategoryKey, context);
                return result.getStatus();
View Full Code Here

     */
    @Override
    public boolean isEnabled() {
        AbstractComponent targetComponent = currentContext.getSelectedManifestations()
                                        .iterator().next().getManifestedComponent();
        PolicyContext policyContext = new PolicyContext();
        policyContext.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
                              targetComponent);
        policyContext.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY
                            .getKey();
        return PlatformAccess.getPlatform().getPolicyManager().execute(compositionKey,
              policyContext).getStatus();
    }
View Full Code Here

     */
    @Override
    public boolean isEnabled() {
        AbstractComponent targetComponent = currentContext.getWindowManifestation()
            .getManifestedComponent();
        PolicyContext policyContext = new PolicyContext();
        policyContext.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
                              targetComponent);
        policyContext.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY
                            .getKey();
        return PlatformAccess.getPlatform().getPolicyManager().execute(compositionKey,
              policyContext).getStatus();
    }
View Full Code Here

    if (context.getSelectedManifestations().isEmpty())
      return false;

    AbstractComponent targetComponent = context.getSelectedManifestations()
        .iterator().next().getManifestedComponent();
    PolicyContext policyContext = new PolicyContext();
    policyContext.setProperty(
        PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
        targetComponent);
    policyContext.setProperty(PolicyContext.PropertyName.ACTION.getName(),
        'w');
    String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY
        .getKey();

    return (context.getSelectedManifestations().size() == 1)
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.