mil.dod.th.ose.core/test/mil/dod/th/ose/core/FactoryObjectDataManagerMocker.java
public static void createMockFactoryObjectDataManager(final FactoryObjectDataManager manager) 
        throws IllegalArgumentException, FactoryObjectInformationException
    {
        //clear any previous entries
        m_ObjectNames.clear();
        m_ObjectPids.clear();
        
        //when the data manager is asked to get the PID for an object pull the PID from the map of PIDs
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final UUID objUuid = (UUID)invocation.getArguments()[0];
                return m_ObjectPids.get(objUuid);
            }
        }).when(manager).getPid(Mockito.any(UUID.class));

        //when asked to store the PID of an object, put the PID in the PID map
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final UUID objUuid = (UUID)invocation.getArguments()[0];
                final String pid = (String)invocation.getArguments()[1];
                
                return m_ObjectPids.put(objUuid, pid);
            }
        }).when(manager).setPid(Mockito.any(UUID.class), anyString());
        
        //remove the PID from the lookup
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final UUID objUuid = (UUID)invocation.getArguments()[0];

                return m_ObjectPids.remove(objUuid);
            }
        }).when(manager).clearPid(Mockito.any(UUID.class));
        
        //when the data manager is asked to get the name of an object, pull the name from the map of names keyed by UUID
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final UUID objUuid = (UUID)invocation.getArguments()[0];
                return m_ObjectNames.get(objUuid);
            }
        }).when(manager).getName(Mockito.any(UUID.class));

        //create an entry for the object's name in the Map of names
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                //UUID of the object
                final UUID objUuid = (UUID)invocation.getArguments()[0];
                //the name
                final String name = (String)invocation.getArguments()[2];

                return m_ObjectNames.put(objUuid, name);
            }
        }).when(manager)
            .persistNewObjectData(Mockito.any(UUID.class), Mockito.any(FactoryDescriptor.class), anyString());
        
        //replace or add the name in the map object names
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final UUID objUuid = (UUID)invocation.getArguments()[0];
                final String name = (String)invocation.getArguments()[1];

                return m_ObjectNames.put(objUuid, name);
            }
        }).when(manager).setName(Mockito.any(UUID.class), anyString());
    }
/**
     * Create a factory object data manager mocking implementation.
     * @param manager
     *      the mock manager to handle implementation concerns for
     */
Create a factory object data manager mocking implementation.
@param manager
the mock manager to handle implementation concerns for
Create a factory object data manager mocking implementation . @param manager the mock manager to handle implementation concerns for
public static void createMockFactoryObjectDataManager(final FactoryObjectDataManager manager) 
        throws IllegalArgumentException, FactoryObjectInformationException
    {
        m_ObjectNames.clear();
        m_ObjectPids.clear();
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final UUID objUuid = (UUID)invocation.getArguments()[0];
                return m_ObjectPids.get(objUuid);
            }
        }).when(manager).getPid(Mockito.any(UUID.class));
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final UUID objUuid = (UUID)invocation.getArguments()[0];
                final String pid = (String)invocation.getArguments()[1];
                return m_ObjectPids.put(objUuid, pid);
            }
        }).when(manager).setPid(Mockito.any(UUID.class), anyString());
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final UUID objUuid = (UUID)invocation.getArguments()[0];
                return m_ObjectPids.remove(objUuid);
            }
        }).when(manager).clearPid(Mockito.any(UUID.class));
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final UUID objUuid = (UUID)invocation.getArguments()[0];
                return m_ObjectNames.get(objUuid);
            }
        }).when(manager).getName(Mockito.any(UUID.class));
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final UUID objUuid = (UUID)invocation.getArguments()[0];
                final String name = (String)invocation.getArguments()[2];
                return m_ObjectNames.put(objUuid, name);
            }
        }).when(manager)
            .persistNewObjectData(Mockito.any(UUID.class), Mockito.any(FactoryDescriptor.class), anyString());
        doAnswer(new Answer<Object>()
        {
            @Override
            public Object answer(final InvocationOnMock invocation) throws Throwable
            {
                final UUID objUuid = (UUID)invocation.getArguments()[0];
                final String name = (String)invocation.getArguments()[1];
                return m_ObjectNames.put(objUuid, name);
            }
        }).when(manager).setName(Mockito.any(UUID.class), anyString());
    }
public static void createMockFactoryObjectDataManager ( final FactoryObjectDataManager manager ) throws IllegalArgumentException , FactoryObjectInformationException { m_ObjectNames . clear ( ) ; m_ObjectPids . clear ( ) ; doAnswer ( new Answer < Object > ( ) { @ Override public Object answer ( final InvocationOnMock invocation ) throws Throwable { final UUID objUuid = ( UUID ) invocation . getArguments ( ) [ 0 ] ; return m_ObjectPids . get ( objUuid ) ; } } ) . when ( manager ) . getPid ( Mockito . any ( UUID . class ) ) ; doAnswer ( new Answer < Object > ( ) { @ Override public Object answer ( final InvocationOnMock invocation ) throws Throwable { final UUID objUuid = ( UUID ) invocation . getArguments ( ) [ 0 ] ; final String pid = ( String ) invocation . getArguments ( ) [ 1 ] ; return m_ObjectPids . put ( objUuid , pid ) ; } } ) . when ( manager ) . setPid ( Mockito . any ( UUID . class ) , anyString ( ) ) ; doAnswer ( new Answer < Object > ( ) { @ Override public Object answer ( final InvocationOnMock invocation ) throws Throwable { final UUID objUuid = ( UUID ) invocation . getArguments ( ) [ 0 ] ; return m_ObjectPids . remove ( objUuid ) ; } } ) . when ( manager ) . clearPid ( Mockito . any ( UUID . class ) ) ; doAnswer ( new Answer < Object > ( ) { @ Override public Object answer ( final InvocationOnMock invocation ) throws Throwable { final UUID objUuid = ( UUID ) invocation . getArguments ( ) [ 0 ] ; return m_ObjectNames . get ( objUuid ) ; } } ) . when ( manager ) . getName ( Mockito . any ( UUID . class ) ) ; doAnswer ( new Answer < Object > ( ) { @ Override public Object answer ( final InvocationOnMock invocation ) throws Throwable { final UUID objUuid = ( UUID ) invocation . getArguments ( ) [ 0 ] ; final String name = ( String ) invocation . getArguments ( ) [ 2 ] ; return m_ObjectNames . put ( objUuid , name ) ; } } ) . when ( manager ) . persistNewObjectData ( Mockito . any ( UUID . class ) , Mockito . any ( FactoryDescriptor . class ) , anyString ( ) ) ; doAnswer ( new Answer < Object > ( ) { @ Override public Object answer ( final InvocationOnMock invocation ) throws Throwable { final UUID objUuid = ( UUID ) invocation . getArguments ( ) [ 0 ] ; final String name = ( String ) invocation . getArguments ( ) [ 1 ] ; return m_ObjectNames . put ( objUuid , name ) ; } } ) . when ( manager ) . setName ( Mockito . any ( UUID . class ) , anyString ( ) ) ; }
Create a factory object data manager mocking implementation.
Create a factory object data manager mocking implementation .
//clear any previous entries //when the data manager is asked to get the PID for an object pull the PID from the map of PIDs //when asked to store the PID of an object, put the PID in the PID map //remove the PID from the lookup //when the data manager is asked to get the name of an object, pull the name from the map of names keyed by UUID //create an entry for the object's name in the Map of names //UUID of the object //the name //replace or add the name in the map object names