Package gov.nasa.arc.mct.services.component

Examples of gov.nasa.arc.mct.services.component.PolicyManager.execute()


        Mockito.when(mockPolicy.execute(Mockito.eq(compositionKey), Mockito.<PolicyContext>any()))
            .thenReturn(new ExecutionResult(null, false, ""));
        Assert.assertFalse(thisMenu.canHandle(mockContext));
       
        // If policy allows, then canHandle should be true
        Mockito.when(mockPolicy.execute(Mockito.eq(compositionKey), Mockito.<PolicyContext>any()))
            .thenReturn(new ExecutionResult(null, true, ""));
        Assert.assertTrue(thisMenu.canHandle(mockContext));
       
       
        // Second, Objects's Import menu
View Full Code Here


       
        // One selection but policy says no - should disallow
        Mockito.when(mockContext.getSelectedManifestations())
            .thenReturn(Arrays.asList(mockView));
        Mockito.when(mockView.getManifestedComponent()).thenReturn(mockComponent);       
        Mockito.when(mockPolicy.execute(Mockito.eq(compositionKey), Mockito.<PolicyContext>any()))
            .thenReturn(new ExecutionResult(null, false, ""));              
        Assert.assertFalse(objsMenu.canHandle(mockContext));
       
        // One selection but policy says yes - should allow!
        Mockito.when(mockContext.getSelectedManifestations())
View Full Code Here

       
        // One selection but policy says yes - should allow!
        Mockito.when(mockContext.getSelectedManifestations())
            .thenReturn(Arrays.asList(mockView));
        Mockito.when(mockView.getManifestedComponent()).thenReturn(mockComponent);       
        Mockito.when(mockPolicy.execute(Mockito.eq(compositionKey), Mockito.<PolicyContext>any()))
            .thenReturn(new ExecutionResult(null, true, ""));              
        Assert.assertTrue(objsMenu.canHandle(mockContext));
       
        // Multiple selections, even though policy says yes - should disallow
        Mockito.when(mockContext.getSelectedManifestations())
View Full Code Here

       
        // Multiple selections, even though policy says yes - should disallow
        Mockito.when(mockContext.getSelectedManifestations())
            .thenReturn(Arrays.asList(mockView, mockView));
        Mockito.when(mockView.getManifestedComponent()).thenReturn(mockComponent);       
        Mockito.when(mockPolicy.execute(Mockito.eq(compositionKey), Mockito.<PolicyContext>any()))
            .thenReturn(new ExecutionResult(null, true, ""));              
        Assert.assertFalse(objsMenu.canHandle(mockContext));

    }
}
View Full Code Here

        Mockito.when(mockPlatform.getPersistenceProvider()).thenReturn(mockPersistenceProvider);
        Mockito.when(mockPlatform.getPolicyManager()).thenReturn(mockPolicyManager);
        Mockito.when(mockPlatform.getComponentRegistry()).thenReturn(mockComponentRegistry);
        Mockito.when(mockPlatform.getWindowManager()).thenReturn(mockWindowManager);
        ExecutionResult mockResult = new ExecutionResult(new PolicyContext(), true, "");
        Mockito.when(mockpoPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(mockResult);
        Mockito.when(mockWindowManager.<Object>showInputDialog(
                Mockito.anyString(), Mockito.anyString(), Mockito.<Object[]>any(), Mockito.any(), Mockito.anyMap()))
                .thenAnswer(new Answer<Object>() {
                    @Override
                    public Object answer(InvocationOnMock invocation) throws Throwable {
View Full Code Here

       
        access.setPlatform(mockPlatform);
        Mockito.when(mockPlatform.getPersistenceProvider()).thenReturn(mockPersistenceProvider);
        Mockito.when(mockPlatform.getPolicyManager()).thenReturn(mockPolicyManager);       
        ExecutionResult mockResult = new ExecutionResult(new PolicyContext(), true, "");
        Mockito.when(mockpoPolicyManager.execute(Mockito.anyString(), Mockito.any(PolicyContext.class))).thenReturn(mockResult);
        Mockito.when(mockPlatform.getComponentRegistry()).thenReturn(mockComponentRegistry);
        Mockito.when(mockPlatform.getWindowManager()).thenReturn(mockWindowManager);
        Mockito.when(mockWindowManager.<Object>showInputDialog(
                Mockito.anyString(), Mockito.anyString(), Mockito.<Object[]>any(), Mockito.any(), Mockito.anyMap()))
                .thenAnswer(new Answer<Object>() {
View Full Code Here

                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();
            }
           
            @Override
            protected Transferable createTransferable(JComponent c) {
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.