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

        // mock another object
        UUID testUuid2 = UUID.randomUUID();
        ComponentInstance instance2 = mockComponentInstance(testUuid, "DuplicateName", null);
        FactoryObjectProxy testObjProxy2 = mock(FactoryObjectProxy.class);

        when(this.m_FactoryObjectDataManager.getPersistentUuid("DuplicateName")).thenReturn(testUuid2);

        // mock factory return (supports getting the PID)
        when(m_FactoryDescriptor.create()).thenReturn(testObjProxy, testObjProxy2);
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance, instance2);

        // replay
        m_SUT.createOrRestoreObject(m_FactoryDescriptor, testUuid);

        m_SUT.persistNewObjectData("DuplicateName", testUuid, m_FactoryDescriptor, true);

        verify(this.m_FactoryObjectDataManager).persistNewObjectData(eq(testUuid), eq(m_FactoryDescriptor),
                eq("DuplicateName" + testUuid.toString()));
    }
/**
     * Test that attempting to set a name with autoRename == true
     */
Test that attempting to set a name with autoRename == true
Test that attempting to set a name with autoRename == true
@Test
    public void testPersistObjectDataAutoRename() throws IllegalArgumentException, FactoryObjectInformationException,
        FactoryException
    {
        UUID testUuid = UUID.randomUUID();
        ComponentInstance instance = mockComponentInstance(testUuid, "DefaultName", null);
        FactoryObjectProxy testObjProxy = mock(FactoryObjectProxy.class);
        UUID testUuid2 = UUID.randomUUID();
        ComponentInstance instance2 = mockComponentInstance(testUuid, "DuplicateName", null);
        FactoryObjectProxy testObjProxy2 = mock(FactoryObjectProxy.class);
        when(this.m_FactoryObjectDataManager.getPersistentUuid("DuplicateName")).thenReturn(testUuid2);
        when(m_FactoryDescriptor.create()).thenReturn(testObjProxy, testObjProxy2);
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance, instance2);
        m_SUT.createOrRestoreObject(m_FactoryDescriptor, testUuid);
        m_SUT.persistNewObjectData("DuplicateName", testUuid, m_FactoryDescriptor, true);
        verify(this.m_FactoryObjectDataManager).persistNewObjectData(eq(testUuid), eq(m_FactoryDescriptor),
                eq("DuplicateName" + testUuid.toString()));
    }
@ Test public void testPersistObjectDataAutoRename ( ) throws IllegalArgumentException , FactoryObjectInformationException , FactoryException { UUID testUuid = UUID . randomUUID ( ) ; ComponentInstance instance = mockComponentInstance ( testUuid , "DefaultName" , null ) ; FactoryObjectProxy testObjProxy = mock ( FactoryObjectProxy . class ) ; UUID testUuid2 = UUID . randomUUID ( ) ; ComponentInstance instance2 = mockComponentInstance ( testUuid , "DuplicateName" , null ) ; FactoryObjectProxy testObjProxy2 = mock ( FactoryObjectProxy . class ) ; when ( this . m_FactoryObjectDataManager . getPersistentUuid ( "DuplicateName" ) ) . thenReturn ( testUuid2 ) ; when ( m_FactoryDescriptor . create ( ) ) . thenReturn ( testObjProxy , testObjProxy2 ) ; when ( m_ServiceProxy . createFactoryObjectInternal ( m_FactoryDescriptor ) ) . thenReturn ( instance , instance2 ) ; m_SUT . createOrRestoreObject ( m_FactoryDescriptor , testUuid ) ; m_SUT . persistNewObjectData ( "DuplicateName" , testUuid , m_FactoryDescriptor , true ) ; verify ( this . m_FactoryObjectDataManager ) . persistNewObjectData ( eq ( testUuid ) , eq ( m_FactoryDescriptor ) , eq ( "DuplicateName" + testUuid . toString ( ) ) ) ; }
Test that attempting to set a name with autoRename == true
Test that attempting to set a name with autoRename == true
// mock an object // mock another object // mock factory return (supports getting the PID) // replay