mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/advanced/TestBundleMgrImpl.java
@SuppressWarnings({"rawtypes", "unchecked"})
    @Test
    public void testTopicAndFilterRegistration()
    {
        ArgumentCaptor<Dictionary> dictCaptor = ArgumentCaptor.forClass(Dictionary.class);
        
        verify(m_BundleContext, times(3)).registerService(eq(EventHandler.class), Mockito.any(EventHandler.class), 
                dictCaptor.capture());
        
        Dictionary bundleHandlerDict = dictCaptor.getAllValues().get(0);
        Dictionary controllerHandlerDict = dictCaptor.getAllValues().get(1);
        Dictionary remoteBundleHandlerDict = dictCaptor.getAllValues().get(2);
        
        //Test bundler handler
        String topic = (String)bundleHandlerDict.get(EventConstants.EVENT_TOPIC);
        assertThat(topic, is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        String filterString = String.format("(&(%s=%s)(|(%s=%s)(%s=%s)))", 
                RemoteConstants.EVENT_PROP_NAMESPACE, Namespace.Bundle.toString(),
                RemoteConstants.EVENT_PROP_MESSAGE_TYPE, BundleMessageType.GetBundleInfoResponse.toString(),
                RemoteConstants.EVENT_PROP_MESSAGE_TYPE, BundleMessageType.BundleNamespaceError.toString());
        String filter = (String)bundleHandlerDict.get(EventConstants.EVENT_FILTER);
        assertThat(filter, is (filterString));
        
        //Test controller handler
        topic = (String)controllerHandlerDict.get(EventConstants.EVENT_TOPIC);
        assertThat(topic, is(ControllerMgr.TOPIC_CONTROLLER_REMOVED));
        
        //Test remote bundle handler
        List<String> topicList = (List<String>)remoteBundleHandlerDict.get(EventConstants.EVENT_TOPIC);
        assertThat(topicList.size(), is(5));
        assertThat(topicList.get(0), 
                is(OSGiEventConstants.TOPIC_BUNDLE_STARTED + RemoteConstants.REMOTE_TOPIC_SUFFIX));
        assertThat(topicList.get(1), 
                is(OSGiEventConstants.TOPIC_BUNDLE_STOPPED + RemoteConstants.REMOTE_TOPIC_SUFFIX));
        assertThat(topicList.get(2), 
                is(OSGiEventConstants.TOPIC_BUNDLE_UPDATED + RemoteConstants.REMOTE_TOPIC_SUFFIX));
        assertThat(topicList.get(3), 
                is(OSGiEventConstants.TOPIC_BUNDLE_INSTALLED + RemoteConstants.REMOTE_TOPIC_SUFFIX));
        assertThat(topicList.get(4), 
                is(OSGiEventConstants.TOPIC_BUNDLE_UNINSTALLED + RemoteConstants.REMOTE_TOPIC_SUFFIX));
    }
/**
     * 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(3)).registerService(eq(EventHandler.class), Mockito.any(EventHandler.class), 
                dictCaptor.capture());
        Dictionary bundleHandlerDict = dictCaptor.getAllValues().get(0);
        Dictionary controllerHandlerDict = dictCaptor.getAllValues().get(1);
        Dictionary remoteBundleHandlerDict = dictCaptor.getAllValues().get(2);
        String topic = (String)bundleHandlerDict.get(EventConstants.EVENT_TOPIC);
        assertThat(topic, is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        String filterString = String.format("(&(%s=%s)(|(%s=%s)(%s=%s)))", 
                RemoteConstants.EVENT_PROP_NAMESPACE, Namespace.Bundle.toString(),
                RemoteConstants.EVENT_PROP_MESSAGE_TYPE, BundleMessageType.GetBundleInfoResponse.toString(),
                RemoteConstants.EVENT_PROP_MESSAGE_TYPE, BundleMessageType.BundleNamespaceError.toString());
        String filter = (String)bundleHandlerDict.get(EventConstants.EVENT_FILTER);
        assertThat(filter, is (filterString));
        topic = (String)controllerHandlerDict.get(EventConstants.EVENT_TOPIC);
        assertThat(topic, is(ControllerMgr.TOPIC_CONTROLLER_REMOVED));
        List<String> topicList = (List<String>)remoteBundleHandlerDict.get(EventConstants.EVENT_TOPIC);
        assertThat(topicList.size(), is(5));
        assertThat(topicList.get(0), 
                is(OSGiEventConstants.TOPIC_BUNDLE_STARTED + RemoteConstants.REMOTE_TOPIC_SUFFIX));
        assertThat(topicList.get(1), 
                is(OSGiEventConstants.TOPIC_BUNDLE_STOPPED + RemoteConstants.REMOTE_TOPIC_SUFFIX));
        assertThat(topicList.get(2), 
                is(OSGiEventConstants.TOPIC_BUNDLE_UPDATED + RemoteConstants.REMOTE_TOPIC_SUFFIX));
        assertThat(topicList.get(3), 
                is(OSGiEventConstants.TOPIC_BUNDLE_INSTALLED + RemoteConstants.REMOTE_TOPIC_SUFFIX));
        assertThat(topicList.get(4), 
                is(OSGiEventConstants.TOPIC_BUNDLE_UNINSTALLED + RemoteConstants.REMOTE_TOPIC_SUFFIX));
    }
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ Test public void testTopicAndFilterRegistration ( ) { ArgumentCaptor < Dictionary > dictCaptor = ArgumentCaptor . forClass ( Dictionary . class ) ; verify ( m_BundleContext , times ( 3 ) ) . registerService ( eq ( EventHandler . class ) , Mockito . any ( EventHandler . class ) , dictCaptor . capture ( ) ) ; Dictionary bundleHandlerDict = dictCaptor . getAllValues ( ) . get ( 0 ) ; Dictionary controllerHandlerDict = dictCaptor . getAllValues ( ) . get ( 1 ) ; Dictionary remoteBundleHandlerDict = dictCaptor . getAllValues ( ) . get ( 2 ) ; String topic = ( String ) bundleHandlerDict . get ( EventConstants . EVENT_TOPIC ) ; assertThat ( topic , is ( RemoteConstants . TOPIC_MESSAGE_RECEIVED ) ) ; String filterString = String . format ( "(&(%s=%s)(|(%s=%s)(%s=%s)))" , RemoteConstants . EVENT_PROP_NAMESPACE , Namespace . Bundle . toString ( ) , RemoteConstants . EVENT_PROP_MESSAGE_TYPE , BundleMessageType . GetBundleInfoResponse . toString ( ) , RemoteConstants . EVENT_PROP_MESSAGE_TYPE , BundleMessageType . BundleNamespaceError . toString ( ) ) ; String filter = ( String ) bundleHandlerDict . get ( EventConstants . EVENT_FILTER ) ; assertThat ( filter , is ( filterString ) ) ; topic = ( String ) controllerHandlerDict . get ( EventConstants . EVENT_TOPIC ) ; assertThat ( topic , is ( ControllerMgr . TOPIC_CONTROLLER_REMOVED ) ) ; List < String > topicList = ( List < String > ) remoteBundleHandlerDict . get ( EventConstants . EVENT_TOPIC ) ; assertThat ( topicList . size ( ) , is ( 5 ) ) ; assertThat ( topicList . get ( 0 ) , is ( OSGiEventConstants . TOPIC_BUNDLE_STARTED + RemoteConstants . REMOTE_TOPIC_SUFFIX ) ) ; assertThat ( topicList . get ( 1 ) , is ( OSGiEventConstants . TOPIC_BUNDLE_STOPPED + RemoteConstants . REMOTE_TOPIC_SUFFIX ) ) ; assertThat ( topicList . get ( 2 ) , is ( OSGiEventConstants . TOPIC_BUNDLE_UPDATED + RemoteConstants . REMOTE_TOPIC_SUFFIX ) ) ; assertThat ( topicList . get ( 3 ) , is ( OSGiEventConstants . TOPIC_BUNDLE_INSTALLED + RemoteConstants . REMOTE_TOPIC_SUFFIX ) ) ; assertThat ( topicList . get ( 4 ) , is ( OSGiEventConstants . TOPIC_BUNDLE_UNINSTALLED + RemoteConstants . REMOTE_TOPIC_SUFFIX ) ) ; }
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 bundler handler //Test controller handler //Test remote bundle handler