mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/persistence/TestObservationStoreImpl.java
@Test
    public final void testMergeObservation() throws IllegalArgumentException, PersistenceFailedException, 
        ValidationFailedException
    {
        m_Observation.setAssetUuid(UUID.randomUUID());
        when(m_PersistenceManager.makePersistent(m_Observation)).thenReturn(m_Observation);
        m_SUT.merge(m_Observation);

        //verify
        ArgumentCaptor<Event> event = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(2)).postEvent(event.capture());
        verify(m_WakeLock, times(2)).activate();
        verify(m_WakeLock, times(2)).cancel();
 
        //check first event does not observation
        assertThat(event.getAllValues().get(0).getTopic(), is(ObservationStore.TOPIC_OBSERVATION_MERGED));
        assertThat(event.getAllValues().get(0).getProperty(ObservationStore.EVENT_PROP_OBSERVATION), 
            is(nullValue()));
        
        //second event should have the observation
        assertThat(event.getAllValues().get(1).getTopic(), is(ObservationStore.TOPIC_OBSERVATION_MERGED_WITH_OBS));
        assertThat((Observation)event.getAllValues().get(1).getProperty(ObservationStore.EVENT_PROP_OBSERVATION), 
                is(m_Observation));
    }
/**
     * Test that observations can be merged.
     * Verify events, one without an observation and the other with the actual observation as a property.
     */
Test that observations can be merged.
Verify events, one without an observation and the other with the actual observation as a property.
Test that observations can be merged . Verify events one without an observation and the other with the actual observation as a property .
@Test
    public final void testMergeObservation() throws IllegalArgumentException, PersistenceFailedException, 
        ValidationFailedException
    {
        m_Observation.setAssetUuid(UUID.randomUUID());
        when(m_PersistenceManager.makePersistent(m_Observation)).thenReturn(m_Observation);
        m_SUT.merge(m_Observation);
        ArgumentCaptor<Event> event = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(2)).postEvent(event.capture());
        verify(m_WakeLock, times(2)).activate();
        verify(m_WakeLock, times(2)).cancel();
        assertThat(event.getAllValues().get(0).getTopic(), is(ObservationStore.TOPIC_OBSERVATION_MERGED));
        assertThat(event.getAllValues().get(0).getProperty(ObservationStore.EVENT_PROP_OBSERVATION), 
            is(nullValue()));
        assertThat(event.getAllValues().get(1).getTopic(), is(ObservationStore.TOPIC_OBSERVATION_MERGED_WITH_OBS));
        assertThat((Observation)event.getAllValues().get(1).getProperty(ObservationStore.EVENT_PROP_OBSERVATION), 
                is(m_Observation));
    }
@ Test public final void testMergeObservation ( ) throws IllegalArgumentException , PersistenceFailedException , ValidationFailedException { m_Observation . setAssetUuid ( UUID . randomUUID ( ) ) ; when ( m_PersistenceManager . makePersistent ( m_Observation ) ) . thenReturn ( m_Observation ) ; m_SUT . merge ( m_Observation ) ; ArgumentCaptor < Event > event = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , times ( 2 ) ) . postEvent ( event . capture ( ) ) ; verify ( m_WakeLock , times ( 2 ) ) . activate ( ) ; verify ( m_WakeLock , times ( 2 ) ) . cancel ( ) ; assertThat ( event . getAllValues ( ) . get ( 0 ) . getTopic ( ) , is ( ObservationStore . TOPIC_OBSERVATION_MERGED ) ) ; assertThat ( event . getAllValues ( ) . get ( 0 ) . getProperty ( ObservationStore . EVENT_PROP_OBSERVATION ) , is ( nullValue ( ) ) ) ; assertThat ( event . getAllValues ( ) . get ( 1 ) . getTopic ( ) , is ( ObservationStore . TOPIC_OBSERVATION_MERGED_WITH_OBS ) ) ; assertThat ( ( Observation ) event . getAllValues ( ) . get ( 1 ) . getProperty ( ObservationStore . EVENT_PROP_OBSERVATION ) , is ( m_Observation ) ) ; }
Test that observations can be merged.
Test that observations can be merged .
//verify //check first event does not observation //second event should have the observation