use of org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name in project onos by opennetworkinglab.
the class DcsBasedTapiDataProducer method getNodes.
/**
* Extract Tapi Nodes from context modelObject and convert them to NodeRefs.
*
* @param context
* @return List of NodeRef
*/
private List<TapiNodeRef> getNodes(DefaultContext context) {
DefaultAugmentedTapiCommonContext topologyContext = context.augmentation(DefaultAugmentedTapiCommonContext.class);
Topology topology = topologyContext.topologyContext().topology().get(0);
if (topology.node() == null) {
return Collections.emptyList();
}
return topology.node().stream().map(node -> {
TapiNodeRef nodeRef = DcsBasedTapiObjectRefFactory.create(topology, node);
if (node.name() != null) {
String deviceId = node.name().stream().filter(kv -> kv.valueName().equals(DEVICE_ID)).findFirst().map(Name::value).get();
nodeRef.setDeviceId(DeviceId.deviceId(deviceId));
}
return nodeRef;
}).collect(Collectors.toList());
}
use of org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name in project onos by opennetworkinglab.
the class OpenConfigComponentHandlerTest method testGetModelObject.
/**
* UnitTest method for getModelObject.
*/
@Test
public void testGetModelObject() {
// test Handler
OpenConfigComponentHandler component = new OpenConfigComponentHandler("name", parent);
// expected ModelObject
DefaultComponent modelObject = new DefaultComponent();
modelObject.name("name");
assertEquals("[NG]getModelObject:Return is not an expected ModelObject.\n", modelObject, component.getModelObject());
}
use of org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name in project onos by opennetworkinglab.
the class OpenConfigComponentHandlerTest method testAddConfig.
/**
* UnitTest method for addConfig.
*/
@Test
public void testAddConfig() {
// test Handler
OpenConfigComponentHandler component = new OpenConfigComponentHandler("name", parent);
// call addConfig
OpenConfigConfigOfComponentHandler config = new OpenConfigConfigOfComponentHandler(component);
// expected ModelObject
DefaultComponent modelObject = new DefaultComponent();
modelObject.name("name");
DefaultConfig con = new DefaultConfig();
modelObject.config(con);
assertEquals("[NG]addConfig:ModelObject(Config 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 OpenConfigConfigOfAssignmentHandlerTest method testAddLogicalChannel.
/**
* UnitTest method for addLogicalChannel.
*/
@Test
public void testAddLogicalChannel() {
// test Handler
OpenConfigConfigOfAssignmentHandler config = new OpenConfigConfigOfAssignmentHandler(parent);
// call addLogicalChannel
config.addLogicalChannel("name");
// expected ModelObject
DefaultConfig modelObject = new DefaultConfig();
modelObject.logicalChannel("name");
assertEquals("[NG]addLogicalChannel:ModelObject(LogicalChannel added) is not an expected one.\n", modelObject, config.getModelObject());
}
use of org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name in project onos by opennetworkinglab.
the class TapiGlobalClassUtil 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);
}
}
Aggregations