Package gov.nasa.arc.mct.components

Examples of gov.nasa.arc.mct.components.AbstractComponent


    @Test
    public void testActionPerformedNonDirty() {      
        Mockito.when(mockComponent.isDirty()).thenReturn(false);
       
        // The newer version of the component, for which a view should be created
        AbstractComponent newerComponent = Mockito.mock(AbstractComponent.class);
        Mockito.when(mockPersistence.getComponent("mock")).thenReturn(newerComponent);
       
        // Similarly, newer version of the view
        View newerView = Mockito.mock(View.class);
        Mockito.when(mockViewInfo.createView(newerComponent)).thenReturn(newerView);
View Full Code Here


    @Test (dataProvider = "truthData")
    public void testActionPerformedDirty(final boolean confirmed) {
        Mockito.when(mockComponent.isDirty()).thenReturn(true);
       
        // The newer version of the component, for which a view should be created
        AbstractComponent newerComponent = Mockito.mock(AbstractComponent.class);
        Mockito.when(mockPersistence.getComponent("mock")).thenReturn(newerComponent);
       
        // Similarly, newer version of the view
        View newerView = Mockito.mock(View.class);
        Mockito.when(mockViewInfo.createView(newerComponent)).thenReturn(newerView);      
View Full Code Here

       
        Answer<ExecutionResult> answer = new Answer<ExecutionResult> () {
            @Override
            public ExecutionResult answer(InvocationOnMock invocation) throws Throwable {
                PolicyContext context = (PolicyContext) invocation.getArguments()[1];
                AbstractComponent comp = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);
                return new ExecutionResult(context, goodComponents.contains(comp), "" );
            }           
        };
       
        Mockito.when(mockPolicyManager.execute(Mockito.eq(PolicyInfo.CategoryType.OBJECT_INSPECTION_POLICY_CATEGORY.getKey()), Mockito.<PolicyContext>any())).thenAnswer(answer);
View Full Code Here

        // returned by getModifiedObjects. Even when parent has not 'changed',
        // save all implies that changes to children are relevant to parent.
        // This verifies that parent is saved even when parent is not dirty.
       
        // Set up parent/child component such that SaveAll should be available
        final AbstractComponent child = generateComponent(true, true, true, null);
        final AbstractComponent comp = generateComponent(true, isDirty, true, child);

        // Elaborate mocking to simulate context menu activation
        MCTHousing mockHousing = Mockito.mock(MCTHousing.class);
        MCTContentArea mockContentArea = Mockito.mock(MCTContentArea.class);
        View mockView = Mockito.mock(View.class);
View Full Code Here

    private AbstractComponent generateComponent(boolean good, boolean dirty, boolean isObjectManager, AbstractComponent child) {
        String name = (good ? "valid " : "invalid ") +
                      (dirty ? "dirty " : "nonDirty ") +
                      (isObjectManager ? "objectManager " : "nonManager ") +
                      (child != null ? "parent" : "leaf");
        AbstractComponent mockComponent = Mockito.mock(AbstractComponent.class, name);
        Mockito.when(mockComponent.isDirty()).thenReturn(dirty);
        ObjectManager mockObjectManager = Mockito.mock(ObjectManager.class);
        if (isObjectManager) {
            Mockito.when(mockComponent.getCapability(ObjectManager.class)).thenReturn(mockObjectManager);
        }
        if (child != null) {
            Mockito.when(mockObjectManager.getAllModifiedObjects()).thenReturn(Collections.singleton(child));           
        } else {
            Mockito.when(mockObjectManager.getAllModifiedObjects()).thenReturn(Collections.<AbstractComponent>emptySet());
View Full Code Here

    public Object[][] generateWarningDialogCases() {
        List<Object[]> cases = new ArrayList<Object[]>();
        for (boolean action : new boolean[] { false, true }) {
            for (boolean confirm : new boolean[] { false, true }) {
                for (boolean partial : new boolean[] { false, true } ) {
                    AbstractComponent ac = generateWarningComponent(true, 3, partial ? 3 : 0);
                    Set<AbstractComponent> expect = new HashSet<AbstractComponent>();
                    expect.add(ac);
                    for (AbstractComponent c : ac.getCapability(ObjectManager.class).getAllModifiedObjects()) {
                        if (goodComponents.contains(c)) {
                            expect.add(c);
                        }
                    }
                    cases.add(new Object[] {
View Full Code Here

        return cases.toArray(new Object[cases.size()][]);
    }
   
    private AbstractComponent generateWarningComponent(boolean good, int goodChildren, int badChildren) {
        String name = (good ? "valid " : "invalid ");
        AbstractComponent mockComponent = Mockito.mock(AbstractComponent.class, name);
        Set<AbstractComponent> children = new HashSet<AbstractComponent>();       
        for (boolean g : new boolean[] { false, true }) {
            for (int i = 0; i < (g ? goodChildren : badChildren); i++) {
                children.add(generateWarningComponent(g, 0, 0));
            }
        }       
        Mockito.when(mockComponent.isDirty()).thenReturn(true);
        ObjectManager mockObjectManager = Mockito.mock(ObjectManager.class);
        Mockito.when(mockComponent.getCapability(ObjectManager.class)).thenReturn(mockObjectManager);
        Mockito.when(mockObjectManager.getAllModifiedObjects()).thenReturn(children);           
       
        if (good) {
            goodComponents.add(mockComponent);
        }
View Full Code Here

    boolean result = true;
    ViewInfo viewInfo = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);
   
   
    if (GraphicalManifestation.class.equals(viewInfo.getViewClass())) {
      AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);
      result = hasFeed(targetComponent);
    } else if (StaticGraphicalView.class.equals(viewInfo.getViewClass())) {
      AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);
      result = GraphicalComponent.class.isAssignableFrom(targetComponent.getClass());
    }

    return new ExecutionResult(context, result, null);
  }
View Full Code Here

    boolean result = true;
   
    ViewInfo viewInfo = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);
 
    if (viewInfo.getViewClass().equals(PlotViewManifestation.class)) {
      AbstractComponent targetComponent = context.getProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), AbstractComponent.class);
     
      if (targetComponent.isLeaf() && !hasFeed(targetComponent)) {
        String message = "Leaf is not a feed.";
        return new ExecutionResult(context, false, message);
      }
     
      result = !rejectCanvasView(context,targetComponent);
View Full Code Here

            .thenReturn(selection);
       
        // Setup selected nodes, including a parent
        int nodes = Math.max(canCompose.length, canDelete.length);
        selectedTreePaths = new TreePath[nodes];
        AbstractComponent mockParent = mockComponent(canDeleteParent, canComposeParent);
        MCTMutableTreeNode mockParentNode = Mockito.mock(MCTMutableTreeNode.class);
        View mockParentView = mockView(mockParent, ViewType.NODE);
        Mockito.when(mockParentNode.getUserObject()).thenReturn(mockParentView);

        for (int i = 0; i < nodes; i++) {
            AbstractComponent mockChild =
                    mockComponent(canDelete [i % canDelete.length ],
                                  canCompose[i % canCompose.length]);
           
            TreePath mockPath = Mockito.mock(TreePath.class);
            MCTMutableTreeNode mockTreeNode = Mockito.mock(MCTMutableTreeNode.class);
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.components.AbstractComponent

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.