mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestPersistence.java
public void testObservationQueryRange()
        throws ValidationFailedException, IllegalArgumentException, PersistenceFailedException
    {
        List<Observation> expectedObs = new ArrayList<>();
        for (int i = 0; i < 20; 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).withRange(5, 10).execute());
        
        // from is inclusive, to is exclusive so it should first 5 newest are skipped, then 5 after that
        assertThat(actualObs.size(), is(5));
        JaxbUtil.assertEqualContent(actualObs.get(0), expectedObs.get(14));
        JaxbUtil.assertEqualContent(actualObs.get(1), expectedObs.get(13));
        JaxbUtil.assertEqualContent(actualObs.get(2), expectedObs.get(12));
        JaxbUtil.assertEqualContent(actualObs.get(3), expectedObs.get(11));
        JaxbUtil.assertEqualContent(actualObs.get(4), expectedObs.get(10));
        
        // do with range all the way to the end
        actualObs = new ArrayList<>(m_ObservationStore.newQuery()
                .withAssetType(ASSETTYPE).withRange(15, 20).execute());
        
        // from is inclusive, to is exclusive so it should be the 5 oldest ones, still with newest first
        assertThat(actualObs.size(), is(5));
        JaxbUtil.assertEqualContent(actualObs.get(0), expectedObs.get(4));
        JaxbUtil.assertEqualContent(actualObs.get(1), expectedObs.get(3));
        JaxbUtil.assertEqualContent(actualObs.get(2), expectedObs.get(2));
        JaxbUtil.assertEqualContent(actualObs.get(3), expectedObs.get(1));
        JaxbUtil.assertEqualContent(actualObs.get(4), expectedObs.get(0));
    }
/**
     * Verify can limit query to a range to get collection back with a smaller amount of observations.
     */
Verify can limit query to a range to get collection back with a smaller amount of observations.
Verify can limit query to a range to get collection back with a smaller amount of observations .
public void testObservationQueryRange()
        throws ValidationFailedException, IllegalArgumentException, PersistenceFailedException
    {
        List<Observation> expectedObs = new ArrayList<>();
        for (int i = 0; i < 20; 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).withRange(5, 10).execute());
        assertThat(actualObs.size(), is(5));
        JaxbUtil.assertEqualContent(actualObs.get(0), expectedObs.get(14));
        JaxbUtil.assertEqualContent(actualObs.get(1), expectedObs.get(13));
        JaxbUtil.assertEqualContent(actualObs.get(2), expectedObs.get(12));
        JaxbUtil.assertEqualContent(actualObs.get(3), expectedObs.get(11));
        JaxbUtil.assertEqualContent(actualObs.get(4), expectedObs.get(10));
        actualObs = new ArrayList<>(m_ObservationStore.newQuery()
                .withAssetType(ASSETTYPE).withRange(15, 20).execute());
        assertThat(actualObs.size(), is(5));
        JaxbUtil.assertEqualContent(actualObs.get(0), expectedObs.get(4));
        JaxbUtil.assertEqualContent(actualObs.get(1), expectedObs.get(3));
        JaxbUtil.assertEqualContent(actualObs.get(2), expectedObs.get(2));
        JaxbUtil.assertEqualContent(actualObs.get(3), expectedObs.get(1));
        JaxbUtil.assertEqualContent(actualObs.get(4), expectedObs.get(0));
    }
public void testObservationQueryRange ( ) throws ValidationFailedException , IllegalArgumentException , PersistenceFailedException { List < Observation > expectedObs = new ArrayList < > ( ) ; for ( int i = 0 ; i < 20 ; 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 ) . withRange ( 5 , 10 ) . execute ( ) ) ; assertThat ( actualObs . size ( ) , is ( 5 ) ) ; JaxbUtil . assertEqualContent ( actualObs . get ( 0 ) , expectedObs . get ( 14 ) ) ; JaxbUtil . assertEqualContent ( actualObs . get ( 1 ) , expectedObs . get ( 13 ) ) ; JaxbUtil . assertEqualContent ( actualObs . get ( 2 ) , expectedObs . get ( 12 ) ) ; JaxbUtil . assertEqualContent ( actualObs . get ( 3 ) , expectedObs . get ( 11 ) ) ; JaxbUtil . assertEqualContent ( actualObs . get ( 4 ) , expectedObs . get ( 10 ) ) ; actualObs = new ArrayList < > ( m_ObservationStore . newQuery ( ) . withAssetType ( ASSETTYPE ) . withRange ( 15 , 20 ) . execute ( ) ) ; assertThat ( actualObs . size ( ) , is ( 5 ) ) ; JaxbUtil . assertEqualContent ( actualObs . get ( 0 ) , expectedObs . get ( 4 ) ) ; JaxbUtil . assertEqualContent ( actualObs . get ( 1 ) , expectedObs . get ( 3 ) ) ; JaxbUtil . assertEqualContent ( actualObs . get ( 2 ) , expectedObs . get ( 2 ) ) ; JaxbUtil . assertEqualContent ( actualObs . get ( 3 ) , expectedObs . get ( 1 ) ) ; JaxbUtil . assertEqualContent ( actualObs . get ( 4 ) , expectedObs . get ( 0 ) ) ; }
Verify can limit query to a range to get collection back with a smaller amount of observations.
Verify can limit query to a range to get collection back with a smaller amount of observations .
// from is inclusive, to is exclusive so it should first 5 newest are skipped, then 5 after that // do with range all the way to the end // from is inclusive, to is exclusive so it should be the 5 oldest ones, still with newest first