mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestObservationStoreMessageService.java
@Test
    public void testGetObservationCountWithQueryDefault() throws IOException, InterruptedException
    {
        //message listener that will wait for responses
        MessageListener listener = new MessageListener(socket);
        
        //create get observation request
        Query query = Query.getDefaultInstance();
        GetObservationRequestData obsResquest = GetObservationRequestData.newBuilder().
            setObsQuery(query).build();
        
        //send request
        TerraHarvestMessage message = createObservationStoreMessage(ObservationStoreMessageType.GetObservationRequest,
            obsResquest);

        //send request
        message.writeDelimitedTo(socket.getOutputStream());

        //wait for response
        Message response = listener.waitForMessage(Namespace.ObservationStore, 
            ObservationStoreMessageType.GetObservationResponse, WAIT_TIME_MS);

        //check observation is the observation expected
        ObservationStoreNamespace obsNamespaceResponse = (ObservationStoreNamespace) response;
        GetObservationResponseData getObsResponse = GetObservationResponseData.parseFrom(
            obsNamespaceResponse.getData());
        
        assertThat(getObsResponse.getObservationFormat(), is(RemoteTypesGen.LexiconFormat.Enum.NATIVE));
        assertThat(getObsResponse.getObservationNativeCount(), greaterThan(0));
               
        //create the message
        Query queryCount = Query.getDefaultInstance();
        
        GetObservationCountRequestData request = GetObservationCountRequestData
                .newBuilder().setObsQuery(queryCount).build();
        
        TerraHarvestMessage messageCount = createObservationStoreMessage(
                ObservationStoreMessageType.GetObservationCountRequest,
                request);
        
        //send request
        messageCount.writeDelimitedTo(socket.getOutputStream());
        
        Message responseCount = listener.waitForMessage(Namespace.ObservationStore, 
                ObservationStoreMessageType.GetObservationCountResponse, WAIT_TIME_MS);
        
        obsNamespaceResponse = (ObservationStoreNamespace)responseCount;
        GetObservationCountResponseData getObsCountResponse = 
                GetObservationCountResponseData.parseFrom(obsNamespaceResponse.getData());
        
        assertThat((int)getObsCountResponse.getCount(), is(getObsResponse.getObservationNativeCount()));
    }
/**
     * Verify that the correct observation count can be retrieved based on the given query.
     * Given query contains no set fields
     */
Verify that the correct observation count can be retrieved based on the given query.
Given query contains no set fields
Verify that the correct observation count can be retrieved based on the given query . Given query contains no set fields
@Test
    public void testGetObservationCountWithQueryDefault() throws IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(socket);
        Query query = Query.getDefaultInstance();
        GetObservationRequestData obsResquest = GetObservationRequestData.newBuilder().
            setObsQuery(query).build();
        TerraHarvestMessage message = createObservationStoreMessage(ObservationStoreMessageType.GetObservationRequest,
            obsResquest);
        message.writeDelimitedTo(socket.getOutputStream());
        Message response = listener.waitForMessage(Namespace.ObservationStore, 
            ObservationStoreMessageType.GetObservationResponse, WAIT_TIME_MS);
        ObservationStoreNamespace obsNamespaceResponse = (ObservationStoreNamespace) response;
        GetObservationResponseData getObsResponse = GetObservationResponseData.parseFrom(
            obsNamespaceResponse.getData());
        assertThat(getObsResponse.getObservationFormat(), is(RemoteTypesGen.LexiconFormat.Enum.NATIVE));
        assertThat(getObsResponse.getObservationNativeCount(), greaterThan(0));
        Query queryCount = Query.getDefaultInstance();
        GetObservationCountRequestData request = GetObservationCountRequestData
                .newBuilder().setObsQuery(queryCount).build();
        TerraHarvestMessage messageCount = createObservationStoreMessage(
                ObservationStoreMessageType.GetObservationCountRequest,
                request);
        messageCount.writeDelimitedTo(socket.getOutputStream());
        Message responseCount = listener.waitForMessage(Namespace.ObservationStore, 
                ObservationStoreMessageType.GetObservationCountResponse, WAIT_TIME_MS);
        obsNamespaceResponse = (ObservationStoreNamespace)responseCount;
        GetObservationCountResponseData getObsCountResponse = 
                GetObservationCountResponseData.parseFrom(obsNamespaceResponse.getData());
        assertThat((int)getObsCountResponse.getCount(), is(getObsResponse.getObservationNativeCount()));
    }
@ Test public void testGetObservationCountWithQueryDefault ( ) throws IOException , InterruptedException { MessageListener listener = new MessageListener ( socket ) ; Query query = Query . getDefaultInstance ( ) ; GetObservationRequestData obsResquest = GetObservationRequestData . newBuilder ( ) . setObsQuery ( query ) . build ( ) ; TerraHarvestMessage message = createObservationStoreMessage ( ObservationStoreMessageType . GetObservationRequest , obsResquest ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; Message response = listener . waitForMessage ( Namespace . ObservationStore , ObservationStoreMessageType . GetObservationResponse , WAIT_TIME_MS ) ; ObservationStoreNamespace obsNamespaceResponse = ( ObservationStoreNamespace ) response ; GetObservationResponseData getObsResponse = GetObservationResponseData . parseFrom ( obsNamespaceResponse . getData ( ) ) ; assertThat ( getObsResponse . getObservationFormat ( ) , is ( RemoteTypesGen . LexiconFormat . Enum . NATIVE ) ) ; assertThat ( getObsResponse . getObservationNativeCount ( ) , greaterThan ( 0 ) ) ; Query queryCount = Query . getDefaultInstance ( ) ; GetObservationCountRequestData request = GetObservationCountRequestData . newBuilder ( ) . setObsQuery ( queryCount ) . build ( ) ; TerraHarvestMessage messageCount = createObservationStoreMessage ( ObservationStoreMessageType . GetObservationCountRequest , request ) ; messageCount . writeDelimitedTo ( socket . getOutputStream ( ) ) ; Message responseCount = listener . waitForMessage ( Namespace . ObservationStore , ObservationStoreMessageType . GetObservationCountResponse , WAIT_TIME_MS ) ; obsNamespaceResponse = ( ObservationStoreNamespace ) responseCount ; GetObservationCountResponseData getObsCountResponse = GetObservationCountResponseData . parseFrom ( obsNamespaceResponse . getData ( ) ) ; assertThat ( ( int ) getObsCountResponse . getCount ( ) , is ( getObsResponse . getObservationNativeCount ( ) ) ) ; }
Verify that the correct observation count can be retrieved based on the given query.
Verify that the correct observation count can be retrieved based on the given query .
//message listener that will wait for responses //create get observation request //send request //send request //wait for response //check observation is the observation expected //create the message //send request