mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestMetaTypeNamespace.java
@Test
    public void testGetMetaTypeInformation() throws UnknownHostException, IOException
    {
        //get connection to controller
        MessageListener listener = new MessageListener(m_Socket);
        
        //construct request message
        GetMetaTypeInfoRequestData request = GetMetaTypeInfoRequestData.newBuilder().build();
        TerraHarvestMessage message = createMetaTypeMessage(MetaTypeMessageType.GetMetaTypeInfoRequest, request);
        
        //send message
        message.writeDelimitedTo(m_Socket.getOutputStream());
        
        Message messageRcvd = listener.waitForMessage(Namespace.MetaType, 
                MetaTypeMessageType.GetMetaTypeInfoResponse, 1200);
        
        MetaTypeNamespace namespace = (MetaTypeNamespace)messageRcvd;
        GetMetaTypeInfoResponseData response = GetMetaTypeInfoResponseData.parseFrom(namespace.getData());
        List<MetaTypeInfoType> metaList = response.getMetaTypeList();
        List<String> pidList = new ArrayList<String>();
        for (MetaTypeInfoType meta: metaList)
        {
            pidList.add(meta.getPid());
        }
        assertThat(pidList, hasItem(ExampleClass.class.getName()));
        
        MetaTypeInfoType exampleConfigFactory = 
                metaList.get(pidList.indexOf(ExampleClass.class.getName()));
        assertThat(exampleConfigFactory.getPid(), is(ExampleClass.class.getName()));
        
        List<AttributeDefinitionType> attrList = exampleConfigFactory.getAttributesList();
        List<String> keyList = new ArrayList<String>();
        for (AttributeDefinitionType attr: attrList)
        {
            keyList.add(attr.getId());
        }
        
        assertThat(keyList, hasItems(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE, 
                ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING, 
                ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN,
                ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_REQUIRED_STRING_VALUE));
        
        AttributeDefinitionType attribute = attrList.get(keyList.indexOf(
                ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE));
        assertThat(attribute.getName(), is("Example Config Value"));
        assertThat(attribute.getDefaultValue(0), is("1"));
        assertThat(attribute.getOptionLabelList(), is(Arrays.asList("Label1", "Label2", "Label3", "Label4")));
        assertThat(attribute.getOptionValueList(), is(Arrays.asList("1", "2", "3", "4")));
        assertThat(attribute.getRequired(), is(false));
        
        attribute = attrList.get(keyList.indexOf(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING));
        assertThat(attribute.getName(), is("Example Config String Value"));
        assertThat(attribute.getDefaultValue(0), is("hello"));
        assertThat(attribute.getRequired(), is(false));
        
        attribute = attrList.get(keyList.indexOf(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN));
        assertThat(attribute.getName(), is("Another Config String Value"));
        assertThat(attribute.getDefaultValue(0), is("goodbye"));
        assertThat(attribute.getRequired(), is(false));
        
        attribute = attrList.get(keyList.indexOf(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_REQUIRED_STRING_VALUE));
        assertThat(attribute.getName(), is("Required Config String Value"));
        assertThat(attribute.getDefaultValueCount(), is(0));
        assertThat(attribute.getRequired(), is(true));
    }
/**
     * Test that GetMetaTypeInfoRequest returns a list of meta type information.
     */
Test that GetMetaTypeInfoRequest returns a list of meta type information.
Test that GetMetaTypeInfoRequest returns a list of meta type information .
@Test
    public void testGetMetaTypeInformation() throws UnknownHostException, IOException
    {
        MessageListener listener = new MessageListener(m_Socket);
        GetMetaTypeInfoRequestData request = GetMetaTypeInfoRequestData.newBuilder().build();
        TerraHarvestMessage message = createMetaTypeMessage(MetaTypeMessageType.GetMetaTypeInfoRequest, request);
        message.writeDelimitedTo(m_Socket.getOutputStream());
        Message messageRcvd = listener.waitForMessage(Namespace.MetaType, 
                MetaTypeMessageType.GetMetaTypeInfoResponse, 1200);
        MetaTypeNamespace namespace = (MetaTypeNamespace)messageRcvd;
        GetMetaTypeInfoResponseData response = GetMetaTypeInfoResponseData.parseFrom(namespace.getData());
        List<MetaTypeInfoType> metaList = response.getMetaTypeList();
        List<String> pidList = new ArrayList<String>();
        for (MetaTypeInfoType meta: metaList)
        {
            pidList.add(meta.getPid());
        }
        assertThat(pidList, hasItem(ExampleClass.class.getName()));
        MetaTypeInfoType exampleConfigFactory = 
                metaList.get(pidList.indexOf(ExampleClass.class.getName()));
        assertThat(exampleConfigFactory.getPid(), is(ExampleClass.class.getName()));
        List<AttributeDefinitionType> attrList = exampleConfigFactory.getAttributesList();
        List<String> keyList = new ArrayList<String>();
        for (AttributeDefinitionType attr: attrList)
        {
            keyList.add(attr.getId());
        }
        assertThat(keyList, hasItems(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE, 
                ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING, 
                ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN,
                ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_REQUIRED_STRING_VALUE));
        AttributeDefinitionType attribute = attrList.get(keyList.indexOf(
                ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE));
        assertThat(attribute.getName(), is("Example Config Value"));
        assertThat(attribute.getDefaultValue(0), is("1"));
        assertThat(attribute.getOptionLabelList(), is(Arrays.asList("Label1", "Label2", "Label3", "Label4")));
        assertThat(attribute.getOptionValueList(), is(Arrays.asList("1", "2", "3", "4")));
        assertThat(attribute.getRequired(), is(false));
        attribute = attrList.get(keyList.indexOf(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING));
        assertThat(attribute.getName(), is("Example Config String Value"));
        assertThat(attribute.getDefaultValue(0), is("hello"));
        assertThat(attribute.getRequired(), is(false));
        attribute = attrList.get(keyList.indexOf(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN));
        assertThat(attribute.getName(), is("Another Config String Value"));
        assertThat(attribute.getDefaultValue(0), is("goodbye"));
        assertThat(attribute.getRequired(), is(false));
        attribute = attrList.get(keyList.indexOf(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_REQUIRED_STRING_VALUE));
        assertThat(attribute.getName(), is("Required Config String Value"));
        assertThat(attribute.getDefaultValueCount(), is(0));
        assertThat(attribute.getRequired(), is(true));
    }
@ Test public void testGetMetaTypeInformation ( ) throws UnknownHostException , IOException { MessageListener listener = new MessageListener ( m_Socket ) ; GetMetaTypeInfoRequestData request = GetMetaTypeInfoRequestData . newBuilder ( ) . build ( ) ; TerraHarvestMessage message = createMetaTypeMessage ( MetaTypeMessageType . GetMetaTypeInfoRequest , request ) ; message . writeDelimitedTo ( m_Socket . getOutputStream ( ) ) ; Message messageRcvd = listener . waitForMessage ( Namespace . MetaType , MetaTypeMessageType . GetMetaTypeInfoResponse , 1200 ) ; MetaTypeNamespace namespace = ( MetaTypeNamespace ) messageRcvd ; GetMetaTypeInfoResponseData response = GetMetaTypeInfoResponseData . parseFrom ( namespace . getData ( ) ) ; List < MetaTypeInfoType > metaList = response . getMetaTypeList ( ) ; List < String > pidList = new ArrayList < String > ( ) ; for ( MetaTypeInfoType meta : metaList ) { pidList . add ( meta . getPid ( ) ) ; } assertThat ( pidList , hasItem ( ExampleClass . class . getName ( ) ) ) ; MetaTypeInfoType exampleConfigFactory = metaList . get ( pidList . indexOf ( ExampleClass . class . getName ( ) ) ) ; assertThat ( exampleConfigFactory . getPid ( ) , is ( ExampleClass . class . getName ( ) ) ) ; List < AttributeDefinitionType > attrList = exampleConfigFactory . getAttributesList ( ) ; List < String > keyList = new ArrayList < String > ( ) ; for ( AttributeDefinitionType attr : attrList ) { keyList . add ( attr . getId ( ) ) ; } assertThat ( keyList , hasItems ( ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_VALUE , ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING , ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN , ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_REQUIRED_STRING_VALUE ) ) ; AttributeDefinitionType attribute = attrList . get ( keyList . indexOf ( ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_VALUE ) ) ; assertThat ( attribute . getName ( ) , is ( "Example Config Value" ) ) ; assertThat ( attribute . getDefaultValue ( 0 ) , is ( "1" ) ) ; assertThat ( attribute . getOptionLabelList ( ) , is ( Arrays . asList ( "Label1" , "Label2" , "Label3" , "Label4" ) ) ) ; assertThat ( attribute . getOptionValueList ( ) , is ( Arrays . asList ( "1" , "2" , "3" , "4" ) ) ) ; assertThat ( attribute . getRequired ( ) , is ( false ) ) ; attribute = attrList . get ( keyList . indexOf ( ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING ) ) ; assertThat ( attribute . getName ( ) , is ( "Example Config String Value" ) ) ; assertThat ( attribute . getDefaultValue ( 0 ) , is ( "hello" ) ) ; assertThat ( attribute . getRequired ( ) , is ( false ) ) ; attribute = attrList . get ( keyList . indexOf ( ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN ) ) ; assertThat ( attribute . getName ( ) , is ( "Another Config String Value" ) ) ; assertThat ( attribute . getDefaultValue ( 0 ) , is ( "goodbye" ) ) ; assertThat ( attribute . getRequired ( ) , is ( false ) ) ; attribute = attrList . get ( keyList . indexOf ( ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_REQUIRED_STRING_VALUE ) ) ; assertThat ( attribute . getName ( ) , is ( "Required Config String Value" ) ) ; assertThat ( attribute . getDefaultValueCount ( ) , is ( 0 ) ) ; assertThat ( attribute . getRequired ( ) , is ( true ) ) ; }
Test that GetMetaTypeInfoRequest returns a list of meta type information.
Test that GetMetaTypeInfoRequest returns a list of meta type information .
//get connection to controller //construct request message //send message