mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/observation/TestRetrieveDeleteObsHelperImpl.java
@Test
    public void testRemoteDeletionAllAssetsTimeConstraint()
    {
        ObservationQuery query = mock(ObservationQuery.class);
        //mock obs store behavior
        when(m_ObservationStore.newQuery()).thenReturn(query);
        when(query.withAssetUuid(Mockito.any(UUID.class))).thenReturn(query);
        when(query.withTimeCreatedRange(Mockito.any(Date.class), Mockito.any(Date.class))).thenReturn(query);
        when(query.remove()).thenReturn(2000L);
        
        //date objs
        Date start = new Date(1000L);
        Date stop = new Date(5000L);
        
        //dates
        m_SUT.setRetrieveByMaxObsNum(false);
        m_SUT.setRetrieveDeleteByDate(true);
        m_SUT.setStartDate(start);
        m_SUT.setEndDate(stop);
        
        //request for observations
        m_SUT.submitDeleteObservationsRequest(null);
        
        //verify call to remote message sender for all asset observations
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        //request
        verify(m_MessageFactory).createObservationStoreMessage(
            eq(ObservationStoreMessageType.RemoveObservationRequest), messageCaptor.capture());
        verify(m_MessageWrapper).queue(eq(CONTROLLER_ID), eq((ResponseHandler)null));
        
        //verify data messages
        RemoveObservationRequestData requestData = (RemoveObservationRequestData)messageCaptor.getAllValues().get(0);
        Query queryData = requestData.getObsQuery();
        assertThat(queryData.hasCreatedTimeRange(), is(true));
        TimeConstraintData timeData = queryData.getCreatedTimeRange();
        assertThat(timeData.getStartTime(), is(start.getTime()));
        assertThat(timeData.getStopTime(), is(5999L));
        
        assertThat(queryData.hasAssetType(), is(false));
        
        //verify local remove call
        verify(query).remove();
    }
/**
     * Verify the remote request to delete Observations for all known assets with time constraint.
     */
Verify the remote request to delete Observations for all known assets with time constraint.
Verify the remote request to delete Observations for all known assets with time constraint .
@Test
    public void testRemoteDeletionAllAssetsTimeConstraint()
    {
        ObservationQuery query = mock(ObservationQuery.class);
        when(m_ObservationStore.newQuery()).thenReturn(query);
        when(query.withAssetUuid(Mockito.any(UUID.class))).thenReturn(query);
        when(query.withTimeCreatedRange(Mockito.any(Date.class), Mockito.any(Date.class))).thenReturn(query);
        when(query.remove()).thenReturn(2000L);
        Date start = new Date(1000L);
        Date stop = new Date(5000L);
        m_SUT.setRetrieveByMaxObsNum(false);
        m_SUT.setRetrieveDeleteByDate(true);
        m_SUT.setStartDate(start);
        m_SUT.setEndDate(stop);
        m_SUT.submitDeleteObservationsRequest(null);
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        verify(m_MessageFactory).createObservationStoreMessage(
            eq(ObservationStoreMessageType.RemoveObservationRequest), messageCaptor.capture());
        verify(m_MessageWrapper).queue(eq(CONTROLLER_ID), eq((ResponseHandler)null));
        RemoveObservationRequestData requestData = (RemoveObservationRequestData)messageCaptor.getAllValues().get(0);
        Query queryData = requestData.getObsQuery();
        assertThat(queryData.hasCreatedTimeRange(), is(true));
        TimeConstraintData timeData = queryData.getCreatedTimeRange();
        assertThat(timeData.getStartTime(), is(start.getTime()));
        assertThat(timeData.getStopTime(), is(5999L));
        assertThat(queryData.hasAssetType(), is(false));
        verify(query).remove();
    }
@ Test public void testRemoteDeletionAllAssetsTimeConstraint ( ) { ObservationQuery query = mock ( ObservationQuery . class ) ; when ( m_ObservationStore . newQuery ( ) ) . thenReturn ( query ) ; when ( query . withAssetUuid ( Mockito . any ( UUID . class ) ) ) . thenReturn ( query ) ; when ( query . withTimeCreatedRange ( Mockito . any ( Date . class ) , Mockito . any ( Date . class ) ) ) . thenReturn ( query ) ; when ( query . remove ( ) ) . thenReturn ( 2000L ) ; Date start = new Date ( 1000L ) ; Date stop = new Date ( 5000L ) ; m_SUT . setRetrieveByMaxObsNum ( false ) ; m_SUT . setRetrieveDeleteByDate ( true ) ; m_SUT . setStartDate ( start ) ; m_SUT . setEndDate ( stop ) ; m_SUT . submitDeleteObservationsRequest ( null ) ; ArgumentCaptor < Message > messageCaptor = ArgumentCaptor . forClass ( Message . class ) ; verify ( m_MessageFactory ) . createObservationStoreMessage ( eq ( ObservationStoreMessageType . RemoveObservationRequest ) , messageCaptor . capture ( ) ) ; verify ( m_MessageWrapper ) . queue ( eq ( CONTROLLER_ID ) , eq ( ( ResponseHandler ) null ) ) ; RemoveObservationRequestData requestData = ( RemoveObservationRequestData ) messageCaptor . getAllValues ( ) . get ( 0 ) ; Query queryData = requestData . getObsQuery ( ) ; assertThat ( queryData . hasCreatedTimeRange ( ) , is ( true ) ) ; TimeConstraintData timeData = queryData . getCreatedTimeRange ( ) ; assertThat ( timeData . getStartTime ( ) , is ( start . getTime ( ) ) ) ; assertThat ( timeData . getStopTime ( ) , is ( 5999L ) ) ; assertThat ( queryData . hasAssetType ( ) , is ( false ) ) ; verify ( query ) . remove ( ) ; }
Verify the remote request to delete Observations for all known assets with time constraint.
Verify the remote request to delete Observations for all known assets with time constraint .
//mock obs store behavior //date objs //dates //request for observations //verify call to remote message sender for all asset observations //request //verify data messages //verify local remove call