mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/observation/TestObservationMgrImpl.java
private Observation createMockedObservation(UUID uuid, long timestamp, final boolean canFindRefObs, 
            ObservationSubTypeEnum ... refTypes)
    {
        Observation observation = mock(Observation.class);
        
        when(observation.getCreatedTimestamp()).thenReturn(timestamp);
        when(observation.getUuid()).thenReturn(uuid);
        
        List<ObservationRef> obsRefs = new ArrayList<>();
        
        for (ObservationSubTypeEnum type : refTypes)
        {
            ObservationRef ref = mock(ObservationRef.class);
            
            UUID refUuid = UUID.randomUUID();
            when(ref.getUuid()).thenReturn(refUuid);
            
            Observation refObservation = mock (Observation.class);
            
            switch (type)
            {
                case DETECTION:
                    when(refObservation.isSetDetection()).thenReturn(true);
                    break;
                case STATUS:
                    when(refObservation.isSetStatus()).thenReturn(true);
                    break;
                case WEATHER:
                    when(refObservation.isSetWeather()).thenReturn(true);
                    break;
                case AUDIO_METADATA:
                    when(refObservation.isSetDigitalMedia()).thenReturn(true);
                    when(refObservation.isSetAudioMetadata()).thenReturn(true);
                    break;
                case IMAGE_METADATA:
                    when(refObservation.isSetDigitalMedia()).thenReturn(true);
                    when(refObservation.isSetImageMetadata()).thenReturn(true);
                    break;
                case VIDEO_METADATA:
                    when(refObservation.isSetDigitalMedia()).thenReturn(true);
                    when(refObservation.isSetVideoMetadata()).thenReturn(true);
                    break;
                case BIOLOGICAL:
                    when(refObservation.isSetBiological()).thenReturn(true);
                    break;
                case CBRNE_TRIGGER:
                    when(refObservation.isSetCbrneTrigger()).thenReturn(true);
                    break;
                case CHEMICAL:
                    when(refObservation.isSetChemical()).thenReturn(true);
                    break;
                case WATER_QUALITY:
                    when(refObservation.isSetWaterQuality()).thenReturn(true);
                    break;
                case POWER:
                    when(refObservation.isSetPower()).thenReturn(true);
                    break;
                default:
                    //do nothing other is desired type
                    break;
            }
            
            if (canFindRefObs)
            {
                when(m_ObservationStore.find(refUuid)).thenReturn(refObservation);
            }
            else
            {
                when(ref.getRelationship()).thenReturn(mock(Relationship.class));
                when(m_ObservationStore.find(refUuid)).thenReturn(null);
            }
            
            obsRefs.add(ref);
        }
        
        when(observation.getRelatedObservations()).thenReturn(obsRefs);
        
        return observation;
    }
/**
     * Function creates a mocked observation which has the given uuid, timestamp, and related observations which 
     * are of the observation type specified.
     * The number of related observations depends on the number of observation types passed in. 
     * @param uuid
     *  the uuid of the observation that is to be created
     * @param timestamp
     *  the timestamp of the observation to be created
     * @param canFindRefObs
     *  if the referenced observation can be found in the observation store
     * @param refTypes
     *  the observation types of the observation references that the created observation is to contain
     * @return
     *  the mock observation with the given data
     */
Function creates a mocked observation which has the given uuid, timestamp, and related observations which
are of the observation type specified.
The number of related observations depends on the number of observation types passed in.
Function creates a mocked observation which has the given uuid timestamp and related observations which are of the observation type specified . The number of related observations depends on the number of observation types passed in .
private Observation createMockedObservation(UUID uuid, long timestamp, final boolean canFindRefObs, 
            ObservationSubTypeEnum ... refTypes)
    {
        Observation observation = mock(Observation.class);
        when(observation.getCreatedTimestamp()).thenReturn(timestamp);
        when(observation.getUuid()).thenReturn(uuid);
        List<ObservationRef> obsRefs = new ArrayList<>();
        for (ObservationSubTypeEnum type : refTypes)
        {
            ObservationRef ref = mock(ObservationRef.class);
            UUID refUuid = UUID.randomUUID();
            when(ref.getUuid()).thenReturn(refUuid);
            Observation refObservation = mock (Observation.class);
            switch (type)
            {
                case DETECTION:
                    when(refObservation.isSetDetection()).thenReturn(true);
                    break;
                case STATUS:
                    when(refObservation.isSetStatus()).thenReturn(true);
                    break;
                case WEATHER:
                    when(refObservation.isSetWeather()).thenReturn(true);
                    break;
                case AUDIO_METADATA:
                    when(refObservation.isSetDigitalMedia()).thenReturn(true);
                    when(refObservation.isSetAudioMetadata()).thenReturn(true);
                    break;
                case IMAGE_METADATA:
                    when(refObservation.isSetDigitalMedia()).thenReturn(true);
                    when(refObservation.isSetImageMetadata()).thenReturn(true);
                    break;
                case VIDEO_METADATA:
                    when(refObservation.isSetDigitalMedia()).thenReturn(true);
                    when(refObservation.isSetVideoMetadata()).thenReturn(true);
                    break;
                case BIOLOGICAL:
                    when(refObservation.isSetBiological()).thenReturn(true);
                    break;
                case CBRNE_TRIGGER:
                    when(refObservation.isSetCbrneTrigger()).thenReturn(true);
                    break;
                case CHEMICAL:
                    when(refObservation.isSetChemical()).thenReturn(true);
                    break;
                case WATER_QUALITY:
                    when(refObservation.isSetWaterQuality()).thenReturn(true);
                    break;
                case POWER:
                    when(refObservation.isSetPower()).thenReturn(true);
                    break;
                default:
                    break;
            }
            if (canFindRefObs)
            {
                when(m_ObservationStore.find(refUuid)).thenReturn(refObservation);
            }
            else
            {
                when(ref.getRelationship()).thenReturn(mock(Relationship.class));
                when(m_ObservationStore.find(refUuid)).thenReturn(null);
            }
            obsRefs.add(ref);
        }
        when(observation.getRelatedObservations()).thenReturn(obsRefs);
        return observation;
    }
private Observation createMockedObservation ( UUID uuid , long timestamp , final boolean canFindRefObs , ObservationSubTypeEnum ... refTypes ) { Observation observation = mock ( Observation . class ) ; when ( observation . getCreatedTimestamp ( ) ) . thenReturn ( timestamp ) ; when ( observation . getUuid ( ) ) . thenReturn ( uuid ) ; List < ObservationRef > obsRefs = new ArrayList < > ( ) ; for ( ObservationSubTypeEnum type : refTypes ) { ObservationRef ref = mock ( ObservationRef . class ) ; UUID refUuid = UUID . randomUUID ( ) ; when ( ref . getUuid ( ) ) . thenReturn ( refUuid ) ; Observation refObservation = mock ( Observation . class ) ; switch ( type ) { case DETECTION : when ( refObservation . isSetDetection ( ) ) . thenReturn ( true ) ; break ; case STATUS : when ( refObservation . isSetStatus ( ) ) . thenReturn ( true ) ; break ; case WEATHER : when ( refObservation . isSetWeather ( ) ) . thenReturn ( true ) ; break ; case AUDIO_METADATA : when ( refObservation . isSetDigitalMedia ( ) ) . thenReturn ( true ) ; when ( refObservation . isSetAudioMetadata ( ) ) . thenReturn ( true ) ; break ; case IMAGE_METADATA : when ( refObservation . isSetDigitalMedia ( ) ) . thenReturn ( true ) ; when ( refObservation . isSetImageMetadata ( ) ) . thenReturn ( true ) ; break ; case VIDEO_METADATA : when ( refObservation . isSetDigitalMedia ( ) ) . thenReturn ( true ) ; when ( refObservation . isSetVideoMetadata ( ) ) . thenReturn ( true ) ; break ; case BIOLOGICAL : when ( refObservation . isSetBiological ( ) ) . thenReturn ( true ) ; break ; case CBRNE_TRIGGER : when ( refObservation . isSetCbrneTrigger ( ) ) . thenReturn ( true ) ; break ; case CHEMICAL : when ( refObservation . isSetChemical ( ) ) . thenReturn ( true ) ; break ; case WATER_QUALITY : when ( refObservation . isSetWaterQuality ( ) ) . thenReturn ( true ) ; break ; case POWER : when ( refObservation . isSetPower ( ) ) . thenReturn ( true ) ; break ; default : break ; } if ( canFindRefObs ) { when ( m_ObservationStore . find ( refUuid ) ) . thenReturn ( refObservation ) ; } else { when ( ref . getRelationship ( ) ) . thenReturn ( mock ( Relationship . class ) ) ; when ( m_ObservationStore . find ( refUuid ) ) . thenReturn ( null ) ; } obsRefs . add ( ref ) ; } when ( observation . getRelatedObservations ( ) ) . thenReturn ( obsRefs ) ; return observation ; }
Function creates a mocked observation which has the given uuid, timestamp, and related observations which
 are of the observation type specified.
Function creates a mocked observation which has the given uuid timestamp and related observations which are of the observation type specified .
//do nothing other is desired type