Search in sources :

Example 6 with Name

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);
    }
}
Also used : DefaultName(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.DefaultName) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 7 with Name

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());
}
Also used : DefaultComponent(org.onosproject.yang.gen.v1.openconfigplatform.rev20180603.openconfigplatform.platformcomponenttop.components.DefaultComponent) DefaultTransceiver(org.onosproject.yang.gen.v1.openconfigplatformtransceiver.rev20180515.openconfigplatformtransceiver.porttransceivertop.DefaultTransceiver) DefaultAugmentedOcPlatformComponent(org.onosproject.yang.gen.v1.openconfigplatformtransceiver.rev20180515.openconfigplatformtransceiver.components.component.DefaultAugmentedOcPlatformComponent) Test(org.junit.Test)

Example 8 with Name

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());
}
Also used : DefaultComponent(org.onosproject.yang.gen.v1.openconfigplatform.rev20180603.openconfigplatform.platformcomponenttop.components.DefaultComponent) DefaultComponents(org.onosproject.yang.gen.v1.openconfigplatform.rev20180603.openconfigplatform.platformcomponenttop.DefaultComponents) Test(org.junit.Test)

Example 9 with Name

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());
}
Also used : DefaultConfig(org.onosproject.yang.gen.v1.openconfigplatform.rev20180603.openconfigplatform.platformcomponenttop.components.component.DefaultConfig) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 DefaultComponent (org.onosproject.yang.gen.v1.openconfigplatform.rev20180603.openconfigplatform.platformcomponenttop.components.DefaultComponent)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 DefaultConfig (org.onosproject.yang.gen.v1.openconfigplatform.rev20180603.openconfigplatform.platformcomponenttop.components.component.DefaultConfig)2 DefaultName (org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.DefaultName)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 DefaultServiceDirectory.getService (org.onlab.osgi.DefaultServiceDirectory.getService)1 DynamicConfigService (org.onosproject.config.DynamicConfigService)1 Filter (org.onosproject.config.Filter)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 DeviceId (org.onosproject.net.DeviceId)1 CONNECTION_ID (org.onosproject.odtn.behaviour.OdtnDeviceDescriptionDiscovery.CONNECTION_ID)1 DcsBasedTapiObjectRefFactory (org.onosproject.odtn.utils.tapi.DcsBasedTapiObjectRefFactory)1 TapiNepRef (org.onosproject.odtn.utils.tapi.TapiNepRef)1