mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/advanced/configuration/TestSystemMetatypeMgrImpl.java
@SuppressWarnings("unchecked")
    @Test
    public void testBundleEventHandler() throws SecurityException, NoSuchFieldException, IllegalArgumentException, 
        IllegalAccessException
    {
        Map<String, Object> props = new HashMap<>();
        props.put(EventConstants.BUNDLE_ID, BUNDLEID);
        props.put(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID, CONTROLLERID);
        Event event = new Event(BundleMgr.TOPIC_BUNDLE_INFO_RECEIVED, props);

        m_BundleEventHandler.handleEvent(event);

        props = new HashMap<>();
        props.put(RemoteMetatypeConstants.EVENT_PROP_BUNDLE_ID, BUNDLEID3);
        props.put(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID, CONTROLLERID);
        event = new Event(RemoteMetatypeConstants.TOPIC_METATYPE_INFORMATION_AVAILABLE 
                + RemoteConstants.REMOTE_TOPIC_SUFFIX, props);

        m_BundleEventHandler.handleEvent(event);

        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);

        verify(m_MessageFactory, times(2)).createMetaTypeMessage(eq(MetaTypeMessageType.GetMetaTypeInfoRequest),
                messageCaptor.capture());
        verify(m_MessageWrapper, times(2)).queue(eq(CONTROLLERID), eq((ResponseHandler)null));

        GetMetaTypeInfoRequestData infoRequest = (GetMetaTypeInfoRequestData)messageCaptor.getAllValues().get(0);
        assertThat(infoRequest.getBundleId(), is(BUNDLEID));
        infoRequest = (GetMetaTypeInfoRequestData)messageCaptor.getAllValues().get(1);
        assertThat(infoRequest.getBundleId(), is(BUNDLEID3));

        Field metaMapField = m_SUT.getClass().getDeclaredField("m_MetatypeListConfigs");
        metaMapField.setAccessible(true);
        Map<Integer, List<MetaTypeModel>> metaMap = (Map<Integer, List<MetaTypeModel>>) metaMapField.get(m_SUT);
        List<MetaTypeModel> listModels = new ArrayList<MetaTypeModel>();
        listModels.add(new MetaTypeModel("some pid", BUNDLEID));
        listModels.add(new MetaTypeModel("pid 2", BUNDLEID2));
        metaMap.put(CONTROLLERID, listModels);
        
        props = new HashMap<>();
        props.put(EventConstants.BUNDLE_ID, BUNDLEID);
        props.put(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID, CONTROLLERID);
        event = new Event(BundleMgr.TOPIC_BUNDLE_INFO_REMOVED, props);

        assertThat(m_SUT.getConfigurationsListAsync(CONTROLLERID).size(), is(2));
        m_BundleEventHandler.handleEvent(event);
        assertThat(m_SUT.getConfigurationsListAsync(CONTROLLERID).size(), is(1));
    }
/**
     * Test the bundle event handler. Verify that all events are handled appropriately.
     */
Test the bundle event handler. Verify that all events are handled appropriately.
Test the bundle event handler . Verify that all events are handled appropriately .
@SuppressWarnings("unchecked")
    @Test
    public void testBundleEventHandler() throws SecurityException, NoSuchFieldException, IllegalArgumentException, 
        IllegalAccessException
    {
        Map<String, Object> props = new HashMap<>();
        props.put(EventConstants.BUNDLE_ID, BUNDLEID);
        props.put(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID, CONTROLLERID);
        Event event = new Event(BundleMgr.TOPIC_BUNDLE_INFO_RECEIVED, props);
        m_BundleEventHandler.handleEvent(event);
        props = new HashMap<>();
        props.put(RemoteMetatypeConstants.EVENT_PROP_BUNDLE_ID, BUNDLEID3);
        props.put(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID, CONTROLLERID);
        event = new Event(RemoteMetatypeConstants.TOPIC_METATYPE_INFORMATION_AVAILABLE 
                + RemoteConstants.REMOTE_TOPIC_SUFFIX, props);
        m_BundleEventHandler.handleEvent(event);
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        verify(m_MessageFactory, times(2)).createMetaTypeMessage(eq(MetaTypeMessageType.GetMetaTypeInfoRequest),
                messageCaptor.capture());
        verify(m_MessageWrapper, times(2)).queue(eq(CONTROLLERID), eq((ResponseHandler)null));
        GetMetaTypeInfoRequestData infoRequest = (GetMetaTypeInfoRequestData)messageCaptor.getAllValues().get(0);
        assertThat(infoRequest.getBundleId(), is(BUNDLEID));
        infoRequest = (GetMetaTypeInfoRequestData)messageCaptor.getAllValues().get(1);
        assertThat(infoRequest.getBundleId(), is(BUNDLEID3));
        Field metaMapField = m_SUT.getClass().getDeclaredField("m_MetatypeListConfigs");
        metaMapField.setAccessible(true);
        Map<Integer, List<MetaTypeModel>> metaMap = (Map<Integer, List<MetaTypeModel>>) metaMapField.get(m_SUT);
        List<MetaTypeModel> listModels = new ArrayList<MetaTypeModel>();
        listModels.add(new MetaTypeModel("some pid", BUNDLEID));
        listModels.add(new MetaTypeModel("pid 2", BUNDLEID2));
        metaMap.put(CONTROLLERID, listModels);
        props = new HashMap<>();
        props.put(EventConstants.BUNDLE_ID, BUNDLEID);
        props.put(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID, CONTROLLERID);
        event = new Event(BundleMgr.TOPIC_BUNDLE_INFO_REMOVED, props);
        assertThat(m_SUT.getConfigurationsListAsync(CONTROLLERID).size(), is(2));
        m_BundleEventHandler.handleEvent(event);
        assertThat(m_SUT.getConfigurationsListAsync(CONTROLLERID).size(), is(1));
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testBundleEventHandler ( ) throws SecurityException , NoSuchFieldException , IllegalArgumentException , IllegalAccessException { Map < String , Object > props = new HashMap < > ( ) ; props . put ( EventConstants . BUNDLE_ID , BUNDLEID ) ; props . put ( SharedPropertyConstants . EVENT_PROP_CONTROLLER_ID , CONTROLLERID ) ; Event event = new Event ( BundleMgr . TOPIC_BUNDLE_INFO_RECEIVED , props ) ; m_BundleEventHandler . handleEvent ( event ) ; props = new HashMap < > ( ) ; props . put ( RemoteMetatypeConstants . EVENT_PROP_BUNDLE_ID , BUNDLEID3 ) ; props . put ( SharedPropertyConstants . EVENT_PROP_CONTROLLER_ID , CONTROLLERID ) ; event = new Event ( RemoteMetatypeConstants . TOPIC_METATYPE_INFORMATION_AVAILABLE + RemoteConstants . REMOTE_TOPIC_SUFFIX , props ) ; m_BundleEventHandler . handleEvent ( event ) ; ArgumentCaptor < Message > messageCaptor = ArgumentCaptor . forClass ( Message . class ) ; verify ( m_MessageFactory , times ( 2 ) ) . createMetaTypeMessage ( eq ( MetaTypeMessageType . GetMetaTypeInfoRequest ) , messageCaptor . capture ( ) ) ; verify ( m_MessageWrapper , times ( 2 ) ) . queue ( eq ( CONTROLLERID ) , eq ( ( ResponseHandler ) null ) ) ; GetMetaTypeInfoRequestData infoRequest = ( GetMetaTypeInfoRequestData ) messageCaptor . getAllValues ( ) . get ( 0 ) ; assertThat ( infoRequest . getBundleId ( ) , is ( BUNDLEID ) ) ; infoRequest = ( GetMetaTypeInfoRequestData ) messageCaptor . getAllValues ( ) . get ( 1 ) ; assertThat ( infoRequest . getBundleId ( ) , is ( BUNDLEID3 ) ) ; Field metaMapField = m_SUT . getClass ( ) . getDeclaredField ( "m_MetatypeListConfigs" ) ; metaMapField . setAccessible ( true ) ; Map < Integer , List < MetaTypeModel > > metaMap = ( Map < Integer , List < MetaTypeModel > > ) metaMapField . get ( m_SUT ) ; List < MetaTypeModel > listModels = new ArrayList < MetaTypeModel > ( ) ; listModels . add ( new MetaTypeModel ( "some pid" , BUNDLEID ) ) ; listModels . add ( new MetaTypeModel ( "pid 2" , BUNDLEID2 ) ) ; metaMap . put ( CONTROLLERID , listModels ) ; props = new HashMap < > ( ) ; props . put ( EventConstants . BUNDLE_ID , BUNDLEID ) ; props . put ( SharedPropertyConstants . EVENT_PROP_CONTROLLER_ID , CONTROLLERID ) ; event = new Event ( BundleMgr . TOPIC_BUNDLE_INFO_REMOVED , props ) ; assertThat ( m_SUT . getConfigurationsListAsync ( CONTROLLERID ) . size ( ) , is ( 2 ) ) ; m_BundleEventHandler . handleEvent ( event ) ; assertThat ( m_SUT . getConfigurationsListAsync ( CONTROLLERID ) . size ( ) , is ( 1 ) ) ; }
Test the bundle event handler.
Test the bundle event handler .