mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestPersistence.java
public void testQueryByObsType() throws ValidationFailedException, IllegalArgumentException, 
        PersistenceFailedException
    {
        //verify there are no pre-existing observations
        m_ObservationStore.removeBySubType(ObservationSubTypeEnum.AUDIO_METADATA);
        final Collection<Observation> observationCollection = m_ObservationStore.
                queryBySubType(ObservationSubTypeEnum.AUDIO_METADATA);
        assertThat(observationCollection, is(notNullValue()));
        assertThat(observationCollection.size(), is(0));
        
        //create an audio observation
        final UUID audioUuid = UUID.randomUUID();
        final Observation audioObservation = new Observation();
        final AudioMetadata audioMetadata = new AudioMetadata();
        audioMetadata.setStartTime(0L);
        audioMetadata.setEndTime(1000L);
        final AudioRecorder audioRecorder = new AudioRecorder();
        audioRecorder.setValue(AudioRecorderEnum.MICROPHONE);
        audioMetadata.setRecorderType(audioRecorder);
        audioMetadata.setSampleRateKHz(20.0);
        
        audioObservation.setAudioMetadata(audioMetadata);
        audioObservation.setAssetUuid(audioUuid);
        audioObservation.setAssetName("audioAssetName");
        audioObservation.setAssetType("audioAsset");
        audioObservation.setCreatedTimestamp(System.currentTimeMillis());
        audioObservation.setUuid(UUID.randomUUID());
        audioObservation.setDigitalMedia(new DigitalMedia(new byte[1000], "audio/mp3"));
        audioObservation.setVersion(new Version(1,0));
        
        m_ObservationStore.persist(audioObservation);
        final Observation returnedAudioObservation = m_ObservationStore.find(audioObservation.getUuid());
        
        //update the asset id
        final UUID mergedUuid = UUID.randomUUID();
        returnedAudioObservation.setAssetUuid(mergedUuid);
        m_ObservationStore.merge(returnedAudioObservation);
        
        //verify
        final Observation returnedAudioObservation2 = m_ObservationStore.find(returnedAudioObservation.getUuid());
        assertThat(returnedAudioObservation2.getAssetUuid(), is(mergedUuid));
        Collection<Observation> audioObservations = m_ObservationStore.queryBySubType(
                ObservationSubTypeEnum.AUDIO_METADATA);
        assertThat(audioObservations.size(), is(1));
    }
/**
     * Test query by observation type.
     */
Test query by observation type.
Test query by observation type .
public void testQueryByObsType() throws ValidationFailedException, IllegalArgumentException, 
        PersistenceFailedException
    {
        m_ObservationStore.removeBySubType(ObservationSubTypeEnum.AUDIO_METADATA);
        final Collection<Observation> observationCollection = m_ObservationStore.
                queryBySubType(ObservationSubTypeEnum.AUDIO_METADATA);
        assertThat(observationCollection, is(notNullValue()));
        assertThat(observationCollection.size(), is(0));
        final UUID audioUuid = UUID.randomUUID();
        final Observation audioObservation = new Observation();
        final AudioMetadata audioMetadata = new AudioMetadata();
        audioMetadata.setStartTime(0L);
        audioMetadata.setEndTime(1000L);
        final AudioRecorder audioRecorder = new AudioRecorder();
        audioRecorder.setValue(AudioRecorderEnum.MICROPHONE);
        audioMetadata.setRecorderType(audioRecorder);
        audioMetadata.setSampleRateKHz(20.0);
        audioObservation.setAudioMetadata(audioMetadata);
        audioObservation.setAssetUuid(audioUuid);
        audioObservation.setAssetName("audioAssetName");
        audioObservation.setAssetType("audioAsset");
        audioObservation.setCreatedTimestamp(System.currentTimeMillis());
        audioObservation.setUuid(UUID.randomUUID());
        audioObservation.setDigitalMedia(new DigitalMedia(new byte[1000], "audio/mp3"));
        audioObservation.setVersion(new Version(1,0));
        m_ObservationStore.persist(audioObservation);
        final Observation returnedAudioObservation = m_ObservationStore.find(audioObservation.getUuid());
        final UUID mergedUuid = UUID.randomUUID();
        returnedAudioObservation.setAssetUuid(mergedUuid);
        m_ObservationStore.merge(returnedAudioObservation);
        final Observation returnedAudioObservation2 = m_ObservationStore.find(returnedAudioObservation.getUuid());
        assertThat(returnedAudioObservation2.getAssetUuid(), is(mergedUuid));
        Collection<Observation> audioObservations = m_ObservationStore.queryBySubType(
                ObservationSubTypeEnum.AUDIO_METADATA);
        assertThat(audioObservations.size(), is(1));
    }
public void testQueryByObsType ( ) throws ValidationFailedException , IllegalArgumentException , PersistenceFailedException { m_ObservationStore . removeBySubType ( ObservationSubTypeEnum . AUDIO_METADATA ) ; final Collection < Observation > observationCollection = m_ObservationStore . queryBySubType ( ObservationSubTypeEnum . AUDIO_METADATA ) ; assertThat ( observationCollection , is ( notNullValue ( ) ) ) ; assertThat ( observationCollection . size ( ) , is ( 0 ) ) ; final UUID audioUuid = UUID . randomUUID ( ) ; final Observation audioObservation = new Observation ( ) ; final AudioMetadata audioMetadata = new AudioMetadata ( ) ; audioMetadata . setStartTime ( 0L ) ; audioMetadata . setEndTime ( 1000L ) ; final AudioRecorder audioRecorder = new AudioRecorder ( ) ; audioRecorder . setValue ( AudioRecorderEnum . MICROPHONE ) ; audioMetadata . setRecorderType ( audioRecorder ) ; audioMetadata . setSampleRateKHz ( 20.0 ) ; audioObservation . setAudioMetadata ( audioMetadata ) ; audioObservation . setAssetUuid ( audioUuid ) ; audioObservation . setAssetName ( "audioAssetName" ) ; audioObservation . setAssetType ( "audioAsset" ) ; audioObservation . setCreatedTimestamp ( System . currentTimeMillis ( ) ) ; audioObservation . setUuid ( UUID . randomUUID ( ) ) ; audioObservation . setDigitalMedia ( new DigitalMedia ( new byte [ 1000 ] , "audio/mp3" ) ) ; audioObservation . setVersion ( new Version ( 1 , 0 ) ) ; m_ObservationStore . persist ( audioObservation ) ; final Observation returnedAudioObservation = m_ObservationStore . find ( audioObservation . getUuid ( ) ) ; final UUID mergedUuid = UUID . randomUUID ( ) ; returnedAudioObservation . setAssetUuid ( mergedUuid ) ; m_ObservationStore . merge ( returnedAudioObservation ) ; final Observation returnedAudioObservation2 = m_ObservationStore . find ( returnedAudioObservation . getUuid ( ) ) ; assertThat ( returnedAudioObservation2 . getAssetUuid ( ) , is ( mergedUuid ) ) ; Collection < Observation > audioObservations = m_ObservationStore . queryBySubType ( ObservationSubTypeEnum . AUDIO_METADATA ) ; assertThat ( audioObservations . size ( ) , is ( 1 ) ) ; }
Test query by observation type.
Test query by observation type .
//verify there are no pre-existing observations //create an audio observation //update the asset id //verify