mil.dod.th.ose.core/test/mil/dod/th/ose/core/factory/api/TestFactoryRegistry.java
@Test
    public void testCreateProperties() throws FactoryException, ConfigurationException, IllegalArgumentException,
        FactoryObjectInformationException
    {
        when(m_FactoryDescriptor.getProductType()).thenReturn("product type");
        FactoryObjectProxy factoryObjectProxy = mock(FactoryObjectProxy.class);
        ComponentInstance instance = mockComponentInstance(UUID.randomUUID(), "name", "samplepid");

        when(m_FactoryDescriptor.create()).thenReturn(factoryObjectProxy);
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance);

        Dictionary<String, Object> metaDefaults = new Hashtable<String, Object>();
        metaDefaults.put("toaster", "bread");
        when(m_Utils.getMetaTypeDefaults(m_FactoryDescriptor)).thenReturn(metaDefaults);

        Map<String, Object> properties = new HashMap<>();

        // replay
        m_SUT.createNewObject(m_FactoryDescriptor, "samplepid", properties);

        // verify dictionary passed to factory is correct
        verify(m_FactoryDescriptor).create();

        //verify object has been created
        FactoryObjectInternal fObjInternal = (FactoryObjectInternal)instance.getInstance();
        verify(m_FactoryService).postFactoryObjectEvent(eq(FactoryDescriptor.TOPIC_FACTORY_OBJ_CREATED),
                eq(fObjInternal));

        //verify factory object has been initialized
        verify(fObjInternal).initialize(eq(m_SUT),
                eq(factoryObjectProxy), eq(m_FactoryDescriptor),
                eq(m_ConfigAdmin), eq(m_EventAdmin), eq(m_PowerInternal), Mockito.any(UUID.class),
                Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
        verify(m_ServiceProxy).initializeProxy(fObjInternal, factoryObjectProxy, new HashMap<String, Object>());
    }
/**
     * Test that when an object is created thru the registry that a the service helper and factory is added to the
     * dictionary.  Also verify that factory object has made call to initialize properties.
     */
Test that when an object is created thru the registry that a the service helper and factory is added to the
dictionary.  Also verify that factory object has made call to initialize properties.
Test that when an object is created thru the registry that a the service helper and factory is added to the dictionary . Also verify that factory object has made call to initialize properties .
@Test
    public void testCreateProperties() throws FactoryException, ConfigurationException, IllegalArgumentException,
        FactoryObjectInformationException
    {
        when(m_FactoryDescriptor.getProductType()).thenReturn("product type");
        FactoryObjectProxy factoryObjectProxy = mock(FactoryObjectProxy.class);
        ComponentInstance instance = mockComponentInstance(UUID.randomUUID(), "name", "samplepid");
        when(m_FactoryDescriptor.create()).thenReturn(factoryObjectProxy);
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance);
        Dictionary<String, Object> metaDefaults = new Hashtable<String, Object>();
        metaDefaults.put("toaster", "bread");
        when(m_Utils.getMetaTypeDefaults(m_FactoryDescriptor)).thenReturn(metaDefaults);
        Map<String, Object> properties = new HashMap<>();
        m_SUT.createNewObject(m_FactoryDescriptor, "samplepid", properties);
        verify(m_FactoryDescriptor).create();
        FactoryObjectInternal fObjInternal = (FactoryObjectInternal)instance.getInstance();
        verify(m_FactoryService).postFactoryObjectEvent(eq(FactoryDescriptor.TOPIC_FACTORY_OBJ_CREATED),
                eq(fObjInternal));
        verify(fObjInternal).initialize(eq(m_SUT),
                eq(factoryObjectProxy), eq(m_FactoryDescriptor),
                eq(m_ConfigAdmin), eq(m_EventAdmin), eq(m_PowerInternal), Mockito.any(UUID.class),
                Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
        verify(m_ServiceProxy).initializeProxy(fObjInternal, factoryObjectProxy, new HashMap<String, Object>());
    }
@ Test public void testCreateProperties ( ) throws FactoryException , ConfigurationException , IllegalArgumentException , FactoryObjectInformationException { when ( m_FactoryDescriptor . getProductType ( ) ) . thenReturn ( "product type" ) ; FactoryObjectProxy factoryObjectProxy = mock ( FactoryObjectProxy . class ) ; ComponentInstance instance = mockComponentInstance ( UUID . randomUUID ( ) , "name" , "samplepid" ) ; when ( m_FactoryDescriptor . create ( ) ) . thenReturn ( factoryObjectProxy ) ; when ( m_ServiceProxy . createFactoryObjectInternal ( m_FactoryDescriptor ) ) . thenReturn ( instance ) ; Dictionary < String , Object > metaDefaults = new Hashtable < String , Object > ( ) ; metaDefaults . put ( "toaster" , "bread" ) ; when ( m_Utils . getMetaTypeDefaults ( m_FactoryDescriptor ) ) . thenReturn ( metaDefaults ) ; Map < String , Object > properties = new HashMap < > ( ) ; m_SUT . createNewObject ( m_FactoryDescriptor , "samplepid" , properties ) ; verify ( m_FactoryDescriptor ) . create ( ) ; FactoryObjectInternal fObjInternal = ( FactoryObjectInternal ) instance . getInstance ( ) ; verify ( m_FactoryService ) . postFactoryObjectEvent ( eq ( FactoryDescriptor . TOPIC_FACTORY_OBJ_CREATED ) , eq ( fObjInternal ) ) ; verify ( fObjInternal ) . initialize ( eq ( m_SUT ) , eq ( factoryObjectProxy ) , eq ( m_FactoryDescriptor ) , eq ( m_ConfigAdmin ) , eq ( m_EventAdmin ) , eq ( m_PowerInternal ) , Mockito . any ( UUID . class ) , Mockito . anyString ( ) , Mockito . anyString ( ) , Mockito . anyString ( ) ) ; verify ( m_ServiceProxy ) . initializeProxy ( fObjInternal , factoryObjectProxy , new HashMap < String , Object > ( ) ) ; }
Test that when an object is created thru the registry that a the service helper and factory is added to the
 dictionary.
Test that when an object is created thru the registry that a the service helper and factory is added to the dictionary .
// replay // verify dictionary passed to factory is correct //verify object has been created //verify factory object has been initialized