use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder in project lispflowmapping by opendaylight.
the class MapResolverTest method handleMapRequest__withSingleLocator.
/**
* Tests {@link MapResolver#handleMapRequest} method.
*/
@Test
public void handleMapRequest__withSingleLocator() {
// input mapping
final LocatorRecordBuilder locatorRecordBuilder = getDefaultLocatorBuilder();
final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder.build());
final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
// result
final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mappingRecordBuilder.build()).build());
mapResolver.handleMapRequest(mapRequestBuilder.build());
Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder in project lispflowmapping by opendaylight.
the class MappingMergeUtilTest method getCommonLocatorRecords_priorityCheck.
/**
* Tests {@link MappingMergeUtil#getCommonLocatorRecords} method, verifies that NB common locator's priority is set
* to correct value (based on SB locator's priority).
*/
@Test
public void getCommonLocatorRecords_priorityCheck() {
LocatorRecordBuilder nbLocatorRecordBuilder1 = new LocatorRecordBuilder().setRloc(IPV4_RLOC_1).setPriority((short) 1).setLocatorId("NB-locator-id");
LocatorRecordBuilder sbLocatorRecordBuilder1 = new LocatorRecordBuilder().setRloc(IPV4_RLOC_1).setPriority((short) 255).setLocatorId("SB-locator-id");
LocatorRecordBuilder nbLocatorRecordBuilder2 = new LocatorRecordBuilder().setRloc(IPV4_RLOC_2).setPriority((short) 1).setLocatorId("NB-locator-id");
LocatorRecordBuilder sbLocatorRecordBuilder2 = new LocatorRecordBuilder().setRloc(IPV4_RLOC_2).setPriority((short) 254).setLocatorId("SB-locator-id");
final MappingRecordBuilder nbMappingRecordBuilder = getDefaultMappingRecordBuilder();
nbMappingRecordBuilder.getLocatorRecord().add(nbLocatorRecordBuilder1.build());
nbMappingRecordBuilder.getLocatorRecord().add(nbLocatorRecordBuilder2.build());
final MappingRecordBuilder sbMappingRecordBuilder = getDefaultMappingRecordBuilder();
sbMappingRecordBuilder.getLocatorRecord().add(sbLocatorRecordBuilder1.build());
sbMappingRecordBuilder.getLocatorRecord().add(sbLocatorRecordBuilder2.build());
MappingData nbMappingData = getDefaultMappingData(nbMappingRecordBuilder.build());
MappingData sbMappingData = getDefaultMappingData(sbMappingRecordBuilder.build());
// result
final MappingData result = MappingMergeUtil.computeNbSbIntersection(nbMappingData, sbMappingData);
final Iterator<LocatorRecord> iterator = result.getRecord().getLocatorRecord().iterator();
final LocatorRecord resultLocator_1 = iterator.next();
final LocatorRecord resultLocator_2 = iterator.next();
assertEquals(2, result.getRecord().getLocatorRecord().size());
assertEquals("NB-locator-id", resultLocator_1.getLocatorId());
// priority changed to 255
assertEquals(255, (short) resultLocator_1.getPriority());
assertEquals("NB-locator-id", resultLocator_2.getLocatorId());
// priority remains original
assertEquals(1, (short) resultLocator_2.getPriority());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder in project lispflowmapping by opendaylight.
the class LispAddressUtil method asLocatorRecords.
public static List<LocatorRecord> asLocatorRecords(List<Rloc> locators) {
List<LocatorRecord> locatorRecords = new ArrayList<LocatorRecord>();
for (Rloc locator : locators) {
LocatorRecordBuilder locatorBuilder = new LocatorRecordBuilder();
locatorBuilder.setLocalLocator(false).setRlocProbed(false).setWeight((short) 1).setPriority((short) 1).setMulticastWeight((short) 1).setMulticastPriority((short) 1).setRouted(true).setRloc(locator).setLocatorId("SFC_LISP").build();
locatorRecords.add(locatorBuilder.build());
}
return locatorRecords;
}
Aggregations