Package gov.nasa.arc.mct.platform.spi

Examples of gov.nasa.arc.mct.platform.spi.Platform


                return view;
            }
        };
       
        PlatformAccess access = new PlatformAccess();
        Platform mockPlatform = Mockito.mock(Platform.class);
        PersistenceProvider mockPersistenceProvider = Mockito.mock(PersistenceProvider.class);
        access.setPlatform(mockPlatform);
        Mockito.when(mockPlatform.getPersistenceProvider()).thenReturn(mockPersistenceProvider);
        Mockito.when(mockPersistenceProvider.getComponent(component.getComponentId())).thenReturn(component);
        MCTViewManifestationInfo manifInfo = Mockito.mock(MCTViewManifestationInfo.class);       
        View view = CanvasViewStrategy.CANVAS_OWNED.createViewFromManifestInfo(viewInfo, component, canvasComponent, manifInfo);
        Assert.assertEquals(view.getManifestedComponent().getComponentId(), canvasComponent.getComponentId());
    }   
View Full Code Here


       
        when(transferable.getTransferData(eq(GOOD_FLAVOR))).thenReturn(new View[]{mockView});
       
        // Mock persistence provider, policy manager, and platform
        PlatformAccess access = new PlatformAccess();
        Platform mockPlatform = Mockito.mock(Platform.class);
        PersistenceProvider mockPersistenceProvider = Mockito.mock(PersistenceProvider.class);
        PolicyManager mockpoPolicyManager = Mockito.mock(PolicyManager.class);      
        CoreComponentRegistry mockComponentRegistry = Mockito.mock(CoreComponentRegistry.class);
        WindowManager mockWindowManager = Mockito.mock(WindowManager.class);
       
        access.setPlatform(mockPlatform);
        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>() {
View Full Code Here

       
        when(transferable.getTransferData(eq(GOOD_FLAVOR))).thenReturn(new View[]{sourceView});
       
        // Mock persistence provider, policy manager, and platform.
        PlatformAccess access = new PlatformAccess();
        Platform mockPlatform = Mockito.mock(Platform.class);
        PersistenceProvider mockPersistenceProvider = Mockito.mock(PersistenceProvider.class);
        PolicyManager mockpoPolicyManager = Mockito.mock(PolicyManager.class);      
        CoreComponentRegistry mockComponentRegistry = Mockito.mock(CoreComponentRegistry.class);
        WindowManager mockWindowManager = Mockito.mock(WindowManager.class);
       
        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>() {
                    @Override
                    public Object answer(InvocationOnMock invocation) throws Throwable {
View Full Code Here

    private void ensureInitialized() {
        if (!initialized) {
            String username = this.currentUser;
            // If PersistenceProvider & WindowManager are available, we can create a dialog with available users
            Platform platform = PlatformAccess.getPlatform();
            PersistenceProvider persistence = platform != null ? platform.getPersistenceProvider() : null;
            WindowManager windowing = platform != null ? platform.getWindowManager() : null;
           
            if (username == null && persistence != null && windowing != null) {
                Object[] users = persistence.getAllUsers().toArray();
                if (users.length > 1) {
                    Arrays.sort(users);
View Full Code Here

            }
           
            private WindowManager getWindowManager() {
                // Try to use the Platform's version, in case something other
                // than WindowManagerImpl has been injected somewhere.
                Platform platform = PlatformAccess.getPlatform();
                if (platform != null) {
                    WindowManager windowManager = platform.getWindowManager();
                    if (windowManager != null) {
                        return windowManager;
                    }
                }
                // Otherwise, fall back to this bundle's version.
View Full Code Here

            final String ADD_USER_PROP = "automatically.add.user";
            final String DEFAULT_GROUP_PROP = "default.user.group";
            if (Boolean.parseBoolean(System.getProperty(ADD_USER_PROP, MCTProperties.DEFAULT_MCT_PROPERTIES.getProperty(ADD_USER_PROP, "false")))) {
                // Default to "testUser1" if no user name was ever specified
                String userId = whoami != null ? whoami : bundle.getString("DEFAULT_USER"); //NOI18N 
                Platform platform = PlatformAccess.getPlatform();
               
                // determine if the platform has been initialized
                if (platform.getBootstrapComponents().isEmpty()) {
                    GlobalContext.getGlobalContext().switchUser(new User() {
                        @Override
                        public String getDisciplineId() {
                            return ""//rather than null, we should return an empty string --Harleigh;Issue127
                        }
                       
                        @Override
                        public User getValidUser(String userID) {
                            return null;
                        }
                       
                        @Override
                        public String getUserId() {
                            return whoami;
                        }
                    }, null);
                    platform.getDefaultComponentProvider().createDefaultComponents();
                    // invoke getting default components again to ensure the platform has been bootstrapped
                    platform.getBootstrapComponents();
                }
               
                AbstractComponent mySandbox = platform.getDefaultComponentProvider().createSandbox(userId);
                AbstractComponent dropbox = platform.getDefaultComponentProvider().createDropbox(userId);
               
                String group = System.getProperty(DEFAULT_GROUP_PROP, MCTProperties.DEFAULT_MCT_PROPERTIES.getProperty(DEFAULT_GROUP_PROP, ""));
                if (group.isEmpty()) {
                    throw new MCTRuntimeException("Default group not specified, set the default group in mct.properties using the " + DEFAULT_GROUP_PROP + " property.");
                }
                platform.getPersistenceProvider().addNewUser(userId, group, mySandbox, dropbox);
                currentUser = platform.getPersistenceProvider().getUser(userId);
            } else {
                throw new MCTRuntimeException("MCT user '" + whoami
                        + "' is not in the MCT database. You can load MCT user(s) using MCT's load user tool.");
            }
        }
View Full Code Here

            private boolean canComponentBeContained() {
                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
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.platform.spi.Platform

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.