mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetMgrImpl.java
@SuppressWarnings({ "rawtypes", "unchecked" })
    @Test
    public void testTopicAndFilterRegistration()
    {
        ArgumentCaptor<Dictionary> dictCaptor = ArgumentCaptor.forClass(Dictionary.class);
        
        verify(m_BundleContext, times(4)).registerService(eq(EventHandler.class), Mockito.any(EventHandler.class), 
                dictCaptor.capture());

        //get dictionaries
        Dictionary eventHelperDict = dictCaptor.getAllValues().get(0);
        Dictionary assetHelperDict = dictCaptor.getAllValues().get(1);
        Dictionary assetDirHelperDict = dictCaptor.getAllValues().get(2);
        
        //Test Asset EventHelper
        Object dictObj = assetHelperDict.get(EventConstants.EVENT_TOPIC);
        verifyMessageReceivedEventRegistration(dictObj);

        dictObj = assetHelperDict.get(EventConstants.EVENT_FILTER);
        String filter = String.format("(%s=%s)", 
                RemoteConstants.EVENT_PROP_NAMESPACE, Namespace.Asset.toString());
        assertThat(dictObj.equals(filter), is(true));
        
        //Test AssetDir EventHelper
        dictObj = assetDirHelperDict.get(EventConstants.EVENT_TOPIC);
        verifyMessageReceivedEventRegistration(dictObj);

        dictObj = assetDirHelperDict.get(EventConstants.EVENT_FILTER);
        filter = String.format("(%s=%s)", 
                RemoteConstants.EVENT_PROP_NAMESPACE, Namespace.AssetDirectoryService.toString());
        assertThat(dictObj.equals(filter), is(true));
        
        //Test EventAdmin EventHelper
        dictObj = eventHelperDict.get(EventConstants.EVENT_TOPIC);
        
        String[] topics = (String[]) dictObj;
        assertThat(topics[0].equals(Asset.TOPIC_DATA_CAPTURED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[1].equals(Asset.TOPIC_STATUS_CHANGED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[2].equals(Asset.TOPIC_WILL_BE_ACTIVATED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[3].equals(Asset.TOPIC_ACTIVATION_COMPLETE + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[4].equals(Asset.TOPIC_ACTIVATION_FAILED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[5].equals(Asset.TOPIC_WILL_BE_DEACTIVATED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[6].equals(Asset.TOPIC_DEACTIVATION_COMPLETE + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[7].equals(Asset.TOPIC_DEACTIVATION_FAILED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[8].equals(FactoryDescriptor.TOPIC_PREFIX + "*"), is(true));
        
        dictObj = eventHelperDict.get(EventConstants.EVENT_FILTER);
        filter = String.format("(%s=*)", RemoteConstants.REMOTE_EVENT_PROP);
        assertThat(dictObj.equals(filter), is(true));
    }
/**
     * Test that each Event Helper has correctly registered for the appropriate topics and
     * filters.
     */
Test that each Event Helper has correctly registered for the appropriate topics and
filters.
Test that each Event Helper has correctly registered for the appropriate topics and filters .
@SuppressWarnings({ "rawtypes", "unchecked" })
    @Test
    public void testTopicAndFilterRegistration()
    {
        ArgumentCaptor<Dictionary> dictCaptor = ArgumentCaptor.forClass(Dictionary.class);
        verify(m_BundleContext, times(4)).registerService(eq(EventHandler.class), Mockito.any(EventHandler.class), 
                dictCaptor.capture());
        Dictionary eventHelperDict = dictCaptor.getAllValues().get(0);
        Dictionary assetHelperDict = dictCaptor.getAllValues().get(1);
        Dictionary assetDirHelperDict = dictCaptor.getAllValues().get(2);
        Object dictObj = assetHelperDict.get(EventConstants.EVENT_TOPIC);
        verifyMessageReceivedEventRegistration(dictObj);
        dictObj = assetHelperDict.get(EventConstants.EVENT_FILTER);
        String filter = String.format("(%s=%s)", 
                RemoteConstants.EVENT_PROP_NAMESPACE, Namespace.Asset.toString());
        assertThat(dictObj.equals(filter), is(true));
        dictObj = assetDirHelperDict.get(EventConstants.EVENT_TOPIC);
        verifyMessageReceivedEventRegistration(dictObj);
        dictObj = assetDirHelperDict.get(EventConstants.EVENT_FILTER);
        filter = String.format("(%s=%s)", 
                RemoteConstants.EVENT_PROP_NAMESPACE, Namespace.AssetDirectoryService.toString());
        assertThat(dictObj.equals(filter), is(true));
        dictObj = eventHelperDict.get(EventConstants.EVENT_TOPIC);
        String[] topics = (String[]) dictObj;
        assertThat(topics[0].equals(Asset.TOPIC_DATA_CAPTURED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[1].equals(Asset.TOPIC_STATUS_CHANGED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[2].equals(Asset.TOPIC_WILL_BE_ACTIVATED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[3].equals(Asset.TOPIC_ACTIVATION_COMPLETE + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[4].equals(Asset.TOPIC_ACTIVATION_FAILED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[5].equals(Asset.TOPIC_WILL_BE_DEACTIVATED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[6].equals(Asset.TOPIC_DEACTIVATION_COMPLETE + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[7].equals(Asset.TOPIC_DEACTIVATION_FAILED + RemoteConstants.REMOTE_TOPIC_SUFFIX), is(true));
        assertThat(topics[8].equals(FactoryDescriptor.TOPIC_PREFIX + "*"), is(true));
        dictObj = eventHelperDict.get(EventConstants.EVENT_FILTER);
        filter = String.format("(%s=*)", RemoteConstants.REMOTE_EVENT_PROP);
        assertThat(dictObj.equals(filter), is(true));
    }
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ Test public void testTopicAndFilterRegistration ( ) { ArgumentCaptor < Dictionary > dictCaptor = ArgumentCaptor . forClass ( Dictionary . class ) ; verify ( m_BundleContext , times ( 4 ) ) . registerService ( eq ( EventHandler . class ) , Mockito . any ( EventHandler . class ) , dictCaptor . capture ( ) ) ; Dictionary eventHelperDict = dictCaptor . getAllValues ( ) . get ( 0 ) ; Dictionary assetHelperDict = dictCaptor . getAllValues ( ) . get ( 1 ) ; Dictionary assetDirHelperDict = dictCaptor . getAllValues ( ) . get ( 2 ) ; Object dictObj = assetHelperDict . get ( EventConstants . EVENT_TOPIC ) ; verifyMessageReceivedEventRegistration ( dictObj ) ; dictObj = assetHelperDict . get ( EventConstants . EVENT_FILTER ) ; String filter = String . format ( "(%s=%s)" , RemoteConstants . EVENT_PROP_NAMESPACE , Namespace . Asset . toString ( ) ) ; assertThat ( dictObj . equals ( filter ) , is ( true ) ) ; dictObj = assetDirHelperDict . get ( EventConstants . EVENT_TOPIC ) ; verifyMessageReceivedEventRegistration ( dictObj ) ; dictObj = assetDirHelperDict . get ( EventConstants . EVENT_FILTER ) ; filter = String . format ( "(%s=%s)" , RemoteConstants . EVENT_PROP_NAMESPACE , Namespace . AssetDirectoryService . toString ( ) ) ; assertThat ( dictObj . equals ( filter ) , is ( true ) ) ; dictObj = eventHelperDict . get ( EventConstants . EVENT_TOPIC ) ; String [ ] topics = ( String [ ] ) dictObj ; assertThat ( topics [ 0 ] . equals ( Asset . TOPIC_DATA_CAPTURED + RemoteConstants . REMOTE_TOPIC_SUFFIX ) , is ( true ) ) ; assertThat ( topics [ 1 ] . equals ( Asset . TOPIC_STATUS_CHANGED + RemoteConstants . REMOTE_TOPIC_SUFFIX ) , is ( true ) ) ; assertThat ( topics [ 2 ] . equals ( Asset . TOPIC_WILL_BE_ACTIVATED + RemoteConstants . REMOTE_TOPIC_SUFFIX ) , is ( true ) ) ; assertThat ( topics [ 3 ] . equals ( Asset . TOPIC_ACTIVATION_COMPLETE + RemoteConstants . REMOTE_TOPIC_SUFFIX ) , is ( true ) ) ; assertThat ( topics [ 4 ] . equals ( Asset . TOPIC_ACTIVATION_FAILED + RemoteConstants . REMOTE_TOPIC_SUFFIX ) , is ( true ) ) ; assertThat ( topics [ 5 ] . equals ( Asset . TOPIC_WILL_BE_DEACTIVATED + RemoteConstants . REMOTE_TOPIC_SUFFIX ) , is ( true ) ) ; assertThat ( topics [ 6 ] . equals ( Asset . TOPIC_DEACTIVATION_COMPLETE + RemoteConstants . REMOTE_TOPIC_SUFFIX ) , is ( true ) ) ; assertThat ( topics [ 7 ] . equals ( Asset . TOPIC_DEACTIVATION_FAILED + RemoteConstants . REMOTE_TOPIC_SUFFIX ) , is ( true ) ) ; assertThat ( topics [ 8 ] . equals ( FactoryDescriptor . TOPIC_PREFIX + "*" ) , is ( true ) ) ; dictObj = eventHelperDict . get ( EventConstants . EVENT_FILTER ) ; filter = String . format ( "(%s=*)" , RemoteConstants . REMOTE_EVENT_PROP ) ; assertThat ( dictObj . equals ( filter ) , is ( true ) ) ; }
Test that each Event Helper has correctly registered for the appropriate topics and
 filters.
Test that each Event Helper has correctly registered for the appropriate topics and filters .
//get dictionaries //Test Asset EventHelper //Test AssetDir EventHelper //Test EventAdmin EventHelper