mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/observation/TestObservationMessageService.java
@Test
    public void testRemoveObservationAll() throws IOException
    {
        //removal message
        Query query = Query.getDefaultInstance();
        RemoveObservationRequestData request = RemoveObservationRequestData.newBuilder().
            setObsQuery(query).build();
        ObservationStoreNamespace obsMessage = ObservationStoreNamespace.newBuilder().
            setData(request.toByteString()).
            setType(ObservationStoreMessageType.RemoveObservationRequest).build();
        TerraHarvestPayload payload = createPayload(obsMessage);
        TerraHarvestMessage thMessage = createMessageObservationStore(obsMessage);

        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        ObservationQuery oQuery = mockObservationQueryRemove(null, null, null, null, null, null, null, null, 1L);

        // 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(1L));
        
        verify(oQuery, never()).withAssetUuid(Mockito.any(UUID.class));
        verify(oQuery, never()).withAssetType(Mockito.anyString());
        verify(oQuery, never()).withMaxObservations(Mockito.anyInt());
        verify(oQuery, never()).withOrder(Mockito.any(ObservationQuery.SortField.class),
                                          Mockito.any(ObservationQuery.SortOrder.class));
        verify(oQuery, never()).withRange(Mockito.anyInt(), Mockito.anyInt());
        verify(oQuery, never()).withTimeCreatedRange(Mockito.any(Date.class), Mockito.any(Date.class));
        verify(oQuery, never()).withSubType(Mockito.any(ObservationSubTypeEnum.class));
    }
/**
     * Test remove observation with query with no parameters set. Verify observations still removed.
     * Verify response is sent.
     */
Test remove observation with query with no parameters set. Verify observations still removed.
Verify response is sent.
Test remove observation with query with no parameters set . Verify observations still removed . Verify response is sent .
@Test
    public void testRemoveObservationAll() throws IOException
    {
        Query query = Query.getDefaultInstance();
        RemoveObservationRequestData request = RemoveObservationRequestData.newBuilder().
            setObsQuery(query).build();
        ObservationStoreNamespace obsMessage = ObservationStoreNamespace.newBuilder().
            setData(request.toByteString()).
            setType(ObservationStoreMessageType.RemoveObservationRequest).build();
        TerraHarvestPayload payload = createPayload(obsMessage);
        TerraHarvestMessage thMessage = createMessageObservationStore(obsMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        ObservationQuery oQuery = mockObservationQueryRemove(null, null, null, null, null, null, null, null, 1L);
        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(1L));
        verify(oQuery, never()).withAssetUuid(Mockito.any(UUID.class));
        verify(oQuery, never()).withAssetType(Mockito.anyString());
        verify(oQuery, never()).withMaxObservations(Mockito.anyInt());
        verify(oQuery, never()).withOrder(Mockito.any(ObservationQuery.SortField.class),
                                          Mockito.any(ObservationQuery.SortOrder.class));
        verify(oQuery, never()).withRange(Mockito.anyInt(), Mockito.anyInt());
        verify(oQuery, never()).withTimeCreatedRange(Mockito.any(Date.class), Mockito.any(Date.class));
        verify(oQuery, never()).withSubType(Mockito.any(ObservationSubTypeEnum.class));
    }
@ Test public void testRemoveObservationAll ( ) throws IOException { Query query = Query . getDefaultInstance ( ) ; RemoveObservationRequestData request = RemoveObservationRequestData . newBuilder ( ) . setObsQuery ( query ) . build ( ) ; ObservationStoreNamespace obsMessage = ObservationStoreNamespace . newBuilder ( ) . setData ( request . toByteString ( ) ) . setType ( ObservationStoreMessageType . RemoveObservationRequest ) . build ( ) ; TerraHarvestPayload payload = createPayload ( obsMessage ) ; TerraHarvestMessage thMessage = createMessageObservationStore ( obsMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; ObservationQuery oQuery = mockObservationQueryRemove ( null , null , null , null , null , null , null , null , 1L ) ; 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 ( 1L ) ) ; verify ( oQuery , never ( ) ) . withAssetUuid ( Mockito . any ( UUID . class ) ) ; verify ( oQuery , never ( ) ) . withAssetType ( Mockito . anyString ( ) ) ; verify ( oQuery , never ( ) ) . withMaxObservations ( Mockito . anyInt ( ) ) ; verify ( oQuery , never ( ) ) . withOrder ( Mockito . any ( ObservationQuery . SortField . class ) , Mockito . any ( ObservationQuery . SortOrder . class ) ) ; verify ( oQuery , never ( ) ) . withRange ( Mockito . anyInt ( ) , Mockito . anyInt ( ) ) ; verify ( oQuery , never ( ) ) . withTimeCreatedRange ( Mockito . any ( Date . class ) , Mockito . any ( Date . class ) ) ; verify ( oQuery , never ( ) ) . withSubType ( Mockito . any ( ObservationSubTypeEnum . class ) ) ; }
Test remove observation with query with no parameters set.
Test remove observation with query with no parameters set .
//removal message // mock the channel the message came from // replay