Examples of PolicyContext


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

            return false;
       
        AbstractComponent parentComponent = ((View) parentNode.getUserObject()).getManifestedComponent();
        AbstractComponent selectedComponent = View.class.cast(lastPathComponent.getUserObject()).getManifestedComponent();

        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), parentComponent);
        context.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(), Collections.singleton(selectedComponent));
        context.setProperty(PolicyContext.PropertyName.VIEW_MANIFESTATION_PROVIDER.getName(), parentNode.getUserObject());
       
        String canRemoveManifestationKey = PolicyInfo.CategoryType.CAN_REMOVE_MANIFESTATION_CATEGORY.getKey();
        boolean canRemoveManifestation = PolicyManagerImpl.getInstance().execute(canRemoveManifestationKey, context).getStatus();
       
        if (canRemoveManifestation) {
View Full Code Here

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

  @Test
  public void testRejectCanvasView() throws Exception {
    (new PolicyManagerAccess()).setPolicyManager(mockPolicyManager);
    AbstractComponent comp = Mockito.mock(AbstractComponent.class);
    PlotViewPolicy policy = new PlotViewPolicy();
    PolicyContext context = new PolicyContext();
    context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), new ViewInfo(PlotViewManifestation.class,"",ViewType.CENTER));
    Method m = policy.getClass().getDeclaredMethod("rejectCanvasView", PolicyContext.class, AbstractComponent.class);
    m.setAccessible(true);
    Mockito.when(comp.isLeaf()).thenReturn(false);
    Assert.assertEquals(m.invoke(policy, context, comp), Boolean.FALSE, "direct access to plot view role should always be true");
    context.setProperty(PolicyContext.PropertyName.VIEW_TYPE.getName(), ViewType.CENTER);
    Assert.assertEquals(m.invoke(policy, context, comp), Boolean.TRUE, "collections must not support canvas view roles");
    Mockito.when(comp.isLeaf()).thenReturn(true);
    Assert.assertEquals(m.invoke(policy, context, comp), Boolean.FALSE, "leafs must support canvas view roles");

  }
View Full Code Here

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

  }
 
  @Test
  public void testExecute() {
    Policy policy = new PlotViewPolicy();
    PolicyContext context;
   
    ViewInfo plotViewInfo = new ViewInfo(PlotViewManifestation.class, "Plot", ViewType.OBJECT);
   
    // Plot views should be allowed for leaf component with a feed
    context = new PolicyContext();
    context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(),
        plotViewInfo);
    context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
        leafWithAFeedComponent);   
    Assert.assertTrue(policy.execute(context).getStatus());

    // ...but not without a feed
    context = new PolicyContext();
    context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(),
        plotViewInfo);
    context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
        leafWithOutAFeedComponent);   
    Assert.assertFalse(policy.execute(context).getStatus());
   
    // Plot view policy should not reject non-plot, ever
    for (AbstractComponent ac : new AbstractComponent[] { leafWithAFeedComponent, leafWithOutAFeedComponent, nonLeafComponent} ) {
      for (ViewType vt : ViewType.values()) {
        ViewInfo someViewInfo = new ViewInfo(NonPlotView.class, "NonPlot", vt);
        context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(),
            someViewInfo);
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
            ac);   
        Assert.assertTrue(policy.execute(context).getStatus());
      }
    }
  }
View Full Code Here

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

  @BeforeMethod
  public void setup() {
    MockitoAnnotations.initMocks(this);
   
    policy = new PlotStringPolicy();
    context = new PolicyContext();
    viewInfo = new ViewInfo(PlotViewManifestation.class, "Plot", ViewType.OBJECT);
    context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(),
        viewInfo);
    context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
        mockProvider);
View Full Code Here

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

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

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

   
    @BeforeMethod
    public void init() {
        MockitoAnnotations.initMocks(this);
        embeddedPolicy = new EmbeddedCanvasViewsAreNotWriteable();
        context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), mockedComponent);
    }
View Full Code Here

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

        }

        protected ExecutionResult checkPolicyForDrops(AbstractComponent canvasComponent,
                        Collection<AbstractComponent> dropComponents,
                        View canvasManifestation) {
            PolicyContext context = new PolicyContext();
            context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
                            canvasComponent);
            context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(),
                            dropComponents);
            context
                            .setProperty(PolicyContext.PropertyName.ACTION.getName(), Character
                                            .valueOf('w'));
            context.setProperty(PolicyContext.PropertyName.VIEW_MANIFESTATION_PROVIDER.getName(),
                            canvasManifestation);
            String policyCategoryKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY.getKey();
            ExecutionResult result = PolicyManagerAccess.getPolicyManager().execute(
                            policyCategoryKey, context);
            return result;
View Full Code Here

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

        MockitoAnnotations.initMocks(this);
        dir = new MCTDirectoryArea();
        handler = new StubbedHandler(dir, tree, model);
        (new PlatformAccess()).setPlatform(mockPlatform);
        when(mockPlatform.getPolicyManager()).thenReturn(mockPolicyManager);
        ExecutionResult result = new ExecutionResult(new PolicyContext(), true, "mock");
        when(mockPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(result);
     }
View Full Code Here

Examples of org.wso2.carbon.policybuilder.ui.internal.context.PolicyContext

  public static void main(String[] args) {
    //  SymmetricBinding a = new SymmetricBinding(11);
    //   SignedEncryptedParts a = new SignedEncryptedParts(false,11);
    String[] myArgs = {"/home/usw/soap.txt"};
    PolicyBuilder pb = new PolicyBuilder();
    pb.injectContext(new PolicyContext());
    pb.start(myArgs);

    /*
        try {
          XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out) ;
View Full Code Here

Examples of org.wso2.carbon.policybuilder.ui.internal.context.PolicyContext

  private static Log log = LogFactory.getLog(ManualAssembler.class);
  public boolean hasNewConfig = false;


  public String assemble(String input) {
    Context context = new PolicyContext();
    context.init();
   
    SymmetricBinding symBind = new SymmetricBinding(11);
    AsymmetricBinding asymBind = new AsymmetricBinding(11);
    SignedEncryptedParts signedPartsBind = new SignedEncryptedParts(true, 11);
    SignedEncryptedParts encPartsBind = new SignedEncryptedParts(false, 11);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.