mil.dod.th.ose.core/test/mil/dod/th/ose/core/factory/api/TestFactoryRegistry.java
@Test
    public void testCreateNewObjectForConfigNoConfigFound() throws IllegalArgumentException,
        FactoryException, FactoryObjectInformationException, IOException, InvalidSyntaxException
    {
        // mock
        ComponentInstance instance = mockComponentInstance(UUID.randomUUID(), "name", null);
        FactoryObjectProxy proxy = mock(FactoryObjectProxy.class);

        String filter = String.format("(%s=%s)", Constants.SERVICE_PID, "config.pid");

        when(m_FactoryDescriptor.create()).thenReturn(proxy);
        when(m_FactoryDescriptor.getPid()).thenReturn("some.pid");
        when(m_FactoryObjectDataManager.getPersistentUuid("name")).thenReturn(null);
        when(m_FactoryObjectDataManager.getPid(Mockito.any(UUID.class))).thenReturn(null);
        when(m_FactoryObjectDataManager.getName(Mockito.any(UUID.class))).thenReturn("name");
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance);
        when(m_ConfigAdmin.listConfigurations(filter)).thenReturn(null);

        // replay
        try
        {
            m_SUT.createNewObjectForConfig(m_FactoryDescriptor, "name", "config.pid");
            fail("Expecting illegal argument exception since the specified configuration does not exist.");
        }
        catch (final IllegalArgumentException ex)
        {

        }

        // verify
        verify(m_ConfigAdmin).listConfigurations(filter);
        verify(m_FactoryObjectDataManager, never()).persistNewObjectData(Mockito.any(UUID.class),
                eq(m_FactoryDescriptor), eq("name"));
        verify(m_FactoryObjectDataManager, never()).tryRemove(Mockito.any(UUID.class));
        verify(m_FactoryObjectDataManager, never()).setPid(Mockito.any(UUID.class), eq("config.pid"));
        verify(m_ConfigAdmin, never()).createFactoryConfiguration("some.pid", null);
    }
/**
     * Verify that a an illegal argument exception is thrown if the specified configuration cannot be found.
     */
Verify that a an illegal argument exception is thrown if the specified configuration cannot be found.
Verify that a an illegal argument exception is thrown if the specified configuration cannot be found .
@Test
    public void testCreateNewObjectForConfigNoConfigFound() throws IllegalArgumentException,
        FactoryException, FactoryObjectInformationException, IOException, InvalidSyntaxException
    {
        ComponentInstance instance = mockComponentInstance(UUID.randomUUID(), "name", null);
        FactoryObjectProxy proxy = mock(FactoryObjectProxy.class);
        String filter = String.format("(%s=%s)", Constants.SERVICE_PID, "config.pid");
        when(m_FactoryDescriptor.create()).thenReturn(proxy);
        when(m_FactoryDescriptor.getPid()).thenReturn("some.pid");
        when(m_FactoryObjectDataManager.getPersistentUuid("name")).thenReturn(null);
        when(m_FactoryObjectDataManager.getPid(Mockito.any(UUID.class))).thenReturn(null);
        when(m_FactoryObjectDataManager.getName(Mockito.any(UUID.class))).thenReturn("name");
        when(m_ServiceProxy.createFactoryObjectInternal(m_FactoryDescriptor)).thenReturn(instance);
        when(m_ConfigAdmin.listConfigurations(filter)).thenReturn(null);
        try
        {
            m_SUT.createNewObjectForConfig(m_FactoryDescriptor, "name", "config.pid");
            fail("Expecting illegal argument exception since the specified configuration does not exist.");
        }
        catch (final IllegalArgumentException ex)
        {
        }
        verify(m_ConfigAdmin).listConfigurations(filter);
        verify(m_FactoryObjectDataManager, never()).persistNewObjectData(Mockito.any(UUID.class),
                eq(m_FactoryDescriptor), eq("name"));
        verify(m_FactoryObjectDataManager, never()).tryRemove(Mockito.any(UUID.class));
        verify(m_FactoryObjectDataManager, never()).setPid(Mockito.any(UUID.class), eq("config.pid"));
        verify(m_ConfigAdmin, never()).createFactoryConfiguration("some.pid", null);
    }
@ Test public void testCreateNewObjectForConfigNoConfigFound ( ) throws IllegalArgumentException , FactoryException , FactoryObjectInformationException , IOException , InvalidSyntaxException { ComponentInstance instance = mockComponentInstance ( UUID . randomUUID ( ) , "name" , null ) ; FactoryObjectProxy proxy = mock ( FactoryObjectProxy . class ) ; String filter = String . format ( "(%s=%s)" , Constants . SERVICE_PID , "config.pid" ) ; when ( m_FactoryDescriptor . create ( ) ) . thenReturn ( proxy ) ; when ( m_FactoryDescriptor . getPid ( ) ) . thenReturn ( "some.pid" ) ; when ( m_FactoryObjectDataManager . getPersistentUuid ( "name" ) ) . thenReturn ( null ) ; when ( m_FactoryObjectDataManager . getPid ( Mockito . any ( UUID . class ) ) ) . thenReturn ( null ) ; when ( m_FactoryObjectDataManager . getName ( Mockito . any ( UUID . class ) ) ) . thenReturn ( "name" ) ; when ( m_ServiceProxy . createFactoryObjectInternal ( m_FactoryDescriptor ) ) . thenReturn ( instance ) ; when ( m_ConfigAdmin . listConfigurations ( filter ) ) . thenReturn ( null ) ; try { m_SUT . createNewObjectForConfig ( m_FactoryDescriptor , "name" , "config.pid" ) ; fail ( "Expecting illegal argument exception since the specified configuration does not exist." ) ; } catch ( final IllegalArgumentException ex ) { } verify ( m_ConfigAdmin ) . listConfigurations ( filter ) ; verify ( m_FactoryObjectDataManager , never ( ) ) . persistNewObjectData ( Mockito . any ( UUID . class ) , eq ( m_FactoryDescriptor ) , eq ( "name" ) ) ; verify ( m_FactoryObjectDataManager , never ( ) ) . tryRemove ( Mockito . any ( UUID . class ) ) ; verify ( m_FactoryObjectDataManager , never ( ) ) . setPid ( Mockito . any ( UUID . class ) , eq ( "config.pid" ) ) ; verify ( m_ConfigAdmin , never ( ) ) . createFactoryConfiguration ( "some.pid" , null ) ; }
Verify that a an illegal argument exception is thrown if the specified configuration cannot be found.
Verify that a an illegal argument exception is thrown if the specified configuration cannot be found .
// mock // replay // verify