mil.dod.th.ose.config/test/mil/dod/th/ose/config/loading/impl/TestAssetTrackerCustomizer.java
@SuppressWarnings("unchecked")
    @Test
    public void testAddingServiceAssetException() throws IllegalArgumentException, AssetException, 
        IllegalStateException, FactoryException
    {
        FactoryObjectConfig objectConfig = new FactoryObjectConfig()
            .withFactoryType(FactoryTypeEnum.ASSET)
            .withProperties(m_Properties)
            .withProductType(TEST_PID)
            .withCreatePolicy(CreatePolicyEnum.FIRST_RUN)
            .withName("Asset1");
        
        when(m_AssetDirService.isAssetAvailable("Asset1")).thenReturn(false);

        when(m_AssetDirService.createAsset(eq(TEST_PID), eq("Asset1"), any(Map.class))).thenThrow(
                new AssetException("problem"));

        AssetTrackerCustomizer sut = new AssetTrackerCustomizer(objectConfig, m_AssetDirService, m_Log, m_EventAdmin);
        
        sut.addingService(m_ServiceReference);

        verify(m_AssetDirService, times(1)).createAsset(eq(TEST_PID), eq("Asset1"), any(Map.class));
        verify(m_Log).log(eq(LogService.LOG_WARNING), Mockito.any(FactoryException.class), Mockito.anyString(), 
                Mockito.any());
    }
/**
     *  Verify error handling if an asset cannot be created.
     */
Verify error handling if an asset cannot be created.
Verify error handling if an asset cannot be created .
@SuppressWarnings("unchecked")
    @Test
    public void testAddingServiceAssetException() throws IllegalArgumentException, AssetException, 
        IllegalStateException, FactoryException
    {
        FactoryObjectConfig objectConfig = new FactoryObjectConfig()
            .withFactoryType(FactoryTypeEnum.ASSET)
            .withProperties(m_Properties)
            .withProductType(TEST_PID)
            .withCreatePolicy(CreatePolicyEnum.FIRST_RUN)
            .withName("Asset1");
        when(m_AssetDirService.isAssetAvailable("Asset1")).thenReturn(false);
        when(m_AssetDirService.createAsset(eq(TEST_PID), eq("Asset1"), any(Map.class))).thenThrow(
                new AssetException("problem"));
        AssetTrackerCustomizer sut = new AssetTrackerCustomizer(objectConfig, m_AssetDirService, m_Log, m_EventAdmin);
        sut.addingService(m_ServiceReference);
        verify(m_AssetDirService, times(1)).createAsset(eq(TEST_PID), eq("Asset1"), any(Map.class));
        verify(m_Log).log(eq(LogService.LOG_WARNING), Mockito.any(FactoryException.class), Mockito.anyString(), 
                Mockito.any());
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testAddingServiceAssetException ( ) throws IllegalArgumentException , AssetException , IllegalStateException , FactoryException { FactoryObjectConfig objectConfig = new FactoryObjectConfig ( ) . withFactoryType ( FactoryTypeEnum . ASSET ) . withProperties ( m_Properties ) . withProductType ( TEST_PID ) . withCreatePolicy ( CreatePolicyEnum . FIRST_RUN ) . withName ( "Asset1" ) ; when ( m_AssetDirService . isAssetAvailable ( "Asset1" ) ) . thenReturn ( false ) ; when ( m_AssetDirService . createAsset ( eq ( TEST_PID ) , eq ( "Asset1" ) , any ( Map . class ) ) ) . thenThrow ( new AssetException ( "problem" ) ) ; AssetTrackerCustomizer sut = new AssetTrackerCustomizer ( objectConfig , m_AssetDirService , m_Log , m_EventAdmin ) ; sut . addingService ( m_ServiceReference ) ; verify ( m_AssetDirService , times ( 1 ) ) . createAsset ( eq ( TEST_PID ) , eq ( "Asset1" ) , any ( Map . class ) ) ; verify ( m_Log ) . log ( eq ( LogService . LOG_WARNING ) , Mockito . any ( FactoryException . class ) , Mockito . anyString ( ) , Mockito . any ( ) ) ; }
Verify error handling if an asset cannot be created.
Verify error handling if an asset cannot be created .