mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestPersistence.java
public void testObservationQueryMax()
        throws ValidationFailedException, IllegalArgumentException, PersistenceFailedException
    {
        List<Observation> expectedObs = new ArrayList<>();
        for (int i = 0; i < 10; i++)
        {
            Observation obs = createObservation();
            obs.setCreatedTimestamp((long)i);
            expectedObs.add(obs);
            m_ObservationStore.persist(expectedObs.get(i));
        }
        
        List<Observation> actualObs = new ArrayList<>(m_ObservationStore.newQuery().withAssetType(ASSETTYPE).execute());
        
        // verify default is all
        assertThat(actualObs.size(), is(expectedObs.size()));
        for (int i = 0; i < expectedObs.size(); i++)
        {
            assertThat(actualObs.get(i), is(expectedObs.get(expectedObs.size() - i - 1)));
        }
        
        // try with max now
        actualObs = new ArrayList<>(m_ObservationStore.newQuery().
                withAssetType(ASSETTYPE).withMaxObservations(5).execute());
        
        // verify size is equal to max, but still the 5 newest
        assertThat(actualObs.size(), is(5));
        for (int i = 0; i < 5; i++)
        {
            assertThat(actualObs.get(i), is(expectedObs.get(expectedObs.size() - i - 1)));
        }
    }
/**
     * Verify can limit query to get collection back with a smaller amount of observations.
     */
Verify can limit query to get collection back with a smaller amount of observations.
Verify can limit query to get collection back with a smaller amount of observations .
public void testObservationQueryMax()
        throws ValidationFailedException, IllegalArgumentException, PersistenceFailedException
    {
        List<Observation> expectedObs = new ArrayList<>();
        for (int i = 0; i < 10; i++)
        {
            Observation obs = createObservation();
            obs.setCreatedTimestamp((long)i);
            expectedObs.add(obs);
            m_ObservationStore.persist(expectedObs.get(i));
        }
        List<Observation> actualObs = new ArrayList<>(m_ObservationStore.newQuery().withAssetType(ASSETTYPE).execute());
        assertThat(actualObs.size(), is(expectedObs.size()));
        for (int i = 0; i < expectedObs.size(); i++)
        {
            assertThat(actualObs.get(i), is(expectedObs.get(expectedObs.size() - i - 1)));
        }
        actualObs = new ArrayList<>(m_ObservationStore.newQuery().
                withAssetType(ASSETTYPE).withMaxObservations(5).execute());
        assertThat(actualObs.size(), is(5));
        for (int i = 0; i < 5; i++)
        {
            assertThat(actualObs.get(i), is(expectedObs.get(expectedObs.size() - i - 1)));
        }
    }
public void testObservationQueryMax ( ) throws ValidationFailedException , IllegalArgumentException , PersistenceFailedException { List < Observation > expectedObs = new ArrayList < > ( ) ; for ( int i = 0 ; i < 10 ; i ++ ) { Observation obs = createObservation ( ) ; obs . setCreatedTimestamp ( ( long ) i ) ; expectedObs . add ( obs ) ; m_ObservationStore . persist ( expectedObs . get ( i ) ) ; } List < Observation > actualObs = new ArrayList < > ( m_ObservationStore . newQuery ( ) . withAssetType ( ASSETTYPE ) . execute ( ) ) ; assertThat ( actualObs . size ( ) , is ( expectedObs . size ( ) ) ) ; for ( int i = 0 ; i < expectedObs . size ( ) ; i ++ ) { assertThat ( actualObs . get ( i ) , is ( expectedObs . get ( expectedObs . size ( ) - i - 1 ) ) ) ; } actualObs = new ArrayList < > ( m_ObservationStore . newQuery ( ) . withAssetType ( ASSETTYPE ) . withMaxObservations ( 5 ) . execute ( ) ) ; assertThat ( actualObs . size ( ) , is ( 5 ) ) ; for ( int i = 0 ; i < 5 ; i ++ ) { assertThat ( actualObs . get ( i ) , is ( expectedObs . get ( expectedObs . size ( ) - i - 1 ) ) ) ; } }
Verify can limit query to get collection back with a smaller amount of observations.
Verify can limit query to get collection back with a smaller amount of observations .
// verify default is all // try with max now // verify size is equal to max, but still the 5 newest