use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.service.path.ServicePath in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method asServicePathEid.
/**
* Tests {@link LispAddressUtil#asServicePathEid(long, long, short)} method.
*/
@Test
public void asServicePathEid() {
final Eid eid = LispAddressUtil.asServicePathEid(INSTANCE_ID_TYPE_VALUE_TEST, SERVICE_PATH_ID_TEST, SERVICE_INDEX_TEST);
assertNotNull(eid);
assertEquals(ServicePathLcaf.class, eid.getAddressType());
assertEquals(INSTANCE_ID_TYPE_TEST, eid.getVirtualNetworkId());
ServicePath servicePath = ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ServicePath) eid.getAddress()).getServicePath();
assertNotNull(servicePath);
assertEquals(SERVICE_INDEX_TEST, servicePath.getServiceIndex());
assertEquals(SERVICE_PATH_ID_TEST, servicePath.getServicePathId().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.service.path.ServicePath in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromServicePathTest_withNull.
/**
* Test {@link LispAddressUtil#addressFromServicePath(ServicePath)} method with null value.
*/
@Test
public void addressFromServicePathTest_withNull() {
final Address testedAddress = LispAddressUtil.addressFromServicePath(null);
assertNull(testedAddress);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.service.path.ServicePath in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromServicePathTest_withServicePath.
/**
* Test {@link LispAddressUtil#addressFromServicePath(ServicePath)} method with concrete servicePath.
*/
@Test
public void addressFromServicePathTest_withServicePath() {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.service.path.ServicePathBuilder servicePathBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.service.path.ServicePathBuilder();
servicePathBuilder.setServiceIndex(SERVICE_INDEX_TEST);
servicePathBuilder.setServicePathId(new ServicePathIdType(DUMMY_SERVICE_PATH_ID_TYPE));
ServicePath expectedAddress = servicePathBuilder.build();
final Address testedAddress = LispAddressUtil.addressFromServicePath(expectedAddress);
assertTrue(testedAddress instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ServicePath);
assertEquals(expectedAddress, ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ServicePath) testedAddress).getServicePath());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.service.path.ServicePath in project lispflowmapping by opendaylight.
the class ServicePathSerializer method serializeData.
@Override
protected void serializeData(ByteBuffer buffer, LispAddress lispAddress) {
ServicePath sp = (ServicePath) lispAddress.getAddress();
buffer.put(ByteUtil.partialIntToByteArray(NumberUtil.asInt(sp.getServicePath().getServicePathId().getValue().intValue()), Length.SPI));
buffer.put((byte) NumberUtil.asShort(sp.getServicePath().getServiceIndex()));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.service.path.ServicePath in project lispflowmapping by opendaylight.
the class MappingSystemTest method getMappingTest_NbFirst_withServicePathDestinationAddress_singleELPLocatorRecord_IndexOutOfBounds.
/**
* Tests {@link MappingSystem#getMapping} method with ServicePath type dst address and single ExplicitLocatorPath
* type locator record. Service index out of bounds. Returns the original mapping.
*/
@Test
public void getMappingTest_NbFirst_withServicePathDestinationAddress_singleELPLocatorRecord_IndexOutOfBounds() {
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(getDefaultLocatorRecordBuilder().setRloc(getELPTypeRloc()).build())).build();
final MappingData mappingData = getDefaultMappingData(mappingRecord);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH_INDEX_OOB)).thenReturn(mappingData);
assertEquals(mappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH_INDEX_OOB));
}
Aggregations