Package gov.nasa.arc.mct.policy

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


*/
public class CheckBuiltinComponentPolicy implements Policy {

    @Override
    public ExecutionResult execute(PolicyContext context) {       
        ExecutionResult trueResult = new ExecutionResult(context, true, "");
        AbstractComponent target = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);
        String displayName = target.getDisplayName();
       
        if (target instanceof MineTaxonomyComponent)
            return new ExecutionResult(context, false, displayName + " cannot be modified.");
        return trueResult;
    }
View Full Code Here


    @Override
    public ExecutionResult execute(PolicyContext context) {
        AbstractComponent target = context.getProperty("TARGET", AbstractComponent.class);
        if (canChangeOwnership(target)) {
            return new ExecutionResult(context, true, "");
        }
        return new ExecutionResult(context, false, "Permission denied on " + target.getDisplayName());
    }
View Full Code Here

    private static final String EM_STR = "";

    @Override
    public ExecutionResult execute(PolicyContext context) {
      AbstractComponent rootComponent = PlatformAccess.getPlatform().getRootComponent();
        ExecutionResult trueResult = new ExecutionResult(context, true, EM_STR);
        TelemetryDataTaxonomyComponent component = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), TelemetryDataTaxonomyComponent.class);
        if (component == null || component != rootComponent)
            return trueResult;
       
        ViewType viewType = context.getProperty(PolicyContext.PropertyName.VIEW_TYPE.getName(), ViewType.class);
        return viewType != ViewType.OBJECT ? trueResult : new ExecutionResult(context, false, EM_STR);
    }
View Full Code Here

    }
   
    String message = result ? "Requested Plot View has two or more children with data feeds." :
                "Requested Plot View did not have two or more children with data feeds.";
   
    return new ExecutionResult(context, result, message);

  }
View Full Code Here

    public void setup() {
        PolicyManager mockManager = new PolicyManager() {
           
            @Override
            public ExecutionResult execute(String categoryKey, PolicyContext context) {
                return new ExecutionResult(null, true, null);
            }
        };
       
        MockitoAnnotations.initMocks(this);
        Mockito.when(mockPlatform.getPolicyManager()).thenReturn(mockManager);
View Full Code Here

                        new Answer() {
                            public Object answer(InvocationOnMock invocation) {
                                Object[] args = invocation.getArguments();
                                PolicyContext pc = (PolicyContext) args[1];
                                ViewInfo vi = pc.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);
                                return new ExecutionResult(pc, !filterOut.contains(vi), "");
                            }
                        }
        );
        Mockito.when(mockPolicyManager.execute(Mockito.matches(PolicyInfo.CategoryType.PREFERRED_VIEW.getKey()), Mockito.any(PolicyContext.class))).thenReturn(new ExecutionResult(new PolicyContext(),true, ""));
        Set<ViewInfo> infos = ac.getViewInfos(type);
        Assert.assertEquals(infos, expected);
    }
View Full Code Here

 
  @Test
  public void testGetNonCompoundPlotComponents() {
    (new PolicyManagerAccess()).setPolicyManager(mockPolicyManager);
    Mockito.when(mockPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(
        new ExecutionResult(null,true,"test"));
   
    AbstractComponent[][] components = PlotViewPolicy.getPlotComponents(leafWithAFeedComponent, true);
    Assert.assertEquals(components.length,1);
    Assert.assertSame(components[0][0], leafWithAFeedComponent);
   
View Full Code Here

 
  @Test
  public void testGetCompoundPlotComponents() {
    (new PolicyManagerAccess()).setPolicyManager(mockPolicyManager);
    Mockito.when(mockPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(
        new ExecutionResult(null,true,"test"));
    // setup compound components with a child that requires a plot.
    List<AbstractComponent> childComponents = new ArrayList<AbstractComponent>();
    childComponents.add(leafWithAFeedComponent)
    childComponents.add(leafWithOutAFeedComponent);
    Mockito.when(compoundComponent.getComponents()).thenReturn(childComponents);
View Full Code Here

 
  @Test
  public void testGetCompoundPlotComponentsWithChildren() {
    (new PolicyManagerAccess()).setPolicyManager(mockPolicyManager);
    Mockito.when(mockPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(
        new ExecutionResult(null,true,"test"));
    // setup compound components with a child that requires a plot.
    List<AbstractComponent> childComponents = new ArrayList<AbstractComponent>();
    String start = "A";
    for (int i = 0; i < 12; i++) {
      AbstractComponent child = createComponentWithChildren(12, start);
View Full Code Here

   
    if (ExecutableButtonManifestation.class.equals(viewInfo.getViewClass())) {
      AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), ExecutableButtonComponent.class);
      result = !ExecutableButtonComponent.class.isAssignableFrom(targetComponent.getClass());
    }
    return new ExecutionResult(context, result, null);
  }
View Full Code Here

TOP

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

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.