use of org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name in project onos by opennetworkinglab.
the class TapiLocalClassUtil method addNameList.
/**
* Add key-value to the ModelObject as "name-and-value" list.
*
* @param obj ModelObject
* @param kvs Key-value map
* @param <T> Type of ModelObject
*/
public static <T extends ModelObject> void addNameList(T obj, Map<String, String> kvs) {
@SuppressWarnings("unchecked") Class<T> cls = (Class<T>) obj.getClass();
try {
Method method = cls.getMethod("addToName", Name.class);
for (Entry<String, String> kv : kvs.entrySet()) {
DefaultName prop = new DefaultName();
prop.valueName(kv.getKey());
prop.value(kv.getValue());
method.invoke(obj, prop);
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
log.error("Exception thrown", e);
}
}
use of org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name in project onos by opennetworkinglab.
the class OpenConfigComponentHandlerTest method testAddTransceiver.
/**
* UnitTest method for addTransceiver.
*/
@Test
public void testAddTransceiver() {
// test Handler
OpenConfigComponentHandler component = new OpenConfigComponentHandler("name", parent);
// call addTransceiver
OpenConfigTransceiverHandler transceiver = new OpenConfigTransceiverHandler(component);
// expected ModelObject
DefaultComponent modelObject = new DefaultComponent();
modelObject.name("name");
DefaultTransceiver trans = new DefaultTransceiver();
DefaultAugmentedOcPlatformComponent augmentedOcPlatformComponent = new DefaultAugmentedOcPlatformComponent();
augmentedOcPlatformComponent.transceiver(trans);
modelObject.addAugmentation(augmentedOcPlatformComponent);
assertEquals("[NG]addTransceiver:ModelObject(Transceiver added) is not an expected one.\n", modelObject, component.getModelObject());
}
use of org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name in project onos by opennetworkinglab.
the class OpenConfigComponentsHandlerTest method testAddComponent.
/**
* UnitTest method for addComponent.
*/
@Test
public void testAddComponent() {
// test Handler
OpenConfigComponentsHandler components = new OpenConfigComponentsHandler();
// call addComponent
OpenConfigComponentHandler component = new OpenConfigComponentHandler("name", components);
// expected ModelObject
DefaultComponents modelObject = new DefaultComponents();
DefaultComponent comp = new DefaultComponent();
comp.name("name");
modelObject.addToComponent(comp);
assertEquals("[NG]addComponent:ModelObject(Component added) is not an expected one.\n", modelObject, components.getModelObject());
}
use of org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name in project onos by opennetworkinglab.
the class OpenConfigConfigOfComponentHandlerTest method testAddName.
/**
* UnitTest method for addName.
*/
@Test
public void testAddName() {
// test Handler
OpenConfigConfigOfComponentHandler config = new OpenConfigConfigOfComponentHandler(parent);
// call addName
config.addName("name");
// expected ModelObject
DefaultConfig modelObject = new DefaultConfig();
modelObject.name("name");
assertEquals("[NG]addName:ModelObject(Name added) is not an expected one.\n", modelObject, config.getModelObject());
}
Aggregations