mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/asset/TestAssetMessageService.java
@Test
    public final void testDefaultCaseInHandleMessage() throws IOException
    {
        AssetNamespace assetMessage = AssetNamespace.newBuilder().
                setType(AssetMessageType.ActivateResponse).build();
        TerraHarvestPayload payload = createPayload(assetMessage);
        TerraHarvestMessage message = createMessage(assetMessage);

        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);

        // replay
        m_SUT.handleMessage(message, payload, channel);

        // verify event is posted
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event postedEvent = eventCaptor.getValue();

        assertThat(postedEvent.getTopic(), is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        assertThat((TerraHarvestMessage)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE), is(message));
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(assetMessage.getType().toString()));
        assertThat((AssetNamespace)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(assetMessage));
        assertThat(postedEvent.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE), 
                is(nullValue()));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));        
    }
/**
     * Ensure that event is handled properly if type does not match expected types in handle message method.
     */
Ensure that event is handled properly if type does not match expected types in handle message method.
Ensure that event is handled properly if type does not match expected types in handle message method .
@Test
    public final void testDefaultCaseInHandleMessage() throws IOException
    {
        AssetNamespace assetMessage = AssetNamespace.newBuilder().
                setType(AssetMessageType.ActivateResponse).build();
        TerraHarvestPayload payload = createPayload(assetMessage);
        TerraHarvestMessage message = createMessage(assetMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event postedEvent = eventCaptor.getValue();
        assertThat(postedEvent.getTopic(), is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        assertThat((TerraHarvestMessage)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE), is(message));
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(assetMessage.getType().toString()));
        assertThat((AssetNamespace)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(assetMessage));
        assertThat(postedEvent.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE), 
                is(nullValue()));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));        
    }
@ Test public final void testDefaultCaseInHandleMessage ( ) throws IOException { AssetNamespace assetMessage = AssetNamespace . newBuilder ( ) . setType ( AssetMessageType . ActivateResponse ) . build ( ) ; TerraHarvestPayload payload = createPayload ( assetMessage ) ; TerraHarvestMessage message = createMessage ( assetMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event postedEvent = eventCaptor . getValue ( ) ; assertThat ( postedEvent . getTopic ( ) , is ( RemoteConstants . TOPIC_MESSAGE_RECEIVED ) ) ; assertThat ( ( TerraHarvestMessage ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE ) , is ( message ) ) ; assertThat ( ( String ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( assetMessage . getType ( ) . toString ( ) ) ) ; assertThat ( ( AssetNamespace ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_NAMESPACE_MESSAGE ) , is ( assetMessage ) ) ; assertThat ( postedEvent . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( nullValue ( ) ) ) ; assertThat ( ( RemoteChannel ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_CHANNEL ) , is ( channel ) ) ; }
Ensure that event is handled properly if type does not match expected types in handle message method.
Ensure that event is handled properly if type does not match expected types in handle message method .
// mock the channel the message came from // replay // verify event is posted