mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestPersistence.java
public void testObservationStore()
        throws ValidationFailedException, IllegalArgumentException, PersistenceFailedException
    {
        final Observation observation = createObservation();
        final UUID uuid = new UUID(observation.getUuid().getMostSignificantBits(),
                                   observation.getUuid().getLeastSignificantBits());
        
        assertThat(m_ObservationStore.find(uuid), is(nullValue()));
        
        m_ObservationStore.persist(observation);
        
        final Observation observation2 = createObservation();
        observation2.setUuid(uuid);
        
        Throwable e = null;
        try { m_ObservationStore.persist(observation2); }
        catch (Throwable ex) { e = ex; }
        assertThat(e, is(instanceOf(PersistenceFailedException.class)));
        
        final Observation returnedObservation = m_ObservationStore.find(uuid);

        assertThat(returnedObservation, is(notNullValue()));
        assertThat(returnedObservation.getCreatedTimestamp(), is(observation.getCreatedTimestamp()));
        assertThat(returnedObservation.getUuid(), is(uuid));
        assertThat(returnedObservation.getAssetUuid(), is(observation.getAssetUuid()));
        assertThat(returnedObservation.getAssetType(), is(observation.getAssetType()));
        assertThat(returnedObservation.getWeather().getTemperature(), is(observation.getWeather().getTemperature()));
        
        Logging.log(LogService.LOG_INFO, 
                "\n====== Observation ======\n= Timestamp = %d\n= UUID = %s\n= AssetUuid = %s\n= AssetType = %s\n",
                returnedObservation.getCreatedTimestamp(),
                returnedObservation.getUuid().toString(),
                returnedObservation.getAssetUuid(),
                returnedObservation.getAssetType());

        m_ObservationStore.remove(uuid);
        
        assertThat(m_ObservationStore.contains(uuid), is(false));
    }
/**
     * Verify that the UUID of an observation must be unique.
     */
Verify that the UUID of an observation must be unique.
Verify that the UUID of an observation must be unique .
public void testObservationStore()
        throws ValidationFailedException, IllegalArgumentException, PersistenceFailedException
    {
        final Observation observation = createObservation();
        final UUID uuid = new UUID(observation.getUuid().getMostSignificantBits(),
                                   observation.getUuid().getLeastSignificantBits());
        assertThat(m_ObservationStore.find(uuid), is(nullValue()));
        m_ObservationStore.persist(observation);
        final Observation observation2 = createObservation();
        observation2.setUuid(uuid);
        Throwable e = null;
        try { m_ObservationStore.persist(observation2); }
        catch (Throwable ex) { e = ex; }
        assertThat(e, is(instanceOf(PersistenceFailedException.class)));
        final Observation returnedObservation = m_ObservationStore.find(uuid);
        assertThat(returnedObservation, is(notNullValue()));
        assertThat(returnedObservation.getCreatedTimestamp(), is(observation.getCreatedTimestamp()));
        assertThat(returnedObservation.getUuid(), is(uuid));
        assertThat(returnedObservation.getAssetUuid(), is(observation.getAssetUuid()));
        assertThat(returnedObservation.getAssetType(), is(observation.getAssetType()));
        assertThat(returnedObservation.getWeather().getTemperature(), is(observation.getWeather().getTemperature()));
        Logging.log(LogService.LOG_INFO, 
                "\n====== Observation ======\n= Timestamp = %d\n= UUID = %s\n= AssetUuid = %s\n= AssetType = %s\n",
                returnedObservation.getCreatedTimestamp(),
                returnedObservation.getUuid().toString(),
                returnedObservation.getAssetUuid(),
                returnedObservation.getAssetType());
        m_ObservationStore.remove(uuid);
        assertThat(m_ObservationStore.contains(uuid), is(false));
    }
public void testObservationStore ( ) throws ValidationFailedException , IllegalArgumentException , PersistenceFailedException { final Observation observation = createObservation ( ) ; final UUID uuid = new UUID ( observation . getUuid ( ) . getMostSignificantBits ( ) , observation . getUuid ( ) . getLeastSignificantBits ( ) ) ; assertThat ( m_ObservationStore . find ( uuid ) , is ( nullValue ( ) ) ) ; m_ObservationStore . persist ( observation ) ; final Observation observation2 = createObservation ( ) ; observation2 . setUuid ( uuid ) ; Throwable e = null ; try { m_ObservationStore . persist ( observation2 ) ; } catch ( Throwable ex ) { e = ex ; } assertThat ( e , is ( instanceOf ( PersistenceFailedException . class ) ) ) ; final Observation returnedObservation = m_ObservationStore . find ( uuid ) ; assertThat ( returnedObservation , is ( notNullValue ( ) ) ) ; assertThat ( returnedObservation . getCreatedTimestamp ( ) , is ( observation . getCreatedTimestamp ( ) ) ) ; assertThat ( returnedObservation . getUuid ( ) , is ( uuid ) ) ; assertThat ( returnedObservation . getAssetUuid ( ) , is ( observation . getAssetUuid ( ) ) ) ; assertThat ( returnedObservation . getAssetType ( ) , is ( observation . getAssetType ( ) ) ) ; assertThat ( returnedObservation . getWeather ( ) . getTemperature ( ) , is ( observation . getWeather ( ) . getTemperature ( ) ) ) ; Logging . log ( LogService . LOG_INFO , "\n====== Observation ======\n= Timestamp = %d\n= UUID = %s\n= AssetUuid = %s\n= AssetType = %s\n" , returnedObservation . getCreatedTimestamp ( ) , returnedObservation . getUuid ( ) . toString ( ) , returnedObservation . getAssetUuid ( ) , returnedObservation . getAssetType ( ) ) ; m_ObservationStore . remove ( uuid ) ; assertThat ( m_ObservationStore . contains ( uuid ) , is ( false ) ) ; }
Verify that the UUID of an observation must be unique.
Verify that the UUID of an observation must be unique .