mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/observation/TestObservationMessageService.java
@Test
    public void testRemoveObservationRequestQueryObsTypeTime() throws IOException, ObjectConverterException
    {
        //necessary messages for request
        TimeConstraintData time = getCreatedTimeConstraint();
        Query query = Query.newBuilder().
                addObservationSubType(
                        ObservationSubTypeEnumConverter.convertJavaEnumToProto(ObservationSubTypeEnum.AUDIO_METADATA))
                .setCreatedTimeRange(time).build();
        
        RemoveObservationRequestData message = RemoveObservationRequestData.newBuilder().
            setObsQuery(query).build();
        
        ObservationStoreNamespace namespace = ObservationStoreNamespace.newBuilder().
            setData(message.toByteString()).
            setType(ObservationStoreMessageType.RemoveObservationRequest).build();
        TerraHarvestPayload payload = createPayload(namespace);
        TerraHarvestMessage thMessage = createMessageObservationStore(namespace);

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

        //mock observation that will be returned from obs store
        Date timeStart = new Date(1L);
        Date timeEnd = new Date(3L);
        ObservationQuery oQuery = mockObservationQueryRemove(null, null, ObservationSubTypeEnum.AUDIO_METADATA, 
                timeStart, timeEnd, null, null, null, 2);

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

        ArgumentCaptor<Message> msgCaptor = ArgumentCaptor.forClass(Message.class);
        verify(m_MessageFactory).createObservationStoreResponseMessage(eq(thMessage), 
            eq(ObservationStoreMessageType.RemoveObservationResponse), msgCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        assertThat(msgCaptor.getValue(), notNullValue());
        assertThat(((RemoveObservationResponseData)msgCaptor.getValue()).getNumberOfObsRemoved(), is(2L));
        
        verify(oQuery).withSubType(ObservationSubTypeEnum.AUDIO_METADATA);
        verify(oQuery).withTimeCreatedRange(timeStart, timeEnd);
        verify(oQuery).remove();
    }
/**
     * Test remove observation request with action of observation type and time constraints.
     * Verify response is sent.
     */
Test remove observation request with action of observation type and time constraints.
Verify response is sent.
Test remove observation request with action of observation type and time constraints . Verify response is sent .
@Test
    public void testRemoveObservationRequestQueryObsTypeTime() throws IOException, ObjectConverterException
    {
        TimeConstraintData time = getCreatedTimeConstraint();
        Query query = Query.newBuilder().
                addObservationSubType(
                        ObservationSubTypeEnumConverter.convertJavaEnumToProto(ObservationSubTypeEnum.AUDIO_METADATA))
                .setCreatedTimeRange(time).build();
        RemoveObservationRequestData message = RemoveObservationRequestData.newBuilder().
            setObsQuery(query).build();
        ObservationStoreNamespace namespace = ObservationStoreNamespace.newBuilder().
            setData(message.toByteString()).
            setType(ObservationStoreMessageType.RemoveObservationRequest).build();
        TerraHarvestPayload payload = createPayload(namespace);
        TerraHarvestMessage thMessage = createMessageObservationStore(namespace);
        RemoteChannel channel = mock(RemoteChannel.class);
        Date timeStart = new Date(1L);
        Date timeEnd = new Date(3L);
        ObservationQuery oQuery = mockObservationQueryRemove(null, null, ObservationSubTypeEnum.AUDIO_METADATA, 
                timeStart, timeEnd, null, null, null, 2);
        m_SUT.handleMessage(thMessage, payload, channel);
        ArgumentCaptor<Message> msgCaptor = ArgumentCaptor.forClass(Message.class);
        verify(m_MessageFactory).createObservationStoreResponseMessage(eq(thMessage), 
            eq(ObservationStoreMessageType.RemoveObservationResponse), msgCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        assertThat(msgCaptor.getValue(), notNullValue());
        assertThat(((RemoveObservationResponseData)msgCaptor.getValue()).getNumberOfObsRemoved(), is(2L));
        verify(oQuery).withSubType(ObservationSubTypeEnum.AUDIO_METADATA);
        verify(oQuery).withTimeCreatedRange(timeStart, timeEnd);
        verify(oQuery).remove();
    }
@ Test public void testRemoveObservationRequestQueryObsTypeTime ( ) throws IOException , ObjectConverterException { TimeConstraintData time = getCreatedTimeConstraint ( ) ; Query query = Query . newBuilder ( ) . addObservationSubType ( ObservationSubTypeEnumConverter . convertJavaEnumToProto ( ObservationSubTypeEnum . AUDIO_METADATA ) ) . setCreatedTimeRange ( time ) . build ( ) ; RemoveObservationRequestData message = RemoveObservationRequestData . newBuilder ( ) . setObsQuery ( query ) . build ( ) ; ObservationStoreNamespace namespace = ObservationStoreNamespace . newBuilder ( ) . setData ( message . toByteString ( ) ) . setType ( ObservationStoreMessageType . RemoveObservationRequest ) . build ( ) ; TerraHarvestPayload payload = createPayload ( namespace ) ; TerraHarvestMessage thMessage = createMessageObservationStore ( namespace ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; Date timeStart = new Date ( 1L ) ; Date timeEnd = new Date ( 3L ) ; ObservationQuery oQuery = mockObservationQueryRemove ( null , null , ObservationSubTypeEnum . AUDIO_METADATA , timeStart , timeEnd , null , null , null , 2 ) ; m_SUT . handleMessage ( thMessage , payload , channel ) ; ArgumentCaptor < Message > msgCaptor = ArgumentCaptor . forClass ( Message . class ) ; verify ( m_MessageFactory ) . createObservationStoreResponseMessage ( eq ( thMessage ) , eq ( ObservationStoreMessageType . RemoveObservationResponse ) , msgCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; assertThat ( msgCaptor . getValue ( ) , notNullValue ( ) ) ; assertThat ( ( ( RemoveObservationResponseData ) msgCaptor . getValue ( ) ) . getNumberOfObsRemoved ( ) , is ( 2L ) ) ; verify ( oQuery ) . withSubType ( ObservationSubTypeEnum . AUDIO_METADATA ) ; verify ( oQuery ) . withTimeCreatedRange ( timeStart , timeEnd ) ; verify ( oQuery ) . remove ( ) ; }
Test remove observation request with action of observation type and time constraints.
Test remove observation request with action of observation type and time constraints .
//necessary messages for request // mock the channel the message came from //mock observation that will be returned from obs store // replay