mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/asset/TestScannerManager.java
@SuppressWarnings("unchecked")
    @Test
    public void testScanForAssetsByType() throws IllegalArgumentException, AssetException, InterruptedException
    {
        EventAdminSyncer syncer = new EventAdminSyncer(m_EventAdmin, 
                AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE, 2);
        
        m_SUT.scanForAssetsByType(m_ADS, AssetType1.class.getName());

        verify(m_WakeLock).activate();
        
        syncer.waitFor(3, TimeUnit.SECONDS);
        
        verify(m_ADS).createAsset(AssetType1.class.getName(), null, Collections.EMPTY_MAP);

        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, atLeastOnce()).postEvent(eventCaptor.capture());

        EventAdminVerifier.assertEventByTopicAssetType(eventCaptor, AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS, 
                AssetType1.class.getName());

        Thread.sleep(1000);

        EventAdminVerifier.assertEventByTopicAssetType(eventCaptor, 
                AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE, AssetType1.class.getName());
    
        // should get null to signify all have completed
        EventAdminVerifier.assertEventByTopicNoAssetType(eventCaptor, 
                AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE);
        verify(m_WakeLock).cancel();
        
        // remove scanner and verify that exception is thrown
        m_SUT.unsetAssetScanner(m_Scanner1);
        try
        {
            m_SUT.scanForAssetsByType(m_ADS, AssetType1.class.getName());
            fail("Expecting exception since product type is not registered with the service");
        }
        catch (IllegalArgumentException e)
        {
        }
    }
/**
     * Verify the scanning of a specific asset type.
     */
Verify the scanning of a specific asset type.
Verify the scanning of a specific asset type .
@SuppressWarnings("unchecked")
    @Test
    public void testScanForAssetsByType() throws IllegalArgumentException, AssetException, InterruptedException
    {
        EventAdminSyncer syncer = new EventAdminSyncer(m_EventAdmin, 
                AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE, 2);
        m_SUT.scanForAssetsByType(m_ADS, AssetType1.class.getName());
        verify(m_WakeLock).activate();
        syncer.waitFor(3, TimeUnit.SECONDS);
        verify(m_ADS).createAsset(AssetType1.class.getName(), null, Collections.EMPTY_MAP);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, atLeastOnce()).postEvent(eventCaptor.capture());
        EventAdminVerifier.assertEventByTopicAssetType(eventCaptor, AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS, 
                AssetType1.class.getName());
        Thread.sleep(1000);
        EventAdminVerifier.assertEventByTopicAssetType(eventCaptor, 
                AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE, AssetType1.class.getName());
        EventAdminVerifier.assertEventByTopicNoAssetType(eventCaptor, 
                AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE);
        verify(m_WakeLock).cancel();
        m_SUT.unsetAssetScanner(m_Scanner1);
        try
        {
            m_SUT.scanForAssetsByType(m_ADS, AssetType1.class.getName());
            fail("Expecting exception since product type is not registered with the service");
        }
        catch (IllegalArgumentException e)
        {
        }
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testScanForAssetsByType ( ) throws IllegalArgumentException , AssetException , InterruptedException { EventAdminSyncer syncer = new EventAdminSyncer ( m_EventAdmin , AssetDirectoryService . TOPIC_SCANNING_FOR_ASSETS_COMPLETE , 2 ) ; m_SUT . scanForAssetsByType ( m_ADS , AssetType1 . class . getName ( ) ) ; verify ( m_WakeLock ) . activate ( ) ; syncer . waitFor ( 3 , TimeUnit . SECONDS ) ; verify ( m_ADS ) . createAsset ( AssetType1 . class . getName ( ) , null , Collections . EMPTY_MAP ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , atLeastOnce ( ) ) . postEvent ( eventCaptor . capture ( ) ) ; EventAdminVerifier . assertEventByTopicAssetType ( eventCaptor , AssetDirectoryService . TOPIC_SCANNING_FOR_ASSETS , AssetType1 . class . getName ( ) ) ; Thread . sleep ( 1000 ) ; EventAdminVerifier . assertEventByTopicAssetType ( eventCaptor , AssetDirectoryService . TOPIC_SCANNING_FOR_ASSETS_COMPLETE , AssetType1 . class . getName ( ) ) ; EventAdminVerifier . assertEventByTopicNoAssetType ( eventCaptor , AssetDirectoryService . TOPIC_SCANNING_FOR_ASSETS_COMPLETE ) ; verify ( m_WakeLock ) . cancel ( ) ; m_SUT . unsetAssetScanner ( m_Scanner1 ) ; try { m_SUT . scanForAssetsByType ( m_ADS , AssetType1 . class . getName ( ) ) ; fail ( "Expecting exception since product type is not registered with the service" ) ; } catch ( IllegalArgumentException e ) { } }
Verify the scanning of a specific asset type.
Verify the scanning of a specific asset type .
// should get null to signify all have completed // remove scanner and verify that exception is thrown