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

Examples of gov.nasa.arc.mct.services.internal.component.CoreComponentRegistry


    @Test
    public void testCreateDropBox() {
        // Regression test for root cause of https://github.com/nasa/mct/issues/281
        String id = "someTestUser";
       
        CoreComponentRegistry mockRegistry = Mockito.mock(CoreComponentRegistry.class);
        Mockito.when(mockPlatform.getComponentRegistry()).thenReturn(mockRegistry);
        Mockito.when(mockRegistry.newInstance(Mockito.anyString()))
            .thenAnswer(new Answer<AbstractComponent>() {
                @Override
                public AbstractComponent answer(InvocationOnMock invocation) throws Throwable {
                    return AbstractComponent.class.cast(
                            Class.forName(invocation.getArguments()[0].toString()).newInstance()
View Full Code Here


     * @return an object of the desired type (or null if none is available)
     */
    public <A> A getAsset(Class<A> assetClass) {
        Platform platform = PlatformAccess.getPlatform();
        if (platform != null) {
            CoreComponentRegistry registry = platform.getComponentRegistry();
            if (registry != null) {
                return registry.getAsset(this, assetClass);
            }
        }
        return null;
    }
View Full Code Here

                            return;
                        }

                        Platform platform = PlatformAccess.getPlatform();
                        PersistenceProvider persistenceService = platform.getPersistenceProvider();
                        CoreComponentRegistry componentRegistry = platform.getComponentRegistry();
                        AbstractComponent mySandbox = componentRegistry.newInstance(MineTaxonomyComponent.class.getName());
                        ComponentInitializer mysandboxCapability = mySandbox.getCapability(ComponentInitializer.class);
                        mysandboxCapability.setCreator(userId);
                        mysandboxCapability.setOwner(userId);
                        mySandbox.setDisplayName("My Sandbox");
                                               
                        AbstractComponent dropbox = componentRegistry.newInstance(TelemetryUserDropBoxComponent.class.getName());
                        ComponentInitializer dropboxCapability = dropbox.getCapability(ComponentInitializer.class);
                        dropboxCapability.setCreator("admin");
                        dropboxCapability.setOwner("*");
                        dropbox.setDisplayName(userId + "\'s drop box");

View Full Code Here

    @Test
    public void testDeprecatedMethods() {
        // Verify that deprecated methods are redirected to getAsset
        Platform oldPlatform = PlatformAccess.getPlatform();
        Platform mockPlatform = Mockito.mock(Platform.class);
        CoreComponentRegistry mockRegistry = Mockito.mock(CoreComponentRegistry.class);
        Mockito.when(mockPlatform.getComponentRegistry()).thenReturn(mockRegistry);
        new PlatformAccess().setPlatform(mockPlatform);
       
        ComponentTypeInfo info;
        info = new ComponentTypeInfo("","",AbstractComponent.class);
View Full Code Here

    @Test
    public void testGetAsset() {
        // Verify that getAsset is robust to null platform, etc
        Platform oldPlatform = PlatformAccess.getPlatform();
        Platform mockPlatform = Mockito.mock(Platform.class);
        CoreComponentRegistry mockRegistry = Mockito.mock(CoreComponentRegistry.class);
        Icon mockIcon = Mockito.mock(Icon.class);
       
        TypeInfo<?> info = new TypeInfo<TypeInfoTest>(TypeInfoTest.class){};
       
        // Try with a null platform - should fail to retrieve asset
        new PlatformAccess().setPlatform(null);
        Assert.assertNull(info.getAsset(Icon.class));       
       
        // Try with a platform but no registry - should fail to retrieve asset
        new PlatformAccess().setPlatform(mockPlatform);
        Assert.assertNull(info.getAsset(Icon.class));       
              
        // Try with a mock registry (but no assets) - should fail to retrieve
        Mockito.when(mockPlatform.getComponentRegistry()).thenReturn(mockRegistry);
        Assert.assertNull(info.getAsset(Icon.class));       
               
        // Try with a mock registry that has the requested asset - should retrieve it
        Mockito.when(mockRegistry.getAsset(info, Icon.class)).thenReturn(mockIcon);
        Assert.assertEquals(info.getAsset(Icon.class), mockIcon);       
       
        // Restore old platform
        new PlatformAccess().setPlatform(oldPlatform);
    }
View Full Code Here

    }
   
    @Override
    public AbstractComponent createSandbox(String userId) {
        Platform platform = PlatformAccess.getPlatform();
        CoreComponentRegistry componentRegistry = platform.getComponentRegistry();
        AbstractComponent mySandbox = componentRegistry.newInstance(MineTaxonomyComponent.class.getName());
        ComponentInitializer mysandboxCapability = mySandbox.getCapability(ComponentInitializer.class);
        mysandboxCapability.setCreator(userId);
        mysandboxCapability.setOwner(userId);
        mySandbox.setDisplayName("My Sandbox");
       
View Full Code Here

    }
   
    @Override
    public void createDefaultComponents() {
        Platform platform = PlatformAccess.getPlatform();
        CoreComponentRegistry componentRegistry = platform.getComponentRegistry();
       
        AbstractComponent dropBoxes = componentRegistry.newInstance(TelemetryDataTaxonomyComponent.class.getName());
        dropBoxes.setDisplayName("User Drop Boxes");
        dropBoxes.setExternalKey("/UserDropBoxes");
        ComponentInitializer dropBoxesCapability = dropBoxes.getCapability(ComponentInitializer.class);
        dropBoxesCapability.setCreator("admin");
        dropBoxesCapability.setOwner("admin");
View Full Code Here

    public void userAdded(String session, String userId, String group) {
        Map<AbstractComponent, Collection<AbstractComponent>> userMap = new HashMap<AbstractComponent, Collection<AbstractComponent>>();
        map.put(userId + DELIM + group, userMap);
       
        PersistenceProvider persistenceService = PlatformAccess.getPlatform().getPersistenceProvider();
        CoreComponentRegistry componentRegistry = PlatformAccess.getPlatform().getComponentRegistry();
                       
        AbstractComponent mySandbox = createMySandbox(persistenceService, componentRegistry, session, userMap, userId, group);
        createUserDropbox(persistenceService, session, userMap, userId, group, mySandbox);       
    }
View Full Code Here

    //Harleigh108: this removes the warning received when we build with respect to java 7: deprecation is for PREFERRED_VIEW
    @SuppressWarnings({ "rawtypes", "deprecation" })
    @Test(dataProvider="viewInfoData")
    public void testGetViewInfos(Set<ViewInfo> viewInfos, final Set<ViewInfo> filterOut, ViewType type, Set<ViewInfo> expected) {
        AbstractComponent ac = new BaseComponentSub2();
        CoreComponentRegistry mockRegistry = Mockito.mock(CoreComponentRegistry.class);
        PolicyManager mockPolicyManager = Mockito.mock(PolicyManager.class);
        Mockito.when(mockPlatform.getComponentRegistry()).thenReturn(mockRegistry);
        Mockito.when(mockRegistry.getViewInfos(Mockito.anyString(), Mockito.same(type))).thenReturn(viewInfos);
        Mockito.when(mockPlatform.getPolicyManager()).thenReturn(mockPolicyManager);
        Mockito.when(mockPolicyManager.execute(Mockito.matches(PolicyInfo.CategoryType.FILTER_VIEW_ROLE.getKey()), Mockito.any(PolicyContext.class))).thenAnswer(
                        new Answer() {
                            public Object answer(InvocationOnMock invocation) {
                                Object[] args = invocation.getArguments();
View Full Code Here

        // 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);
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.services.internal.component.CoreComponentRegistry

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.