mil.dod.th.ose.core/test/mil/dod/th/ose/core/factory/api/TestFactoryRegistry.java
@SuppressWarnings("unchecked")
    @Test
    public void testCreateNewObject() throws IllegalArgumentException,
        FactoryException, FactoryObjectInformationException, ConfigurationException, IOException
    {
        // mock
        ComponentInstance instance = mockComponentInstance(UUID.randomUUID(), "name", null);
        FactoryObjectInternal fInternal = (FactoryObjectInternal)instance.getInstance();
        FactoryObjectProxy proxy = mock(FactoryObjectProxy.class);

        when(m_FactoryDescriptor.create()).thenReturn(proxy);
        when(m_FactoryDescriptor.getPid()).thenReturn("some.pid");
        when(m_FactoryObjectDataManager.getPersistentUuid("name")).thenReturn(null);
        when(m_FactoryObjectDataManager.getPid(Mockito.any(UUID.class))).thenReturn(null);
        when(m_FactoryObjectDataManager.getName(Mockito.any(UUID.class))).thenReturn("name");
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance);

        // replay
        m_SUT.createNewObject(m_FactoryDescriptor, "name",
                new ImmutableMap.Builder<String, Object>().put("key", "value").build());

        // verify
        verify(m_FactoryObjectDataManager).persistNewObjectData(Mockito.any(UUID.class),
                eq(m_FactoryDescriptor), eq("name"));

        verify(m_ServiceProxy).createFactoryObjectInternal(m_FactoryDescriptor);
        verify(m_FactoryDescriptor).create();

        InOrder inOrder = inOrder(m_Callback, m_ServiceProxy, fInternal);
        inOrder.verify(fInternal).initialize(eq(m_SUT), eq(proxy), eq(m_FactoryDescriptor),
                eq(m_ConfigAdmin), eq(m_EventAdmin), eq(m_PowerInternal),
                Mockito.any(UUID.class), eq("name"), Mockito.anyString(), Mockito.anyString());

        inOrder.verify(m_Callback).preObjectInitialize(fInternal);

        inOrder.verify(m_ServiceProxy).initializeProxy(eq(fInternal), eq(proxy), Mockito.anyMap());

        inOrder.verify(m_Callback).postObjectInitialize(fInternal);

        verify(m_ConfigAdmin).createFactoryConfiguration("some.pid", null);
    }
/**
     * Verify that a new object is properly created when objects are passed in.
     */
Verify that a new object is properly created when objects are passed in.
Verify that a new object is properly created when objects are passed in .
@SuppressWarnings("unchecked")
    @Test
    public void testCreateNewObject() throws IllegalArgumentException,
        FactoryException, FactoryObjectInformationException, ConfigurationException, IOException
    {
        ComponentInstance instance = mockComponentInstance(UUID.randomUUID(), "name", null);
        FactoryObjectInternal fInternal = (FactoryObjectInternal)instance.getInstance();
        FactoryObjectProxy proxy = mock(FactoryObjectProxy.class);
        when(m_FactoryDescriptor.create()).thenReturn(proxy);
        when(m_FactoryDescriptor.getPid()).thenReturn("some.pid");
        when(m_FactoryObjectDataManager.getPersistentUuid("name")).thenReturn(null);
        when(m_FactoryObjectDataManager.getPid(Mockito.any(UUID.class))).thenReturn(null);
        when(m_FactoryObjectDataManager.getName(Mockito.any(UUID.class))).thenReturn("name");
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance);
        m_SUT.createNewObject(m_FactoryDescriptor, "name",
                new ImmutableMap.Builder<String, Object>().put("key", "value").build());
        verify(m_FactoryObjectDataManager).persistNewObjectData(Mockito.any(UUID.class),
                eq(m_FactoryDescriptor), eq("name"));
        verify(m_ServiceProxy).createFactoryObjectInternal(m_FactoryDescriptor);
        verify(m_FactoryDescriptor).create();
        InOrder inOrder = inOrder(m_Callback, m_ServiceProxy, fInternal);
        inOrder.verify(fInternal).initialize(eq(m_SUT), eq(proxy), eq(m_FactoryDescriptor),
                eq(m_ConfigAdmin), eq(m_EventAdmin), eq(m_PowerInternal),
                Mockito.any(UUID.class), eq("name"), Mockito.anyString(), Mockito.anyString());
        inOrder.verify(m_Callback).preObjectInitialize(fInternal);
        inOrder.verify(m_ServiceProxy).initializeProxy(eq(fInternal), eq(proxy), Mockito.anyMap());
        inOrder.verify(m_Callback).postObjectInitialize(fInternal);
        verify(m_ConfigAdmin).createFactoryConfiguration("some.pid", null);
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testCreateNewObject ( ) throws IllegalArgumentException , FactoryException , FactoryObjectInformationException , ConfigurationException , IOException { ComponentInstance instance = mockComponentInstance ( UUID . randomUUID ( ) , "name" , null ) ; FactoryObjectInternal fInternal = ( FactoryObjectInternal ) instance . getInstance ( ) ; FactoryObjectProxy proxy = mock ( FactoryObjectProxy . class ) ; when ( m_FactoryDescriptor . create ( ) ) . thenReturn ( proxy ) ; when ( m_FactoryDescriptor . getPid ( ) ) . thenReturn ( "some.pid" ) ; when ( m_FactoryObjectDataManager . getPersistentUuid ( "name" ) ) . thenReturn ( null ) ; when ( m_FactoryObjectDataManager . getPid ( Mockito . any ( UUID . class ) ) ) . thenReturn ( null ) ; when ( m_FactoryObjectDataManager . getName ( Mockito . any ( UUID . class ) ) ) . thenReturn ( "name" ) ; when ( m_ServiceProxy . createFactoryObjectInternal ( m_FactoryDescriptor ) ) . thenReturn ( instance ) ; m_SUT . createNewObject ( m_FactoryDescriptor , "name" , new ImmutableMap . Builder < String , Object > ( ) . put ( "key" , "value" ) . build ( ) ) ; verify ( m_FactoryObjectDataManager ) . persistNewObjectData ( Mockito . any ( UUID . class ) , eq ( m_FactoryDescriptor ) , eq ( "name" ) ) ; verify ( m_ServiceProxy ) . createFactoryObjectInternal ( m_FactoryDescriptor ) ; verify ( m_FactoryDescriptor ) . create ( ) ; InOrder inOrder = inOrder ( m_Callback , m_ServiceProxy , fInternal ) ; inOrder . verify ( fInternal ) . initialize ( eq ( m_SUT ) , eq ( proxy ) , eq ( m_FactoryDescriptor ) , eq ( m_ConfigAdmin ) , eq ( m_EventAdmin ) , eq ( m_PowerInternal ) , Mockito . any ( UUID . class ) , eq ( "name" ) , Mockito . anyString ( ) , Mockito . anyString ( ) ) ; inOrder . verify ( m_Callback ) . preObjectInitialize ( fInternal ) ; inOrder . verify ( m_ServiceProxy ) . initializeProxy ( eq ( fInternal ) , eq ( proxy ) , Mockito . anyMap ( ) ) ; inOrder . verify ( m_Callback ) . postObjectInitialize ( fInternal ) ; verify ( m_ConfigAdmin ) . createFactoryConfiguration ( "some.pid" , null ) ; }
Verify that a new object is properly created when objects are passed in.
Verify that a new object is properly created when objects are passed in .
// mock // replay // verify