Package gov.nasa.arc.mct.policy

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


    }
  }
 
  @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


  @Test
  public void testStringPolicy() {
    context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), mockFeedProvider);
    context.setProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), graphicalViewInfo);
   
    Policy policy = new GraphicalStringPolicy();
   
    Mockito.when(mockFeedProvider.getFeedType()).thenReturn(FeedType.STRING);
    Assert.assertFalse(policy.execute(context).getStatus());
   
    Mockito.when(mockFeedProvider.getFeedType()).thenReturn(FeedType.INTEGER);
    Assert.assertTrue(policy.execute(context).getStatus());
   
    Mockito.when(mockFeedProvider.getFeedType()).thenReturn(FeedType.FLOATING_POINT);
    Assert.assertTrue(policy.execute(context).getStatus());
  }
View Full Code Here

TOP

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

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.