mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/observation/TestRetrieveDeleteObsHelperImpl.java
@Test
    public void testRemoteDeleteAnAsset()
    {
        //obs store query
        ObservationQuery obsQuery = mock(ObservationQuery.class);
        when(m_ObservationStore.newQuery()).thenReturn(obsQuery);
        when(obsQuery.remove()).thenReturn(2L);
        
        //asset UUID
        UUID asset2UUID = UUID.randomUUID();
        
        //asset model mock
        AssetModel asset2 = mock(AssetModel.class);
        when(asset2.getUuid()).thenReturn(asset2UUID);

        //request to delete observations
        m_SUT.submitDeleteObservationsRequest(asset2);
        
        //verify call to remote message sender to delete 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));
        
        RemoveObservationRequestData requestData = (RemoveObservationRequestData)messageCaptor.getValue();
        Query query = requestData.getObsQuery();
        assertThat(query.hasCreatedTimeRange(), is(false));
        assertThat(query.getAssetUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(asset2UUID)));
        
        //verify local remove call
        verify(obsQuery).withAssetUuid(asset2UUID);
        verify(obsQuery).remove();
    }
/**
     * Verify the remote request to delete Observations for a known asset.
     */
Verify the remote request to delete Observations for a known asset.
Verify the remote request to delete Observations for a known asset .
@Test
    public void testRemoteDeleteAnAsset()
    {
        ObservationQuery obsQuery = mock(ObservationQuery.class);
        when(m_ObservationStore.newQuery()).thenReturn(obsQuery);
        when(obsQuery.remove()).thenReturn(2L);
        UUID asset2UUID = UUID.randomUUID();
        AssetModel asset2 = mock(AssetModel.class);
        when(asset2.getUuid()).thenReturn(asset2UUID);
        m_SUT.submitDeleteObservationsRequest(asset2);
        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.getValue();
        Query query = requestData.getObsQuery();
        assertThat(query.hasCreatedTimeRange(), is(false));
        assertThat(query.getAssetUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(asset2UUID)));
        verify(obsQuery).withAssetUuid(asset2UUID);
        verify(obsQuery).remove();
    }
@ Test public void testRemoteDeleteAnAsset ( ) { ObservationQuery obsQuery = mock ( ObservationQuery . class ) ; when ( m_ObservationStore . newQuery ( ) ) . thenReturn ( obsQuery ) ; when ( obsQuery . remove ( ) ) . thenReturn ( 2L ) ; UUID asset2UUID = UUID . randomUUID ( ) ; AssetModel asset2 = mock ( AssetModel . class ) ; when ( asset2 . getUuid ( ) ) . thenReturn ( asset2UUID ) ; m_SUT . submitDeleteObservationsRequest ( asset2 ) ; 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 . getValue ( ) ; Query query = requestData . getObsQuery ( ) ; assertThat ( query . hasCreatedTimeRange ( ) , is ( false ) ) ; assertThat ( query . getAssetUuid ( ) , is ( SharedMessageUtils . convertUUIDToProtoUUID ( asset2UUID ) ) ) ; verify ( obsQuery ) . withAssetUuid ( asset2UUID ) ; verify ( obsQuery ) . remove ( ) ; }
Verify the remote request to delete Observations for a known asset.
Verify the remote request to delete Observations for a known asset .
//obs store query //asset UUID //asset model mock //request to delete observations //verify call to remote message sender to delete observations //request //verify local remove call