mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/persistence/TestObservationStoreImpl.java
@Test
    public final void testQueryBySubType()
    {
        // mock
        Query jdoQuery = mock(Query.class);
        when(m_PersistenceManager.newQuery(m_Extent)).thenReturn(jdoQuery);
        when(jdoQuery.deletePersistentAll()).thenReturn(3827L);
        
        // mock returned obs
        Observation obs1 = new Observation().withCreatedTimestamp(100L);
        Observation obs2 = new Observation().withCreatedTimestamp(200L);
        Collection<Observation> expectedObs = new ArrayList<>(Arrays.asList(obs1, obs2));
        when(jdoQuery.execute()).thenReturn(expectedObs);
        
        Collection<Observation> actualObs = m_SUT.queryBySubType(ObservationSubTypeEnum.DETECTION);
        
        verify(jdoQuery).setFilter("this.detection.id > 0");
        assertThat(actualObs, contains(obs1, obs2));
        verify(m_WakeLock, times(2)).activate();
        verify(m_WakeLock, times(2)).cancel();
    }
/**
     * Verify querying by observation sub type sets the correct filter and returns the results. 
     */
Verify querying by observation sub type sets the correct filter and returns the results.
Verify querying by observation sub type sets the correct filter and returns the results .
@Test
    public final void testQueryBySubType()
    {
        Query jdoQuery = mock(Query.class);
        when(m_PersistenceManager.newQuery(m_Extent)).thenReturn(jdoQuery);
        when(jdoQuery.deletePersistentAll()).thenReturn(3827L);
         returned obs
        Observation obs1 = new Observation().withCreatedTimestamp(100L);
        Observation obs2 = new Observation().withCreatedTimestamp(200L);
        Collection<Observation> expectedObs = new ArrayList<>(Arrays.asList(obs1, obs2));
        when(jdoQuery.execute()).thenReturn(expectedObs);
        Collection<Observation> actualObs = m_SUT.queryBySubType(ObservationSubTypeEnum.DETECTION);
        verify(jdoQuery).setFilter("this.detection.id > 0");
        assertThat(actualObs, contains(obs1, obs2));
        verify(m_WakeLock, times(2)).activate();
        verify(m_WakeLock, times(2)).cancel();
    }
@ Test public final void testQueryBySubType ( ) { Query jdoQuery = mock ( Query . class ) ; when ( m_PersistenceManager . newQuery ( m_Extent ) ) . thenReturn ( jdoQuery ) ; when ( jdoQuery . deletePersistentAll ( ) ) . thenReturn ( 3827L ) ; Observation obs1 = new Observation ( ) . withCreatedTimestamp ( 100L ) ; Observation obs2 = new Observation ( ) . withCreatedTimestamp ( 200L ) ; Collection < Observation > expectedObs = new ArrayList < > ( Arrays . asList ( obs1 , obs2 ) ) ; when ( jdoQuery . execute ( ) ) . thenReturn ( expectedObs ) ; Collection < Observation > actualObs = m_SUT . queryBySubType ( ObservationSubTypeEnum . DETECTION ) ; verify ( jdoQuery ) . setFilter ( "this.detection.id > 0" ) ; assertThat ( actualObs , contains ( obs1 , obs2 ) ) ; verify ( m_WakeLock , times ( 2 ) ) . activate ( ) ; verify ( m_WakeLock , times ( 2 ) ) . cancel ( ) ; }
Verify querying by observation sub type sets the correct filter and returns the results.
Verify querying by observation sub type sets the correct filter and returns the results .
// mock // mock returned obs