mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/asset/TestAssetImpl.java
@Test
    public void testPersistObservationFieldsSet() throws Exception
    {
        Observation observation = new Observation();
        UUID uuid = UUID.randomUUID();
        long time = System.currentTimeMillis();
        Coordinates coords = SpatialTypesFactory.newCoordinates(5, 10);
        Orientation orientation = SpatialTypesFactory.newOrientation(5, 6, 7);
        observation.setUuid(uuid);
        observation.setObservedTimestamp(time - 1000);
        observation.setCreatedTimestamp(time);
        observation.setAssetLocation(coords);
        observation.setAssetOrientation(orientation);

        // have the plug-in override the position
        Dictionary<String, Object> propsUsedForNewProp = new Hashtable<>();
        propsUsedForNewProp.put(AssetAttributes.CONFIG_PROP_PLUGIN_OVERRIDES_POSITION, true);
        when(m_Configuration.getProperties()).thenReturn(propsUsedForNewProp);
        when(m_ConfigAdmin.getConfiguration(eq(OBJ_PID), Mockito.any(String.class))).thenReturn(m_Configuration);

        // update props
        m_SUT.blockingPropsUpdate(new HashMap<String, Object>());

        m_SUT.persistObservation(observation);

        ArgumentCaptor<Observation> obsCapt = ArgumentCaptor.forClass(Observation.class);
        verify(m_ObservationStore, atLeastOnce()).persist(obsCapt.capture());

        Observation persistedObservation = obsCapt.getValue();
        assertThat(persistedObservation.getAssetName(), is(OBJ_NAME));
        assertThat(persistedObservation.getAssetUuid(), is(OBJ_UUID));
        assertThat(persistedObservation.getSystemId(), is(m_Controller.getId()));
        assertThat(persistedObservation.getVersion(), is(m_ObservationStore.getObservationVersion()));
        assertThat(persistedObservation.isSystemInTestMode(), is(true));
        assertThat(persistedObservation.getUuid(), is(uuid));
        assertThat(persistedObservation.getObservedTimestamp(), is(time - 1000));
        assertThat(persistedObservation.getCreatedTimestamp(), is(time));
        assertThat(persistedObservation.getAssetType(), is(PRODUCT_TYPE));

        assertThat(persistedObservation.getAssetLocation(), is(SpatialTypesFactory.newCoordinates(5, 10)));
        assertThat(persistedObservation.getAssetOrientation(), is(SpatialTypesFactory.newOrientation(5, 6, 7)));
    }
/**
     * Verify that UUID and timestamp fields do not get overridden if already set and that position is not changed if
     * overridden by the plug-in.
     */
Verify that UUID and timestamp fields do not get overridden if already set and that position is not changed if
overridden by the plug-in.
Verify that UUID and timestamp fields do not get overridden if already set and that position is not changed if overridden by the plug - in .
@Test
    public void testPersistObservationFieldsSet() throws Exception
    {
        Observation observation = new Observation();
        UUID uuid = UUID.randomUUID();
        long time = System.currentTimeMillis();
        Coordinates coords = SpatialTypesFactory.newCoordinates(5, 10);
        Orientation orientation = SpatialTypesFactory.newOrientation(5, 6, 7);
        observation.setUuid(uuid);
        observation.setObservedTimestamp(time - 1000);
        observation.setCreatedTimestamp(time);
        observation.setAssetLocation(coords);
        observation.setAssetOrientation(orientation);
        Dictionary<String, Object> propsUsedForNewProp = new Hashtable<>();
        propsUsedForNewProp.put(AssetAttributes.CONFIG_PROP_PLUGIN_OVERRIDES_POSITION, true);
        when(m_Configuration.getProperties()).thenReturn(propsUsedForNewProp);
        when(m_ConfigAdmin.getConfiguration(eq(OBJ_PID), Mockito.any(String.class))).thenReturn(m_Configuration);
        m_SUT.blockingPropsUpdate(new HashMap<String, Object>());
        m_SUT.persistObservation(observation);
        ArgumentCaptor<Observation> obsCapt = ArgumentCaptor.forClass(Observation.class);
        verify(m_ObservationStore, atLeastOnce()).persist(obsCapt.capture());
        Observation persistedObservation = obsCapt.getValue();
        assertThat(persistedObservation.getAssetName(), is(OBJ_NAME));
        assertThat(persistedObservation.getAssetUuid(), is(OBJ_UUID));
        assertThat(persistedObservation.getSystemId(), is(m_Controller.getId()));
        assertThat(persistedObservation.getVersion(), is(m_ObservationStore.getObservationVersion()));
        assertThat(persistedObservation.isSystemInTestMode(), is(true));
        assertThat(persistedObservation.getUuid(), is(uuid));
        assertThat(persistedObservation.getObservedTimestamp(), is(time - 1000));
        assertThat(persistedObservation.getCreatedTimestamp(), is(time));
        assertThat(persistedObservation.getAssetType(), is(PRODUCT_TYPE));
        assertThat(persistedObservation.getAssetLocation(), is(SpatialTypesFactory.newCoordinates(5, 10)));
        assertThat(persistedObservation.getAssetOrientation(), is(SpatialTypesFactory.newOrientation(5, 6, 7)));
    }
@ Test public void testPersistObservationFieldsSet ( ) throws Exception { Observation observation = new Observation ( ) ; UUID uuid = UUID . randomUUID ( ) ; long time = System . currentTimeMillis ( ) ; Coordinates coords = SpatialTypesFactory . newCoordinates ( 5 , 10 ) ; Orientation orientation = SpatialTypesFactory . newOrientation ( 5 , 6 , 7 ) ; observation . setUuid ( uuid ) ; observation . setObservedTimestamp ( time - 1000 ) ; observation . setCreatedTimestamp ( time ) ; observation . setAssetLocation ( coords ) ; observation . setAssetOrientation ( orientation ) ; Dictionary < String , Object > propsUsedForNewProp = new Hashtable < > ( ) ; propsUsedForNewProp . put ( AssetAttributes . CONFIG_PROP_PLUGIN_OVERRIDES_POSITION , true ) ; when ( m_Configuration . getProperties ( ) ) . thenReturn ( propsUsedForNewProp ) ; when ( m_ConfigAdmin . getConfiguration ( eq ( OBJ_PID ) , Mockito . any ( String . class ) ) ) . thenReturn ( m_Configuration ) ; m_SUT . blockingPropsUpdate ( new HashMap < String , Object > ( ) ) ; m_SUT . persistObservation ( observation ) ; ArgumentCaptor < Observation > obsCapt = ArgumentCaptor . forClass ( Observation . class ) ; verify ( m_ObservationStore , atLeastOnce ( ) ) . persist ( obsCapt . capture ( ) ) ; Observation persistedObservation = obsCapt . getValue ( ) ; assertThat ( persistedObservation . getAssetName ( ) , is ( OBJ_NAME ) ) ; assertThat ( persistedObservation . getAssetUuid ( ) , is ( OBJ_UUID ) ) ; assertThat ( persistedObservation . getSystemId ( ) , is ( m_Controller . getId ( ) ) ) ; assertThat ( persistedObservation . getVersion ( ) , is ( m_ObservationStore . getObservationVersion ( ) ) ) ; assertThat ( persistedObservation . isSystemInTestMode ( ) , is ( true ) ) ; assertThat ( persistedObservation . getUuid ( ) , is ( uuid ) ) ; assertThat ( persistedObservation . getObservedTimestamp ( ) , is ( time - 1000 ) ) ; assertThat ( persistedObservation . getCreatedTimestamp ( ) , is ( time ) ) ; assertThat ( persistedObservation . getAssetType ( ) , is ( PRODUCT_TYPE ) ) ; assertThat ( persistedObservation . getAssetLocation ( ) , is ( SpatialTypesFactory . newCoordinates ( 5 , 10 ) ) ) ; assertThat ( persistedObservation . getAssetOrientation ( ) , is ( SpatialTypesFactory . newOrientation ( 5 , 6 , 7 ) ) ) ; }
Verify that UUID and timestamp fields do not get overridden if already set and that position is not changed if
 overridden by the plug-in.
Verify that UUID and timestamp fields do not get overridden if already set and that position is not changed if overridden by the plug - in .
// have the plug-in override the position // update props