mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/osgi/TestEventAdminMessageService.java
@Test
    public void testEventHandlerImpl() throws Exception
    {
        Map<String, Object> properties = new HashMap<String, Object>();
        Event event = new Event("FAKE_EVENT", properties);

        EventRegistrationRequestData requestData = EventRegistrationRequestData.newBuilder()
                .setCanQueueEvent(false)
                .setExpirationTimeHours(1)
                .setObjectFormat(RemoteTypesGen.LexiconFormat.Enum.XML)
                .setFilter("(something.id=Gold)")
                .addTopic("Silver")
                .build();        
        
        //conversion behavior
        List<ComplexTypesMapEntry> props = new ArrayList<ComplexTypesMapEntry>();
        ComplexTypesMapEntry entry = ComplexTypesMapEntry.newBuilder().
            setKey("fakeKey").
            setMulti(Multitype.newBuilder().
                setType(Type.STRING).
                setStringValue("fakeValue").build()).build();
        props.add(entry);
        when(m_ConversionService. mapToComplexTypesMap(anyMap(), 
                (RemoteTypesGen.LexiconFormat.Enum)any())).thenReturn(props);

        m_SUT.new EventHandlerImpl(200, EncryptType.AES_ECDH_ECDSA, 
                requestData).handleEvent(event);
        
        // verify format is passed properly
        verify(m_ConversionService, timeout(1000)).mapToComplexTypesMap(anyMap(), 
                eq(RemoteTypesGen.LexiconFormat.Enum.XML));

        ArgumentCaptor<SendEventData> messageCaptor = ArgumentCaptor.forClass(SendEventData.class);
        verify(m_MessageFactory, timeout(1000)).createEventAdminMessage(eq(EventAdminMessageType.SendEvent), 
                messageCaptor.capture());
        verify(m_MessageWrapper, timeout(1000)).trySend(200, EncryptType.AES_ECDH_ECDSA);

        // verify content of message
        SendEventData eventMessage = messageCaptor.getValue();
        assertThat(eventMessage.getTopic(), is("FAKE_EVENT"));

        ComplexTypesMapEntry entry1 = eventMessage.getProperty(0);
        assertThat(entry1.getKey(), is("fakeKey"));
        assertThat(entry1.getMulti().getStringValue(), is("fakeValue"));
        ComplexTypesMapEntry entry2 = eventMessage.getProperty(1);
        assertThat(entry2.getKey(), is(RemoteConstants.REMOTE_EVENT_PROP));
        assertThat(entry2.getMulti().getBoolValue(), is(true));
    }
/**
     * Test event handling logic for locally posted events.
     */
Test event handling logic for locally posted events.
Test event handling logic for locally posted events .
@Test
    public void testEventHandlerImpl() throws Exception
    {
        Map<String, Object> properties = new HashMap<String, Object>();
        Event event = new Event("FAKE_EVENT", properties);
        EventRegistrationRequestData requestData = EventRegistrationRequestData.newBuilder()
                .setCanQueueEvent(false)
                .setExpirationTimeHours(1)
                .setObjectFormat(RemoteTypesGen.LexiconFormat.Enum.XML)
                .setFilter("(something.id=Gold)")
                .addTopic("Silver")
                .build();        
        List<ComplexTypesMapEntry> props = new ArrayList<ComplexTypesMapEntry>();
        ComplexTypesMapEntry entry = ComplexTypesMapEntry.newBuilder().
            setKey("fakeKey").
            setMulti(Multitype.newBuilder().
                setType(Type.STRING).
                setStringValue("fakeValue").build()).build();
        props.add(entry);
        when(m_ConversionService. mapToComplexTypesMap(anyMap(), 
                (RemoteTypesGen.LexiconFormat.Enum)any())).thenReturn(props);
        m_SUT.new EventHandlerImpl(200, EncryptType.AES_ECDH_ECDSA, 
                requestData).handleEvent(event);
        verify(m_ConversionService, timeout(1000)).mapToComplexTypesMap(anyMap(), 
                eq(RemoteTypesGen.LexiconFormat.Enum.XML));
        ArgumentCaptor<SendEventData> messageCaptor = ArgumentCaptor.forClass(SendEventData.class);
        verify(m_MessageFactory, timeout(1000)).createEventAdminMessage(eq(EventAdminMessageType.SendEvent), 
                messageCaptor.capture());
        verify(m_MessageWrapper, timeout(1000)).trySend(200, EncryptType.AES_ECDH_ECDSA);
        SendEventData eventMessage = messageCaptor.getValue();
        assertThat(eventMessage.getTopic(), is("FAKE_EVENT"));
        ComplexTypesMapEntry entry1 = eventMessage.getProperty(0);
        assertThat(entry1.getKey(), is("fakeKey"));
        assertThat(entry1.getMulti().getStringValue(), is("fakeValue"));
        ComplexTypesMapEntry entry2 = eventMessage.getProperty(1);
        assertThat(entry2.getKey(), is(RemoteConstants.REMOTE_EVENT_PROP));
        assertThat(entry2.getMulti().getBoolValue(), is(true));
    }
@ Test public void testEventHandlerImpl ( ) throws Exception { Map < String , Object > properties = new HashMap < String , Object > ( ) ; Event event = new Event ( "FAKE_EVENT" , properties ) ; EventRegistrationRequestData requestData = EventRegistrationRequestData . newBuilder ( ) . setCanQueueEvent ( false ) . setExpirationTimeHours ( 1 ) . setObjectFormat ( RemoteTypesGen . LexiconFormat . Enum . XML ) . setFilter ( "(something.id=Gold)" ) . addTopic ( "Silver" ) . build ( ) ; List < ComplexTypesMapEntry > props = new ArrayList < ComplexTypesMapEntry > ( ) ; ComplexTypesMapEntry entry = ComplexTypesMapEntry . newBuilder ( ) . setKey ( "fakeKey" ) . setMulti ( Multitype . newBuilder ( ) . setType ( Type . STRING ) . setStringValue ( "fakeValue" ) . build ( ) ) . build ( ) ; props . add ( entry ) ; when ( m_ConversionService . mapToComplexTypesMap ( anyMap ( ) , ( RemoteTypesGen . LexiconFormat . Enum ) any ( ) ) ) . thenReturn ( props ) ; m_SUT . new EventHandlerImpl ( 200 , EncryptType . AES_ECDH_ECDSA , requestData ) . handleEvent ( event ) ; verify ( m_ConversionService , timeout ( 1000 ) ) . mapToComplexTypesMap ( anyMap ( ) , eq ( RemoteTypesGen . LexiconFormat . Enum . XML ) ) ; ArgumentCaptor < SendEventData > messageCaptor = ArgumentCaptor . forClass ( SendEventData . class ) ; verify ( m_MessageFactory , timeout ( 1000 ) ) . createEventAdminMessage ( eq ( EventAdminMessageType . SendEvent ) , messageCaptor . capture ( ) ) ; verify ( m_MessageWrapper , timeout ( 1000 ) ) . trySend ( 200 , EncryptType . AES_ECDH_ECDSA ) ; SendEventData eventMessage = messageCaptor . getValue ( ) ; assertThat ( eventMessage . getTopic ( ) , is ( "FAKE_EVENT" ) ) ; ComplexTypesMapEntry entry1 = eventMessage . getProperty ( 0 ) ; assertThat ( entry1 . getKey ( ) , is ( "fakeKey" ) ) ; assertThat ( entry1 . getMulti ( ) . getStringValue ( ) , is ( "fakeValue" ) ) ; ComplexTypesMapEntry entry2 = eventMessage . getProperty ( 1 ) ; assertThat ( entry2 . getKey ( ) , is ( RemoteConstants . REMOTE_EVENT_PROP ) ) ; assertThat ( entry2 . getMulti ( ) . getBoolValue ( ) , is ( true ) ) ; }
Test event handling logic for locally posted events.
Test event handling logic for locally posted events .
//conversion behavior // verify format is passed properly // verify content of message