use of org.onosproject.yang.model.ResourceId in project onos by opennetworkinglab.
the class ResourceIdsTest method testFromInstanceIdentifier.
@Test
public void testFromInstanceIdentifier() {
ResourceId eth0 = ResourceId.builder().addBranchPointSchema("interfaces", "ietf-interfaces").addBranchPointSchema("interface", "ietf-interfaces").addKeyLeaf("name", "ietf-interfaces", "eth0").build();
assertThat(ResourceIds.fromInstanceIdentifier("/ietf-interfaces:interfaces/interface[name=\"eth0\"]"), is(eth0));
assertThat("fromInstanceIdentifier return path relative to virtual root", ResourceIds.fromInstanceIdentifier("/org.onosproject.dcs:devices"), is(ResourceIds.relativize(ResourceIds.ROOT_ID, DEVICES_ID)));
assertThat(ResourceIds.prefixDcsRoot(ResourceIds.fromInstanceIdentifier("/org.onosproject.dcs:devices")), is(DEVICES_ID));
assertThat(ResourceIds.fromInstanceIdentifier("/"), is(nullValue()));
DeviceId deviceId = DeviceId.deviceId("test:device-identifier");
assertThat(ResourceIds.prefixDcsRoot(fromInstanceIdentifier("/org.onosproject.dcs:devices/device[device-id=\"test:device-identifier\"]")), is(toResourceId(deviceId)));
}
use of org.onosproject.yang.model.ResourceId in project onos by opennetworkinglab.
the class OdtnTapiHandlersTestCommand method doExecute.
@Override
public void doExecute() {
dcs = get(DynamicConfigService.class);
modelConverter = get(ModelConverter.class);
setupTapiContext();
DataNode data = contextHandler.getDataNode();
ResourceId empty = ResourceId.builder().build();
CharSequence strNode = toCharSequence(toXmlCompositeStream(toCompositeData(toResourceData(empty, data))));
StringBuilder exp = loadXml("/test-tapi-context.xml");
if (XmlString.prettifyXml(strNode).toString().contentEquals(exp)) {
printlog("result: ok");
} else {
printlog("result: failed");
}
}
use of org.onosproject.yang.model.ResourceId in project onos by opennetworkinglab.
the class OpenConfigComponentHandlerTest method testSetResourceId.
/**
* UnitTest method for setResourceId.
*/
@Test
public void testSetResourceId() {
// call setResourceId
OpenConfigComponentHandler component = new OpenConfigComponentHandler("name", parent);
// get resourceId
ResourceId resourceId = null;
try {
Field field = OpenConfigObjectHandler.class.getDeclaredField("resourceId");
field.setAccessible(true);
resourceId = (ResourceId) field.get(component);
} catch (NoSuchFieldException e) {
Assert.fail("[NG]setResourceId:ResourceId does not exist.\n" + e);
} catch (IllegalAccessException e) {
Assert.fail("[NG]setResourceId:Access to ResourceId is illegal.\n" + e);
}
assertEquals("[NG]setResourceId:Set ResourceId is not an expected one.\n", rid, resourceId);
}
use of org.onosproject.yang.model.ResourceId in project onos by opennetworkinglab.
the class OpenConfigConfigOfAssignmentHandlerTest method testSetResourceId.
/**
* UnitTest method for setResourceId.
*/
@Test
public void testSetResourceId() {
// call setResourceId
OpenConfigConfigOfAssignmentHandler config = new OpenConfigConfigOfAssignmentHandler(parent);
// get resourceId
ResourceId resourceId = null;
try {
Field field = OpenConfigObjectHandler.class.getDeclaredField("resourceId");
field.setAccessible(true);
resourceId = (ResourceId) field.get(config);
} catch (NoSuchFieldException e) {
Assert.fail("[NG]setResourceId:ResourceId does not exist.\n" + e);
} catch (IllegalAccessException e) {
Assert.fail("[NG]setResourceId:Access to ResourceId is illegal.\n" + e);
}
assertEquals("[NG]setResourceId:Set ResourceId is not an expected one.\n", rid, resourceId);
}
use of org.onosproject.yang.model.ResourceId in project onos by opennetworkinglab.
the class OpenConfigConfigOfChannelHandlerTest method testSetResourceId.
/**
* UnitTest method for setResourceId.
*/
@Test
public void testSetResourceId() {
// call setResourceId
OpenConfigConfigOfChannelHandler config = new OpenConfigConfigOfChannelHandler(parent);
// get resourceId
ResourceId resourceId = null;
try {
Field field = OpenConfigObjectHandler.class.getDeclaredField("resourceId");
field.setAccessible(true);
resourceId = (ResourceId) field.get(config);
} catch (NoSuchFieldException e) {
Assert.fail("[NG]setResourceId:ResourceId does not exist.\n" + e);
} catch (IllegalAccessException e) {
Assert.fail("[NG]setResourceId:Access to ResourceId is illegal.\n" + e);
}
assertEquals("[NG]setResourceId:Set ResourceId is not an expected one.\n", rid, resourceId);
}
Aggregations