mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/osgi/TestEventAdminMessageService.java
@Test
    public void testEventHandlerImpl_ConversionException() throws Exception
    {
        Map<String, Object> properties = new HashMap<String, Object>();
        Event event = new Event("FAKE_EVENT", properties);
        EventRegistrationRequestData request = EventRegistrationRequestData.newBuilder()
                .setCanQueueEvent(true)
                .setExpirationTimeHours(1)
                .setObjectFormat(RemoteTypesGen.LexiconFormat.Enum.UUID_ONLY)
                .setFilter("(something.id=Red)")
                .addTopic("Blue")
                .build();
        //conversion behavior
        when(m_ConversionService.mapToComplexTypesMap(anyMap(), (RemoteTypesGen.LexiconFormat.Enum)any())).
            thenThrow(new ObjectConverterException("Exception"));

        m_SUT.new EventHandlerImpl(200, EncryptType.NONE, request).handleEvent(event);

        // wait to give thread time to start and try to read message
        Thread.sleep(500);

        ArgumentCaptor<SendEventData> messageCaptor = ArgumentCaptor.forClass(SendEventData.class);
        verify(m_MessageFactory, never()).createEventAdminMessage(eq(EventAdminMessageType.SendEvent), 
                messageCaptor.capture());
        verify(m_MessageWrapper, never()).trySend(200, EncryptType.NONE);
    }
/**
     * Test that if an exception is experienced when trying to create a remote event that the event is not sent.
     */
Test that if an exception is experienced when trying to create a remote event that the event is not sent.
Test that if an exception is experienced when trying to create a remote event that the event is not sent .
@Test
    public void testEventHandlerImpl_ConversionException() throws Exception
    {
        Map<String, Object> properties = new HashMap<String, Object>();
        Event event = new Event("FAKE_EVENT", properties);
        EventRegistrationRequestData request = EventRegistrationRequestData.newBuilder()
                .setCanQueueEvent(true)
                .setExpirationTimeHours(1)
                .setObjectFormat(RemoteTypesGen.LexiconFormat.Enum.UUID_ONLY)
                .setFilter("(something.id=Red)")
                .addTopic("Blue")
                .build();
        when(m_ConversionService.mapToComplexTypesMap(anyMap(), (RemoteTypesGen.LexiconFormat.Enum)any())).
            thenThrow(new ObjectConverterException("Exception"));
        m_SUT.new EventHandlerImpl(200, EncryptType.NONE, request).handleEvent(event);
        Thread.sleep(500);
        ArgumentCaptor<SendEventData> messageCaptor = ArgumentCaptor.forClass(SendEventData.class);
        verify(m_MessageFactory, never()).createEventAdminMessage(eq(EventAdminMessageType.SendEvent), 
                messageCaptor.capture());
        verify(m_MessageWrapper, never()).trySend(200, EncryptType.NONE);
    }
@ Test public void testEventHandlerImpl_ConversionException ( ) throws Exception { Map < String , Object > properties = new HashMap < String , Object > ( ) ; Event event = new Event ( "FAKE_EVENT" , properties ) ; EventRegistrationRequestData request = EventRegistrationRequestData . newBuilder ( ) . setCanQueueEvent ( true ) . setExpirationTimeHours ( 1 ) . setObjectFormat ( RemoteTypesGen . LexiconFormat . Enum . UUID_ONLY ) . setFilter ( "(something.id=Red)" ) . addTopic ( "Blue" ) . build ( ) ; when ( m_ConversionService . mapToComplexTypesMap ( anyMap ( ) , ( RemoteTypesGen . LexiconFormat . Enum ) any ( ) ) ) . thenThrow ( new ObjectConverterException ( "Exception" ) ) ; m_SUT . new EventHandlerImpl ( 200 , EncryptType . NONE , request ) . handleEvent ( event ) ; Thread . sleep ( 500 ) ; ArgumentCaptor < SendEventData > messageCaptor = ArgumentCaptor . forClass ( SendEventData . class ) ; verify ( m_MessageFactory , never ( ) ) . createEventAdminMessage ( eq ( EventAdminMessageType . SendEvent ) , messageCaptor . capture ( ) ) ; verify ( m_MessageWrapper , never ( ) ) . trySend ( 200 , EncryptType . NONE ) ; }
Test that if an exception is experienced when trying to create a remote event that the event is not sent.
Test that if an exception is experienced when trying to create a remote event that the event is not sent .
//conversion behavior // wait to give thread time to start and try to read message