mil.dod.th.ose.core/test/mil/dod/th/ose/core/factory/api/TestFactoryRegistry.java
@Test
    public void testCreateWithConfigUnsetPid() throws IllegalArgumentException,
        FactoryException, FactoryObjectInformationException
    {
        // mock a factory object
        UUID testUuid = UUID.randomUUID();
        ComponentInstance instance = mockComponentInstance(testUuid, "DefaultName", "some_pid");
        FactoryObjectProxy testObjProxy = mock(FactoryObjectProxy.class);

        // set up fake object factory
        when(m_FactoryDescriptor.create()).thenReturn(testObjProxy);
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance);

        // replay
        FactoryObject obj = m_SUT.createOrRestoreObject(m_FactoryDescriptor, testUuid);

        //verify PID is set
        assertThat(obj.getPid(), is("some_pid"));

        //unset Pid
        m_SUT.unAssignPidForObj((FactoryObjectInternal)obj);

        //verify pid unset
        verify((FactoryObjectInternal)instance.getInstance()).setPid(null);
        verify(m_FactoryObjectDataManager).clearPid(testUuid);
        verify(m_FactoryService).postFactoryObjectEvent(eq(FactoryDescriptor.TOPIC_FACTORY_OBJ_PID_REMOVED),
                eq((FactoryObjectInternal)obj));
    }
/**
     * Test unsetting the PID for an already created object.
     */
Test unsetting the PID for an already created object.
Test unsetting the PID for an already created object .
@Test
    public void testCreateWithConfigUnsetPid() throws IllegalArgumentException,
        FactoryException, FactoryObjectInformationException
    {
        UUID testUuid = UUID.randomUUID();
        ComponentInstance instance = mockComponentInstance(testUuid, "DefaultName", "some_pid");
        FactoryObjectProxy testObjProxy = mock(FactoryObjectProxy.class);
        when(m_FactoryDescriptor.create()).thenReturn(testObjProxy);
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance);
        FactoryObject obj = m_SUT.createOrRestoreObject(m_FactoryDescriptor, testUuid);
        assertThat(obj.getPid(), is("some_pid"));
        m_SUT.unAssignPidForObj((FactoryObjectInternal)obj);
        verify((FactoryObjectInternal)instance.getInstance()).setPid(null);
        verify(m_FactoryObjectDataManager).clearPid(testUuid);
        verify(m_FactoryService).postFactoryObjectEvent(eq(FactoryDescriptor.TOPIC_FACTORY_OBJ_PID_REMOVED),
                eq((FactoryObjectInternal)obj));
    }
@ Test public void testCreateWithConfigUnsetPid ( ) throws IllegalArgumentException , FactoryException , FactoryObjectInformationException { UUID testUuid = UUID . randomUUID ( ) ; ComponentInstance instance = mockComponentInstance ( testUuid , "DefaultName" , "some_pid" ) ; FactoryObjectProxy testObjProxy = mock ( FactoryObjectProxy . class ) ; when ( m_FactoryDescriptor . create ( ) ) . thenReturn ( testObjProxy ) ; when ( m_ServiceProxy . createFactoryObjectInternal ( m_FactoryDescriptor ) ) . thenReturn ( instance ) ; FactoryObject obj = m_SUT . createOrRestoreObject ( m_FactoryDescriptor , testUuid ) ; assertThat ( obj . getPid ( ) , is ( "some_pid" ) ) ; m_SUT . unAssignPidForObj ( ( FactoryObjectInternal ) obj ) ; verify ( ( FactoryObjectInternal ) instance . getInstance ( ) ) . setPid ( null ) ; verify ( m_FactoryObjectDataManager ) . clearPid ( testUuid ) ; verify ( m_FactoryService ) . postFactoryObjectEvent ( eq ( FactoryDescriptor . TOPIC_FACTORY_OBJ_PID_REMOVED ) , eq ( ( FactoryObjectInternal ) obj ) ) ; }
Test unsetting the PID for an already created object.
Test unsetting the PID for an already created object .
// mock a factory object // set up fake object factory // replay //verify PID is set //unset Pid //verify pid unset