use of org.onosproject.yang.model.ResourceId in project onos by opennetworkinglab.
the class OpenConfigConfigOfComponentHandlerTest method testSetResourceId.
/**
* UnitTest method for setResourceId.
*/
@Test
public void testSetResourceId() {
// call setResourceId
OpenConfigConfigOfComponentHandler config = new OpenConfigConfigOfComponentHandler(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 OpenConfigLogicalChannelAssignmentsHandlerTest method testSetResourceId.
/**
* UnitTest method for setResourceId.
*/
@Test
public void testSetResourceId() {
// call setResourceId
OpenConfigLogicalChannelAssignmentsHandler logicalChannelAssignments = new OpenConfigLogicalChannelAssignmentsHandler(parent);
// get resourceId
ResourceId resourceId = null;
try {
Field field = OpenConfigObjectHandler.class.getDeclaredField("resourceId");
field.setAccessible(true);
resourceId = (ResourceId) field.get(logicalChannelAssignments);
} 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 RestconfManager method runPostOperationOnDataResource.
@Override
public void runPostOperationOnDataResource(URI uri, ObjectNode rootNode) throws RestconfException {
DataResourceLocator rl = DataResourceLocator.newInstance(uri);
ResourceData receivedData = convertJsonToDataNode(rl.uriForYangRuntime(), rootNode);
ResourceId rid = receivedData.resourceId();
List<DataNode> dataNodeList = receivedData.dataNodes();
if (dataNodeList == null || dataNodeList.isEmpty()) {
log.warn("There is no one Data Node can be proceed.");
return;
}
if (dataNodeList.size() > 1) {
log.warn("There are more than one Data Node can be proceed: {}", dataNodeList.size());
}
DataNode dataNode = dataNodeList.get(0);
if (rid == null) {
rid = ResourceId.builder().addBranchPointSchema("/", null).build();
dataNode = removeTopNode(dataNode);
}
try {
dynamicConfigService.createNode(rl.ridForDynConfig(), dataNode);
} catch (Exception e) {
if (e.getMessage().startsWith("Requested node already present")) {
throw new RestconfException("Already exists", e, RestconfError.ErrorTag.DATA_EXISTS, CONFLICT, Optional.of(uri.getPath()));
} else {
log.error("ERROR: DynamicConfigService: creating {} with {}", ResourceIds.toInstanceIdentifier(rl.ridForDynConfig()), dataNode, e);
throw new RestconfException("ERROR: DynamicConfigService", e, RestconfError.ErrorTag.OPERATION_FAILED, INTERNAL_SERVER_ERROR, Optional.of(uri.getPath()));
}
}
}
use of org.onosproject.yang.model.ResourceId in project onos by opennetworkinglab.
the class OdtnDcsModelCheckCommand method dumpDcsStore.
private <T extends InnerModelObject> void dumpDcsStore(Class<T> cls) {
ModelObjectId mid = ModelObjectId.builder().addChild(cls).build();
DataNode all = dcs.readNode(getResourceId(mid), Filter.builder().build());
ResourceId empty = ResourceId.builder().build();
CharSequence strNode = toCharSequence(toXmlCompositeStream(toCompositeData(toResourceData(empty, all))));
printlog("XML:\n{}", XmlString.prettifyXml(strNode));
}
use of org.onosproject.yang.model.ResourceId in project onos by opennetworkinglab.
the class OpenConfigAssignmentHandlerTest method testSetResourceId.
/**
* UnitTest method for setResourceId.
*/
@Test
public void testSetResourceId() {
// call setResourceId
OpenConfigAssignmentHandler assignment = new OpenConfigAssignmentHandler(2, parent);
// get resourceId
ResourceId resourceId = null;
try {
Field field = OpenConfigObjectHandler.class.getDeclaredField("resourceId");
field.setAccessible(true);
resourceId = (ResourceId) field.get(assignment);
} 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