mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/util/TestRemotePropertyConverter.java
@Test
    public final void testMapToComplexTypesMap() throws Exception
    {
        Asset mockAsset = mock(Asset.class);
        // mock
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(FactoryDescriptor.EVENT_PROP_OBJ, mockAsset);
        props.put(FactoryDescriptor.EVENT_PROP_OBJ_UUID, "9433d480-d03e-11e1-9b23-0800200c9a66");
        props.put(EventConstants.EVENT_TOPIC, "blah");
        props.put("test", "hello");
        props.put("test2", new Object());
        props.put("test3", AssetActiveStatus.ACTIVATED);
        props.put("test4", LinkStatus.OK);
        props.put("test5", ProgramStatus.EXECUTED);
        props.put("test6", TestResult.FAILED);
        props.put("test7", SummaryStatusEnum.GOOD);
        Bundle bundle = mock(Bundle.class);
        props.put(EventConstants.EVENT, new BundleEvent(5, bundle));

        Map<String, ComplexTypesMapEntry> convertedProps = 
                Maps.uniqueIndex(m_SUT.mapToComplexTypesMap(props, null), new Function<ComplexTypesMapEntry, String>()
                {
                    @Override
                    public String apply(ComplexTypesMapEntry entry)
                    {
                        return entry.getKey();
                    }
                });
        
        assertThat(convertedProps, not(hasKey(FactoryDescriptor.EVENT_PROP_OBJ)));
        assertThat(convertedProps, not(hasKey("test2")));
        assertThat(convertedProps, not(hasKey("test3")));
        assertThat(convertedProps, not(hasKey(EventConstants.EVENT)));
        
        //verify expected values
        assertThat(convertedProps.get(FactoryDescriptor.EVENT_PROP_OBJ_UUID).getValueCase(), is(ValueCase.MULTI)); 
        assertThat(convertedProps.get(FactoryDescriptor.EVENT_PROP_OBJ_UUID).getMulti().getStringValue(), 
                is("9433d480-d03e-11e1-9b23-0800200c9a66"));
        assertThat(convertedProps.get("test").getValueCase(), is(ValueCase.MULTI)); 
        assertThat(convertedProps.get("test").getMulti().getStringValue(), is("hello"));
        assertThat(convertedProps.get(EventConstants.EVENT_TOPIC).getValueCase(), is(ValueCase.MULTI)); 
        assertThat(convertedProps.get(EventConstants.EVENT_TOPIC).getMulti().getStringValue(), is("blah"));
        assertThat(convertedProps.get("test4").getValueCase(), is(ValueCase.LINKLAYERSTATUS)); 
        assertThat(convertedProps.get("test4").getLinkLayerStatus(), is(CustomCommsTypes.LinkStatus.OK));
        assertThat(convertedProps.get("test5").getValueCase(), is(ValueCase.PROGRAMSTATUS)); 
        assertThat(convertedProps.get("test5").getProgramStatus(), is(MissionStatus.EXECUTED));
        assertThat(convertedProps.get("test6").getValueCase(), is(ValueCase.PROGRAMTESTRESULT)); 
        assertThat(convertedProps.get("test6").getProgramTestResult(), is(MissionTestResult.FAILED));
        assertThat(convertedProps.get("test7").getValueCase(), is(ValueCase.SUMMARYSTATUS)); 
        assertThat(convertedProps.get("test7").getSummaryStatus(), 
                is(SummaryStatusEnumConverter.convertJavaEnumToProto(SummaryStatusEnum.GOOD)));
    }
/**
     * Test creating a protocol buffer message equivalent of property map.
     * 
     * Verify expected values are converted, while unsupported types, like an asset are ignored.
     */
Test creating a protocol buffer message equivalent of property map.

Verify expected values are converted, while unsupported types, like an asset are ignored.
Test creating a protocol buffer message equivalent of property map . Verify expected values are converted while unsupported types like an asset are ignored .
@Test
    public final void testMapToComplexTypesMap() throws Exception
    {
        Asset mockAsset = mock(Asset.class);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(FactoryDescriptor.EVENT_PROP_OBJ, mockAsset);
        props.put(FactoryDescriptor.EVENT_PROP_OBJ_UUID, "9433d480-d03e-11e1-9b23-0800200c9a66");
        props.put(EventConstants.EVENT_TOPIC, "blah");
        props.put("test", "hello");
        props.put("test2", new Object());
        props.put("test3", AssetActiveStatus.ACTIVATED);
        props.put("test4", LinkStatus.OK);
        props.put("test5", ProgramStatus.EXECUTED);
        props.put("test6", TestResult.FAILED);
        props.put("test7", SummaryStatusEnum.GOOD);
        Bundle bundle = mock(Bundle.class);
        props.put(EventConstants.EVENT, new BundleEvent(5, bundle));
        Map<String, ComplexTypesMapEntry> convertedProps = 
                Maps.uniqueIndex(m_SUT.mapToComplexTypesMap(props, null), new Function<ComplexTypesMapEntry, String>()
                {
                    @Override
                    public String apply(ComplexTypesMapEntry entry)
                    {
                        return entry.getKey();
                    }
                });
        assertThat(convertedProps, not(hasKey(FactoryDescriptor.EVENT_PROP_OBJ)));
        assertThat(convertedProps, not(hasKey("test2")));
        assertThat(convertedProps, not(hasKey("test3")));
        assertThat(convertedProps, not(hasKey(EventConstants.EVENT)));
        assertThat(convertedProps.get(FactoryDescriptor.EVENT_PROP_OBJ_UUID).getValueCase(), is(ValueCase.MULTI)); 
        assertThat(convertedProps.get(FactoryDescriptor.EVENT_PROP_OBJ_UUID).getMulti().getStringValue(), 
                is("9433d480-d03e-11e1-9b23-0800200c9a66"));
        assertThat(convertedProps.get("test").getValueCase(), is(ValueCase.MULTI)); 
        assertThat(convertedProps.get("test").getMulti().getStringValue(), is("hello"));
        assertThat(convertedProps.get(EventConstants.EVENT_TOPIC).getValueCase(), is(ValueCase.MULTI)); 
        assertThat(convertedProps.get(EventConstants.EVENT_TOPIC).getMulti().getStringValue(), is("blah"));
        assertThat(convertedProps.get("test4").getValueCase(), is(ValueCase.LINKLAYERSTATUS)); 
        assertThat(convertedProps.get("test4").getLinkLayerStatus(), is(CustomCommsTypes.LinkStatus.OK));
        assertThat(convertedProps.get("test5").getValueCase(), is(ValueCase.PROGRAMSTATUS)); 
        assertThat(convertedProps.get("test5").getProgramStatus(), is(MissionStatus.EXECUTED));
        assertThat(convertedProps.get("test6").getValueCase(), is(ValueCase.PROGRAMTESTRESULT)); 
        assertThat(convertedProps.get("test6").getProgramTestResult(), is(MissionTestResult.FAILED));
        assertThat(convertedProps.get("test7").getValueCase(), is(ValueCase.SUMMARYSTATUS)); 
        assertThat(convertedProps.get("test7").getSummaryStatus(), 
                is(SummaryStatusEnumConverter.convertJavaEnumToProto(SummaryStatusEnum.GOOD)));
    }
@ Test public final void testMapToComplexTypesMap ( ) throws Exception { Asset mockAsset = mock ( Asset . class ) ; Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( FactoryDescriptor . EVENT_PROP_OBJ , mockAsset ) ; props . put ( FactoryDescriptor . EVENT_PROP_OBJ_UUID , "9433d480-d03e-11e1-9b23-0800200c9a66" ) ; props . put ( EventConstants . EVENT_TOPIC , "blah" ) ; props . put ( "test" , "hello" ) ; props . put ( "test2" , new Object ( ) ) ; props . put ( "test3" , AssetActiveStatus . ACTIVATED ) ; props . put ( "test4" , LinkStatus . OK ) ; props . put ( "test5" , ProgramStatus . EXECUTED ) ; props . put ( "test6" , TestResult . FAILED ) ; props . put ( "test7" , SummaryStatusEnum . GOOD ) ; Bundle bundle = mock ( Bundle . class ) ; props . put ( EventConstants . EVENT , new BundleEvent ( 5 , bundle ) ) ; Map < String , ComplexTypesMapEntry > convertedProps = Maps . uniqueIndex ( m_SUT . mapToComplexTypesMap ( props , null ) , new Function < ComplexTypesMapEntry , String > ( ) { @ Override public String apply ( ComplexTypesMapEntry entry ) { return entry . getKey ( ) ; } } ) ; assertThat ( convertedProps , not ( hasKey ( FactoryDescriptor . EVENT_PROP_OBJ ) ) ) ; assertThat ( convertedProps , not ( hasKey ( "test2" ) ) ) ; assertThat ( convertedProps , not ( hasKey ( "test3" ) ) ) ; assertThat ( convertedProps , not ( hasKey ( EventConstants . EVENT ) ) ) ; assertThat ( convertedProps . get ( FactoryDescriptor . EVENT_PROP_OBJ_UUID ) . getValueCase ( ) , is ( ValueCase . MULTI ) ) ; assertThat ( convertedProps . get ( FactoryDescriptor . EVENT_PROP_OBJ_UUID ) . getMulti ( ) . getStringValue ( ) , is ( "9433d480-d03e-11e1-9b23-0800200c9a66" ) ) ; assertThat ( convertedProps . get ( "test" ) . getValueCase ( ) , is ( ValueCase . MULTI ) ) ; assertThat ( convertedProps . get ( "test" ) . getMulti ( ) . getStringValue ( ) , is ( "hello" ) ) ; assertThat ( convertedProps . get ( EventConstants . EVENT_TOPIC ) . getValueCase ( ) , is ( ValueCase . MULTI ) ) ; assertThat ( convertedProps . get ( EventConstants . EVENT_TOPIC ) . getMulti ( ) . getStringValue ( ) , is ( "blah" ) ) ; assertThat ( convertedProps . get ( "test4" ) . getValueCase ( ) , is ( ValueCase . LINKLAYERSTATUS ) ) ; assertThat ( convertedProps . get ( "test4" ) . getLinkLayerStatus ( ) , is ( CustomCommsTypes . LinkStatus . OK ) ) ; assertThat ( convertedProps . get ( "test5" ) . getValueCase ( ) , is ( ValueCase . PROGRAMSTATUS ) ) ; assertThat ( convertedProps . get ( "test5" ) . getProgramStatus ( ) , is ( MissionStatus . EXECUTED ) ) ; assertThat ( convertedProps . get ( "test6" ) . getValueCase ( ) , is ( ValueCase . PROGRAMTESTRESULT ) ) ; assertThat ( convertedProps . get ( "test6" ) . getProgramTestResult ( ) , is ( MissionTestResult . FAILED ) ) ; assertThat ( convertedProps . get ( "test7" ) . getValueCase ( ) , is ( ValueCase . SUMMARYSTATUS ) ) ; assertThat ( convertedProps . get ( "test7" ) . getSummaryStatus ( ) , is ( SummaryStatusEnumConverter . convertJavaEnumToProto ( SummaryStatusEnum . GOOD ) ) ) ; }
Test creating a protocol buffer message equivalent of property map.
Test creating a protocol buffer message equivalent of property map .
// mock //verify expected values