mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/osgi/TestEventAdminMessageService.java
@Test
    public void testRegisterForEvent_EventHandlerParams() throws Exception 
    {
        //construct message
        EventRegistrationRequestData.Builder requestMessage = EventRegistrationRequestData.newBuilder()
                .addTopic("test-topic")
                .setObjectFormat(RemoteTypesGen.LexiconFormat.Enum.UUID_ONLY);
        // add required fields
        requestMessage = RemoteUtils.appendRequiredFields(requestMessage, false);
        EventAdminNamespace eventAdminMessage = EventAdminNamespace.newBuilder()
                .setType(EventAdminMessageType.EventRegistrationRequest)
                .setData(requestMessage.build().toByteString())
                .build();
        TerraHarvestMessage message = createEventAdminMessage(eventAdminMessage);
        TerraHarvestPayload payload = createPayload(eventAdminMessage);

        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        m_SUT.handleMessage(message, payload, channel);
        
        ArgumentCaptor<EventHandler> eventHandler = ArgumentCaptor.forClass(EventHandler.class);

        // verify that the event is being registered with the proper event handler
        verify(m_Context).registerService(eq(EventHandler.class), eventHandler.capture(), (Dictionary)any());
        
        Map<String, Object> props = new HashMap<>();
        Event event = new Event("some-topic", props);
        eventHandler.getValue().handleEvent(event);
        
        verify(m_ConversionService, timeout(1000)).mapToComplexTypesMap(props, 
                RemoteTypesGen.LexiconFormat.Enum.UUID_ONLY);
        verify(m_MessageFactory, timeout(1000)).createEventAdminMessage(eq(EventAdminMessageType.SendEvent), 
                (Message)any());
        verify(m_MessageWrapper, timeout(1000)).trySend(200, EncryptType.AES_ECDH_ECDSA);
    }
/**
     * Verify parameters are passed to event handler properly.
     */
Verify parameters are passed to event handler properly.
Verify parameters are passed to event handler properly .
@Test
    public void testRegisterForEvent_EventHandlerParams() throws Exception 
    {
        EventRegistrationRequestData.Builder requestMessage = EventRegistrationRequestData.newBuilder()
                .addTopic("test-topic")
                .setObjectFormat(RemoteTypesGen.LexiconFormat.Enum.UUID_ONLY);
        requestMessage = RemoteUtils.appendRequiredFields(requestMessage, false);
        EventAdminNamespace eventAdminMessage = EventAdminNamespace.newBuilder()
                .setType(EventAdminMessageType.EventRegistrationRequest)
                .setData(requestMessage.build().toByteString())
                .build();
        TerraHarvestMessage message = createEventAdminMessage(eventAdminMessage);
        TerraHarvestPayload payload = createPayload(eventAdminMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<EventHandler> eventHandler = ArgumentCaptor.forClass(EventHandler.class);
        verify(m_Context).registerService(eq(EventHandler.class), eventHandler.capture(), (Dictionary)any());
        Map<String, Object> props = new HashMap<>();
        Event event = new Event("some-topic", props);
        eventHandler.getValue().handleEvent(event);
        verify(m_ConversionService, timeout(1000)).mapToComplexTypesMap(props, 
                RemoteTypesGen.LexiconFormat.Enum.UUID_ONLY);
        verify(m_MessageFactory, timeout(1000)).createEventAdminMessage(eq(EventAdminMessageType.SendEvent), 
                (Message)any());
        verify(m_MessageWrapper, timeout(1000)).trySend(200, EncryptType.AES_ECDH_ECDSA);
    }
@ Test public void testRegisterForEvent_EventHandlerParams ( ) throws Exception { EventRegistrationRequestData . Builder requestMessage = EventRegistrationRequestData . newBuilder ( ) . addTopic ( "test-topic" ) . setObjectFormat ( RemoteTypesGen . LexiconFormat . Enum . UUID_ONLY ) ; requestMessage = RemoteUtils . appendRequiredFields ( requestMessage , false ) ; EventAdminNamespace eventAdminMessage = EventAdminNamespace . newBuilder ( ) . setType ( EventAdminMessageType . EventRegistrationRequest ) . setData ( requestMessage . build ( ) . toByteString ( ) ) . build ( ) ; TerraHarvestMessage message = createEventAdminMessage ( eventAdminMessage ) ; TerraHarvestPayload payload = createPayload ( eventAdminMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < EventHandler > eventHandler = ArgumentCaptor . forClass ( EventHandler . class ) ; verify ( m_Context ) . registerService ( eq ( EventHandler . class ) , eventHandler . capture ( ) , ( Dictionary ) any ( ) ) ; Map < String , Object > props = new HashMap < > ( ) ; Event event = new Event ( "some-topic" , props ) ; eventHandler . getValue ( ) . handleEvent ( event ) ; verify ( m_ConversionService , timeout ( 1000 ) ) . mapToComplexTypesMap ( props , RemoteTypesGen . LexiconFormat . Enum . UUID_ONLY ) ; verify ( m_MessageFactory , timeout ( 1000 ) ) . createEventAdminMessage ( eq ( EventAdminMessageType . SendEvent ) , ( Message ) any ( ) ) ; verify ( m_MessageWrapper , timeout ( 1000 ) ) . trySend ( 200 , EncryptType . AES_ECDH_ECDSA ) ; }
Verify parameters are passed to event handler properly.
Verify parameters are passed to event handler properly .
//construct message // add required fields // mock the channel the message came from // replay // verify that the event is being registered with the proper event handler