mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/advanced/TestBundleMgrImpl.java
@Test
    public void testGetBundles()
    {
        ArgumentCaptor<EventMessages.EventRegistrationRequestData> registrationMsg = 
                ArgumentCaptor.forClass(EventMessages.EventRegistrationRequestData.class);
        
        //Should be true since the controller is known by the controller list and therefore has no known bundles
        //until the bundles request message is responded to by the controller.
        assertThat(m_SUT.getBundlesAsync(100).isEmpty(), is(true));
        
        assertThat(m_SUT.getBundlesAsync(100).isEmpty(), is(true));
        
        ArgumentCaptor<GetBundleInfoRequestData> msgCaptor = ArgumentCaptor.forClass(GetBundleInfoRequestData.class);
        
        verify(m_MessageFactory).createBundleMessage(eq(BundleMessageType.GetBundleInfoRequest), msgCaptor.capture());
        verify(m_MessageWrapper, times(2)).queue(eq(100), Mockito.any(RemoteEventRegistrationHandler.class));
        verify(m_MessageFactory).createEventAdminMessage(eq(EventAdminMessageType.EventRegistrationRequest), 
                registrationMsg.capture());
        verify(m_MessageWrapper, times(2)).queue(eq(100), Mockito.any(RemoteEventRegistrationHandler.class));
        
        GetBundleInfoRequestData capValue = msgCaptor.getValue();
        
        assertThat(capValue, notNullValue());
        
        assertThat(capValue.hasBundleId(), is(false));
        assertThat(capValue.hasBundleDescription(), is(true));
        assertThat(capValue.getBundleDescription(), is(true));
        
        assertThat(capValue.hasBundleLastModified(), is(true));
        assertThat(capValue.getBundleLastModified(), is(true));
        
        assertThat(capValue.hasBundleLocation(), is(true));
        assertThat(capValue.getBundleLocation(), is(true));
        
        assertThat(capValue.hasBundleName(), is(true));
        assertThat(capValue.getBundleName(), is(true));
        
        assertThat(capValue.hasBundleState(), is(true));
        assertThat(capValue.getBundleState(), is(true));
        
        assertThat(capValue.hasBundleSymbolicName(), is(true));
        assertThat(capValue.getBundleSymbolicName(), is(true));
        
        assertThat(capValue.hasBundleVendor(), is(true));
        assertThat(capValue.getBundleVendor(), is(true));
        
        assertThat(capValue.hasBundleVersion(), is(true));
        assertThat(capValue.getBundleVersion(), is(true));
        
        assertThat(capValue.hasPackageExports(), is(true));
        assertThat(capValue.getPackageExports(), is(true));
        
        assertThat(capValue.hasPackageImports(), is(true));
        assertThat(capValue.getPackageImports(), is(true));
        
        List<String> topics = registrationMsg.getValue().getTopicList();
        assertThat(topics.contains("org/osgi/framework/BundleEvent/*"), is(true));
    }
/**
     * Test the get bundles method.
     * Verify that the the proper list is returned and that controller is added to the list if it is not already known.
     * Verify the correct requests are sent out.
     */
Test the get bundles method.
Verify that the the proper list is returned and that controller is added to the list if it is not already known.
Verify the correct requests are sent out.
Test the get bundles method . Verify that the the proper list is returned and that controller is added to the list if it is not already known . Verify the correct requests are sent out .
@Test
    public void testGetBundles()
    {
        ArgumentCaptor<EventMessages.EventRegistrationRequestData> registrationMsg = 
                ArgumentCaptor.forClass(EventMessages.EventRegistrationRequestData.class);
        assertThat(m_SUT.getBundlesAsync(100).isEmpty(), is(true));
        assertThat(m_SUT.getBundlesAsync(100).isEmpty(), is(true));
        ArgumentCaptor<GetBundleInfoRequestData> msgCaptor = ArgumentCaptor.forClass(GetBundleInfoRequestData.class);
        verify(m_MessageFactory).createBundleMessage(eq(BundleMessageType.GetBundleInfoRequest), msgCaptor.capture());
        verify(m_MessageWrapper, times(2)).queue(eq(100), Mockito.any(RemoteEventRegistrationHandler.class));
        verify(m_MessageFactory).createEventAdminMessage(eq(EventAdminMessageType.EventRegistrationRequest), 
                registrationMsg.capture());
        verify(m_MessageWrapper, times(2)).queue(eq(100), Mockito.any(RemoteEventRegistrationHandler.class));
        GetBundleInfoRequestData capValue = msgCaptor.getValue();
        assertThat(capValue, notNullValue());
        assertThat(capValue.hasBundleId(), is(false));
        assertThat(capValue.hasBundleDescription(), is(true));
        assertThat(capValue.getBundleDescription(), is(true));
        assertThat(capValue.hasBundleLastModified(), is(true));
        assertThat(capValue.getBundleLastModified(), is(true));
        assertThat(capValue.hasBundleLocation(), is(true));
        assertThat(capValue.getBundleLocation(), is(true));
        assertThat(capValue.hasBundleName(), is(true));
        assertThat(capValue.getBundleName(), is(true));
        assertThat(capValue.hasBundleState(), is(true));
        assertThat(capValue.getBundleState(), is(true));
        assertThat(capValue.hasBundleSymbolicName(), is(true));
        assertThat(capValue.getBundleSymbolicName(), is(true));
        assertThat(capValue.hasBundleVendor(), is(true));
        assertThat(capValue.getBundleVendor(), is(true));
        assertThat(capValue.hasBundleVersion(), is(true));
        assertThat(capValue.getBundleVersion(), is(true));
        assertThat(capValue.hasPackageExports(), is(true));
        assertThat(capValue.getPackageExports(), is(true));
        assertThat(capValue.hasPackageImports(), is(true));
        assertThat(capValue.getPackageImports(), is(true));
        List<String> topics = registrationMsg.getValue().getTopicList();
        assertThat(topics.contains("org/osgi/framework/BundleEvent/*"), is(true));
    }
@ Test public void testGetBundles ( ) { ArgumentCaptor < EventMessages . EventRegistrationRequestData > registrationMsg = ArgumentCaptor . forClass ( EventMessages . EventRegistrationRequestData . class ) ; assertThat ( m_SUT . getBundlesAsync ( 100 ) . isEmpty ( ) , is ( true ) ) ; assertThat ( m_SUT . getBundlesAsync ( 100 ) . isEmpty ( ) , is ( true ) ) ; ArgumentCaptor < GetBundleInfoRequestData > msgCaptor = ArgumentCaptor . forClass ( GetBundleInfoRequestData . class ) ; verify ( m_MessageFactory ) . createBundleMessage ( eq ( BundleMessageType . GetBundleInfoRequest ) , msgCaptor . capture ( ) ) ; verify ( m_MessageWrapper , times ( 2 ) ) . queue ( eq ( 100 ) , Mockito . any ( RemoteEventRegistrationHandler . class ) ) ; verify ( m_MessageFactory ) . createEventAdminMessage ( eq ( EventAdminMessageType . EventRegistrationRequest ) , registrationMsg . capture ( ) ) ; verify ( m_MessageWrapper , times ( 2 ) ) . queue ( eq ( 100 ) , Mockito . any ( RemoteEventRegistrationHandler . class ) ) ; GetBundleInfoRequestData capValue = msgCaptor . getValue ( ) ; assertThat ( capValue , notNullValue ( ) ) ; assertThat ( capValue . hasBundleId ( ) , is ( false ) ) ; assertThat ( capValue . hasBundleDescription ( ) , is ( true ) ) ; assertThat ( capValue . getBundleDescription ( ) , is ( true ) ) ; assertThat ( capValue . hasBundleLastModified ( ) , is ( true ) ) ; assertThat ( capValue . getBundleLastModified ( ) , is ( true ) ) ; assertThat ( capValue . hasBundleLocation ( ) , is ( true ) ) ; assertThat ( capValue . getBundleLocation ( ) , is ( true ) ) ; assertThat ( capValue . hasBundleName ( ) , is ( true ) ) ; assertThat ( capValue . getBundleName ( ) , is ( true ) ) ; assertThat ( capValue . hasBundleState ( ) , is ( true ) ) ; assertThat ( capValue . getBundleState ( ) , is ( true ) ) ; assertThat ( capValue . hasBundleSymbolicName ( ) , is ( true ) ) ; assertThat ( capValue . getBundleSymbolicName ( ) , is ( true ) ) ; assertThat ( capValue . hasBundleVendor ( ) , is ( true ) ) ; assertThat ( capValue . getBundleVendor ( ) , is ( true ) ) ; assertThat ( capValue . hasBundleVersion ( ) , is ( true ) ) ; assertThat ( capValue . getBundleVersion ( ) , is ( true ) ) ; assertThat ( capValue . hasPackageExports ( ) , is ( true ) ) ; assertThat ( capValue . getPackageExports ( ) , is ( true ) ) ; assertThat ( capValue . hasPackageImports ( ) , is ( true ) ) ; assertThat ( capValue . getPackageImports ( ) , is ( true ) ) ; List < String > topics = registrationMsg . getValue ( ) . getTopicList ( ) ; assertThat ( topics . contains ( "org/osgi/framework/BundleEvent/*" ) , is ( true ) ) ; }
Test the get bundles method.
Test the get bundles method .
//Should be true since the controller is known by the controller list and therefore has no known bundles //until the bundles request message is responded to by the controller.