mil.dod.th.ose.core/test/mil/dod/th/ose/core/factory/api/TestFactoryRegistry.java
@Test
    public void testPersistObjectDataNameAlreadyKnown() throws IllegalArgumentException,
           FactoryObjectInformationException, FactoryException
    {
        // mock an object
        UUID testUuid = UUID.randomUUID();

        ComponentInstance instance = mockComponentInstance(testUuid, "SomeName", null);
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance);
        FactoryObjectProxy testObjectProxy = mock(FactoryObjectProxy.class);

        when(this.m_FactoryObjectDataManager.getPersistentUuid("SomeName")).thenReturn(testUuid);

        // mock factory return (supports getting the PID)
        when(m_FactoryDescriptor.create()).thenReturn(testObjectProxy);

        // replay
        m_SUT.createOrRestoreObject(m_FactoryDescriptor, testUuid);
        m_SUT.setName((FactoryObjectInternal)instance.getInstance(), "SomeName");

        //verify that set name isn't called since the name is the same as mocked up above
        verify(this.m_FactoryObjectDataManager, never()).setName(Mockito.eq(testUuid), eq("SomeName"));
    }
/**
     * Test that attempting to set a name when the name is already associated with the object does not re-persist
     * the data. It already exists!
     */
Test that attempting to set a name when the name is already associated with the object does not re-persist
the data. It already exists!
Test that attempting to set a name when the name is already associated with the object does not re - persist the data . It already exists!
@Test
    public void testPersistObjectDataNameAlreadyKnown() throws IllegalArgumentException,
           FactoryObjectInformationException, FactoryException
    {
        UUID testUuid = UUID.randomUUID();
        ComponentInstance instance = mockComponentInstance(testUuid, "SomeName", null);
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance);
        FactoryObjectProxy testObjectProxy = mock(FactoryObjectProxy.class);
        when(this.m_FactoryObjectDataManager.getPersistentUuid("SomeName")).thenReturn(testUuid);
        when(m_FactoryDescriptor.create()).thenReturn(testObjectProxy);
        m_SUT.createOrRestoreObject(m_FactoryDescriptor, testUuid);
        m_SUT.setName((FactoryObjectInternal)instance.getInstance(), "SomeName");
        verify(this.m_FactoryObjectDataManager, never()).setName(Mockito.eq(testUuid), eq("SomeName"));
    }
@ Test public void testPersistObjectDataNameAlreadyKnown ( ) throws IllegalArgumentException , FactoryObjectInformationException , FactoryException { UUID testUuid = UUID . randomUUID ( ) ; ComponentInstance instance = mockComponentInstance ( testUuid , "SomeName" , null ) ; when ( m_ServiceProxy . createFactoryObjectInternal ( m_FactoryDescriptor ) ) . thenReturn ( instance ) ; FactoryObjectProxy testObjectProxy = mock ( FactoryObjectProxy . class ) ; when ( this . m_FactoryObjectDataManager . getPersistentUuid ( "SomeName" ) ) . thenReturn ( testUuid ) ; when ( m_FactoryDescriptor . create ( ) ) . thenReturn ( testObjectProxy ) ; m_SUT . createOrRestoreObject ( m_FactoryDescriptor , testUuid ) ; m_SUT . setName ( ( FactoryObjectInternal ) instance . getInstance ( ) , "SomeName" ) ; verify ( this . m_FactoryObjectDataManager , never ( ) ) . setName ( Mockito . eq ( testUuid ) , eq ( "SomeName" ) ) ; }
Test that attempting to set a name when the name is already associated with the object does not re-persist
 the data.
Test that attempting to set a name when the name is already associated with the object does not re - persist the data .
// mock an object // mock factory return (supports getting the PID) // replay //verify that set name isn't called since the name is the same as mocked up above