mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/advanced/configuration/TestSystemMetatypeMgrImpl.java
@Test
    public void testAttributeRemoved() throws SecurityException, IllegalArgumentException, NoSuchFieldException, 
        IllegalAccessException
    {
        setupMetaTypeInfo();
        
        //Verify model before update.
        MetaTypeModel model = m_SUT.getConfigInformationAsync(CONTROLLERID, "already.existent.service");
        assertThat(model.getBundleId(), is(BUNDLEID));
        assertThat(model.getPid(), is("already.existent.service"));
        List<AttributeModel> attributes = model.getAttributes();
        assertThat(attributes.size(), is(3));
        assertThat(attributes.get(0).getId(), is("intField"));
        assertThat(attributes.get(1).getId(), is("stringField"));
        assertThat(attributes.get(2).getId(), is("boolField"));
        
        String ocdName = "name";
        String ocdId = "ID";
        String description = "desc";
        
        ObjectClassDefinitionType ocdMes1 = ObjectClassDefinitionType.newBuilder()
                .setName(ocdName)
                .setId(ocdId)
                .setDescription(description).build();
        
        AttributeDefinitionType attrInt = AttributeDefinitionType.newBuilder().setAttributeType(
                AttributeDefinition.INTEGER).setCardinality(0).setDescription("some description int").setId("intField").
                setName("Int Field").build();
        AttributeDefinitionType attrString = AttributeDefinitionType.newBuilder().setAttributeType(
                AttributeDefinition.STRING).setCardinality(0).setDescription("some description string").
                setId("stringField").setName("String Field").build();
        List<AttributeDefinitionType> attributeList = new ArrayList<MetaTypeMessages.AttributeDefinitionType>();
        attributeList.add(attrInt);
        attributeList.add(attrString);
        
        MetaTypeInfoType metaUpdated = MetaTypeInfoType.newBuilder().setBundleId(BUNDLEID).
                setPid("already.existent.service").setIsFactory(false).
                setOcd(ocdMes1).addAllAttributes(attributeList).build();
        List<MetaTypeInfoType> metaInfoList = new ArrayList<MetaTypeInfoType>();
        metaInfoList.add(metaUpdated);
        
        GetMetaTypeInfoResponseData responseMessage = 
                GetMetaTypeInfoResponseData.newBuilder().addAllMetaType(metaInfoList).build();
        MetaTypeNamespace namespace = MetaTypeNamespace.newBuilder().setType(
                MetaTypeMessageType.GetMetaTypeInfoResponse).setData(responseMessage.toByteString()).build();
        TerraHarvestMessage thMessage = TerraHarvestMessageHelper.createTerraHarvestMessage(CONTROLLERID, 0, 
                Namespace.MetaType, 5000, namespace);
        
        //Mock event
        Map<String, Object> props = new HashMap<>();
        props.put(RemoteConstants.EVENT_PROP_MESSAGE, thMessage);
        props.put(RemoteConstants.EVENT_PROP_DATA_MESSAGE, responseMessage);
        Event event = new Event(RemoteConstants.TOPIC_MESSAGE_RECEIVED, props);
        
        m_MetaTypeEventHandler.handleEvent(event);
        
        //Verify model after update.
        model = m_SUT.getConfigInformationAsync(CONTROLLERID, "already.existent.service");
        assertThat(model.getBundleId(), is(BUNDLEID));
        assertThat(model.getPid(), is("already.existent.service"));
        attributes = model.getAttributes();
        assertThat(attributes.size(), is(2));
        assertThat(attributes.get(0).getId(), is("intField"));
        assertThat(attributes.get(1).getId(), is("stringField"));
    }
/**
     * Verify if a bundle is updated and an attribute has been removed then the local model reflects that change.
     */
Verify if a bundle is updated and an attribute has been removed then the local model reflects that change.
Verify if a bundle is updated and an attribute has been removed then the local model reflects that change .
@Test
    public void testAttributeRemoved() throws SecurityException, IllegalArgumentException, NoSuchFieldException, 
        IllegalAccessException
    {
        setupMetaTypeInfo();
        MetaTypeModel model = m_SUT.getConfigInformationAsync(CONTROLLERID, "already.existent.service");
        assertThat(model.getBundleId(), is(BUNDLEID));
        assertThat(model.getPid(), is("already.existent.service"));
        List<AttributeModel> attributes = model.getAttributes();
        assertThat(attributes.size(), is(3));
        assertThat(attributes.get(0).getId(), is("intField"));
        assertThat(attributes.get(1).getId(), is("stringField"));
        assertThat(attributes.get(2).getId(), is("boolField"));
        String ocdName = "name";
        String ocdId = "ID";
        String description = "desc";
        ObjectClassDefinitionType ocdMes1 = ObjectClassDefinitionType.newBuilder()
                .setName(ocdName)
                .setId(ocdId)
                .setDescription(description).build();
        AttributeDefinitionType attrInt = AttributeDefinitionType.newBuilder().setAttributeType(
                AttributeDefinition.INTEGER).setCardinality(0).setDescription("some description int").setId("intField").
                setName("Int Field").build();
        AttributeDefinitionType attrString = AttributeDefinitionType.newBuilder().setAttributeType(
                AttributeDefinition.STRING).setCardinality(0).setDescription("some description string").
                setId("stringField").setName("String Field").build();
        List<AttributeDefinitionType> attributeList = new ArrayList<MetaTypeMessages.AttributeDefinitionType>();
        attributeList.add(attrInt);
        attributeList.add(attrString);
        MetaTypeInfoType metaUpdated = MetaTypeInfoType.newBuilder().setBundleId(BUNDLEID).
                setPid("already.existent.service").setIsFactory(false).
                setOcd(ocdMes1).addAllAttributes(attributeList).build();
        List<MetaTypeInfoType> metaInfoList = new ArrayList<MetaTypeInfoType>();
        metaInfoList.add(metaUpdated);
        GetMetaTypeInfoResponseData responseMessage = 
                GetMetaTypeInfoResponseData.newBuilder().addAllMetaType(metaInfoList).build();
        MetaTypeNamespace namespace = MetaTypeNamespace.newBuilder().setType(
                MetaTypeMessageType.GetMetaTypeInfoResponse).setData(responseMessage.toByteString()).build();
        TerraHarvestMessage thMessage = TerraHarvestMessageHelper.createTerraHarvestMessage(CONTROLLERID, 0, 
                Namespace.MetaType, 5000, namespace);
        Map<String, Object> props = new HashMap<>();
        props.put(RemoteConstants.EVENT_PROP_MESSAGE, thMessage);
        props.put(RemoteConstants.EVENT_PROP_DATA_MESSAGE, responseMessage);
        Event event = new Event(RemoteConstants.TOPIC_MESSAGE_RECEIVED, props);
        m_MetaTypeEventHandler.handleEvent(event);
        model = m_SUT.getConfigInformationAsync(CONTROLLERID, "already.existent.service");
        assertThat(model.getBundleId(), is(BUNDLEID));
        assertThat(model.getPid(), is("already.existent.service"));
        attributes = model.getAttributes();
        assertThat(attributes.size(), is(2));
        assertThat(attributes.get(0).getId(), is("intField"));
        assertThat(attributes.get(1).getId(), is("stringField"));
    }
@ Test public void testAttributeRemoved ( ) throws SecurityException , IllegalArgumentException , NoSuchFieldException , IllegalAccessException { setupMetaTypeInfo ( ) ; MetaTypeModel model = m_SUT . getConfigInformationAsync ( CONTROLLERID , "already.existent.service" ) ; assertThat ( model . getBundleId ( ) , is ( BUNDLEID ) ) ; assertThat ( model . getPid ( ) , is ( "already.existent.service" ) ) ; List < AttributeModel > attributes = model . getAttributes ( ) ; assertThat ( attributes . size ( ) , is ( 3 ) ) ; assertThat ( attributes . get ( 0 ) . getId ( ) , is ( "intField" ) ) ; assertThat ( attributes . get ( 1 ) . getId ( ) , is ( "stringField" ) ) ; assertThat ( attributes . get ( 2 ) . getId ( ) , is ( "boolField" ) ) ; String ocdName = "name" ; String ocdId = "ID" ; String description = "desc" ; ObjectClassDefinitionType ocdMes1 = ObjectClassDefinitionType . newBuilder ( ) . setName ( ocdName ) . setId ( ocdId ) . setDescription ( description ) . build ( ) ; AttributeDefinitionType attrInt = AttributeDefinitionType . newBuilder ( ) . setAttributeType ( AttributeDefinition . INTEGER ) . setCardinality ( 0 ) . setDescription ( "some description int" ) . setId ( "intField" ) . setName ( "Int Field" ) . build ( ) ; AttributeDefinitionType attrString = AttributeDefinitionType . newBuilder ( ) . setAttributeType ( AttributeDefinition . STRING ) . setCardinality ( 0 ) . setDescription ( "some description string" ) . setId ( "stringField" ) . setName ( "String Field" ) . build ( ) ; List < AttributeDefinitionType > attributeList = new ArrayList < MetaTypeMessages . AttributeDefinitionType > ( ) ; attributeList . add ( attrInt ) ; attributeList . add ( attrString ) ; MetaTypeInfoType metaUpdated = MetaTypeInfoType . newBuilder ( ) . setBundleId ( BUNDLEID ) . setPid ( "already.existent.service" ) . setIsFactory ( false ) . setOcd ( ocdMes1 ) . addAllAttributes ( attributeList ) . build ( ) ; List < MetaTypeInfoType > metaInfoList = new ArrayList < MetaTypeInfoType > ( ) ; metaInfoList . add ( metaUpdated ) ; GetMetaTypeInfoResponseData responseMessage = GetMetaTypeInfoResponseData . newBuilder ( ) . addAllMetaType ( metaInfoList ) . build ( ) ; MetaTypeNamespace namespace = MetaTypeNamespace . newBuilder ( ) . setType ( MetaTypeMessageType . GetMetaTypeInfoResponse ) . setData ( responseMessage . toByteString ( ) ) . build ( ) ; TerraHarvestMessage thMessage = TerraHarvestMessageHelper . createTerraHarvestMessage ( CONTROLLERID , 0 , Namespace . MetaType , 5000 , namespace ) ; Map < String , Object > props = new HashMap < > ( ) ; props . put ( RemoteConstants . EVENT_PROP_MESSAGE , thMessage ) ; props . put ( RemoteConstants . EVENT_PROP_DATA_MESSAGE , responseMessage ) ; Event event = new Event ( RemoteConstants . TOPIC_MESSAGE_RECEIVED , props ) ; m_MetaTypeEventHandler . handleEvent ( event ) ; model = m_SUT . getConfigInformationAsync ( CONTROLLERID , "already.existent.service" ) ; assertThat ( model . getBundleId ( ) , is ( BUNDLEID ) ) ; assertThat ( model . getPid ( ) , is ( "already.existent.service" ) ) ; attributes = model . getAttributes ( ) ; assertThat ( attributes . size ( ) , is ( 2 ) ) ; assertThat ( attributes . get ( 0 ) . getId ( ) , is ( "intField" ) ) ; assertThat ( attributes . get ( 1 ) . getId ( ) , is ( "stringField" ) ) ; }
Verify if a bundle is updated and an attribute has been removed then the local model reflects that change.
Verify if a bundle is updated and an attribute has been removed then the local model reflects that change .
//Verify model before update. //Mock event //Verify model after update.