mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/observation/TestObservationMessageService.java
@Test
    public void testFindByUUID() throws IOException, ObjectConverterException
    {
        //obs UUIDs
        UUID obsUuid1 = UUID.randomUUID();
        UUID obsUuid2 = UUID.randomUUID();

        //removal message
        FindObservationByUUIDRequestData request = FindObservationByUUIDRequestData.newBuilder().
            addUuidOfObservation(SharedMessageUtils.convertUUIDToProtoUUID(obsUuid1)).
            addUuidOfObservation(SharedMessageUtils.convertUUIDToProtoUUID(obsUuid2)).build();
        ObservationStoreNamespace obsMessage = ObservationStoreNamespace.newBuilder().
            setData(request.toByteString()).
            setType(ObservationStoreMessageType.FindObservationByUUIDRequest).build();
        TerraHarvestPayload payload = createPayload(obsMessage);
        TerraHarvestMessage thMessage = createMessageObservationStore(obsMessage);

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

        //mocks
        Observation obsJaxb1 = mock(Observation.class);
        Observation obsJaxb2 = mock(Observation.class);

        ObservationGen.Observation obsGen1 = TerraHarvestMessageHelper.getProtoObs();
        ObservationGen.Observation obsGen2 = TerraHarvestMessageHelper.getProtoObs();

        //mock behavior
        when(m_ObservationStore.find(obsUuid1)).thenReturn(obsJaxb1);
        when(m_ObservationStore.find(obsUuid2)).thenReturn(obsJaxb2);
        when(m_Converter.convertToProto(obsJaxb1)).thenReturn(obsGen1);
        when(m_Converter.convertToProto(obsJaxb2)).thenReturn(obsGen2);

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

        //capture response
        ArgumentCaptor<FindObservationByUUIDResponseData> response = 
            ArgumentCaptor.forClass(FindObservationByUUIDResponseData.class);
        verify(m_MessageFactory).createObservationStoreResponseMessage(eq(thMessage), 
            eq(ObservationStoreMessageType.FindObservationByUUIDResponse), response.capture());
        verify(m_ResponseWrapper).queue(channel);

        //check response message for proto observations
        FindObservationByUUIDResponseData responseData = response.getValue();
        assertThat(responseData.getObservationFormat(), is(RemoteTypesGen.LexiconFormat.Enum.NATIVE));
        assertThat(responseData.getObservationNativeList(), hasItems(obsGen1, obsGen2));
    }
/**

     * Test find observation by UUID request.
     * 
     * Verify that observations are converted and set back in response.
     */
Test find observation by UUID request.

Verify that observations are converted and set back in response.
Test find observation by UUID request . Verify that observations are converted and set back in response .
@Test
    public void testFindByUUID() throws IOException, ObjectConverterException
    {
        UUID obsUuid1 = UUID.randomUUID();
        UUID obsUuid2 = UUID.randomUUID();
        FindObservationByUUIDRequestData request = FindObservationByUUIDRequestData.newBuilder().
            addUuidOfObservation(SharedMessageUtils.convertUUIDToProtoUUID(obsUuid1)).
            addUuidOfObservation(SharedMessageUtils.convertUUIDToProtoUUID(obsUuid2)).build();
        ObservationStoreNamespace obsMessage = ObservationStoreNamespace.newBuilder().
            setData(request.toByteString()).
            setType(ObservationStoreMessageType.FindObservationByUUIDRequest).build();
        TerraHarvestPayload payload = createPayload(obsMessage);
        TerraHarvestMessage thMessage = createMessageObservationStore(obsMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        Observation obsJaxb1 = mock(Observation.class);
        Observation obsJaxb2 = mock(Observation.class);
        ObservationGen.Observation obsGen1 = TerraHarvestMessageHelper.getProtoObs();
        ObservationGen.Observation obsGen2 = TerraHarvestMessageHelper.getProtoObs();
        when(m_ObservationStore.find(obsUuid1)).thenReturn(obsJaxb1);
        when(m_ObservationStore.find(obsUuid2)).thenReturn(obsJaxb2);
        when(m_Converter.convertToProto(obsJaxb1)).thenReturn(obsGen1);
        when(m_Converter.convertToProto(obsJaxb2)).thenReturn(obsGen2);
        m_SUT.handleMessage(thMessage, payload, channel);
        ArgumentCaptor<FindObservationByUUIDResponseData> response = 
            ArgumentCaptor.forClass(FindObservationByUUIDResponseData.class);
        verify(m_MessageFactory).createObservationStoreResponseMessage(eq(thMessage), 
            eq(ObservationStoreMessageType.FindObservationByUUIDResponse), response.capture());
        verify(m_ResponseWrapper).queue(channel);
        FindObservationByUUIDResponseData responseData = response.getValue();
        assertThat(responseData.getObservationFormat(), is(RemoteTypesGen.LexiconFormat.Enum.NATIVE));
        assertThat(responseData.getObservationNativeList(), hasItems(obsGen1, obsGen2));
    }
@ Test public void testFindByUUID ( ) throws IOException , ObjectConverterException { UUID obsUuid1 = UUID . randomUUID ( ) ; UUID obsUuid2 = UUID . randomUUID ( ) ; FindObservationByUUIDRequestData request = FindObservationByUUIDRequestData . newBuilder ( ) . addUuidOfObservation ( SharedMessageUtils . convertUUIDToProtoUUID ( obsUuid1 ) ) . addUuidOfObservation ( SharedMessageUtils . convertUUIDToProtoUUID ( obsUuid2 ) ) . build ( ) ; ObservationStoreNamespace obsMessage = ObservationStoreNamespace . newBuilder ( ) . setData ( request . toByteString ( ) ) . setType ( ObservationStoreMessageType . FindObservationByUUIDRequest ) . build ( ) ; TerraHarvestPayload payload = createPayload ( obsMessage ) ; TerraHarvestMessage thMessage = createMessageObservationStore ( obsMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; Observation obsJaxb1 = mock ( Observation . class ) ; Observation obsJaxb2 = mock ( Observation . class ) ; ObservationGen . Observation obsGen1 = TerraHarvestMessageHelper . getProtoObs ( ) ; ObservationGen . Observation obsGen2 = TerraHarvestMessageHelper . getProtoObs ( ) ; when ( m_ObservationStore . find ( obsUuid1 ) ) . thenReturn ( obsJaxb1 ) ; when ( m_ObservationStore . find ( obsUuid2 ) ) . thenReturn ( obsJaxb2 ) ; when ( m_Converter . convertToProto ( obsJaxb1 ) ) . thenReturn ( obsGen1 ) ; when ( m_Converter . convertToProto ( obsJaxb2 ) ) . thenReturn ( obsGen2 ) ; m_SUT . handleMessage ( thMessage , payload , channel ) ; ArgumentCaptor < FindObservationByUUIDResponseData > response = ArgumentCaptor . forClass ( FindObservationByUUIDResponseData . class ) ; verify ( m_MessageFactory ) . createObservationStoreResponseMessage ( eq ( thMessage ) , eq ( ObservationStoreMessageType . FindObservationByUUIDResponse ) , response . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; FindObservationByUUIDResponseData responseData = response . getValue ( ) ; assertThat ( responseData . getObservationFormat ( ) , is ( RemoteTypesGen . LexiconFormat . Enum . NATIVE ) ) ; assertThat ( responseData . getObservationNativeList ( ) , hasItems ( obsGen1 , obsGen2 ) ) ; }
Test find observation by UUID request.
Test find observation by UUID request .
//obs UUIDs //removal message // mock the channel the message came from //mocks //mock behavior // replay //capture response //check response message for proto observations