Search in sources :

Example 6 with ResourceId

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)));
}
Also used : DeviceResourceIds.toResourceId(org.onosproject.d.config.DeviceResourceIds.toResourceId) ResourceId(org.onosproject.yang.model.ResourceId) DeviceId(org.onosproject.net.DeviceId) Test(org.junit.Test)

Example 7 with ResourceId

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");
    }
}
Also used : DynamicConfigService(org.onosproject.config.DynamicConfigService) ResourceId(org.onosproject.yang.model.ResourceId) DataNode(org.onosproject.yang.model.DataNode) ModelConverter(org.onosproject.yang.model.ModelConverter)

Example 8 with ResourceId

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);
}
Also used : Field(java.lang.reflect.Field) ResourceId(org.onosproject.yang.model.ResourceId) Test(org.junit.Test)

Example 9 with 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);
}
Also used : Field(java.lang.reflect.Field) ResourceId(org.onosproject.yang.model.ResourceId) Test(org.junit.Test)

Example 10 with 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);
}
Also used : Field(java.lang.reflect.Field) ResourceId(org.onosproject.yang.model.ResourceId) Test(org.junit.Test)

Aggregations

ResourceId (org.onosproject.yang.model.ResourceId)30 Test (org.junit.Test)21 Field (java.lang.reflect.Field)12 DeviceResourceIds.toResourceId (org.onosproject.d.config.DeviceResourceIds.toResourceId)6 DataNode (org.onosproject.yang.model.DataNode)6 FailedException (org.onosproject.config.FailedException)4 RestconfUtils.convertJsonToDataNode (org.onosproject.restconf.utils.RestconfUtils.convertJsonToDataNode)4 DefaultResourceData (org.onosproject.yang.model.DefaultResourceData)4 ResourceData (org.onosproject.yang.model.ResourceData)4 RestconfException (org.onosproject.restconf.api.RestconfException)3 KeyLeaf (org.onosproject.yang.model.KeyLeaf)3 ListKey (org.onosproject.yang.model.ListKey)3 SchemaId (org.onosproject.yang.model.SchemaId)3 DeviceId (org.onosproject.net.DeviceId)2 URI (java.net.URI)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 DynamicConfigEvent (org.onosproject.config.DynamicConfigEvent)1 DynamicConfigListener (org.onosproject.config.DynamicConfigListener)1 DynamicConfigService (org.onosproject.config.DynamicConfigService)1 YangToolUtil.toCharSequence (org.onosproject.odtn.utils.YangToolUtil.toCharSequence)1