use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MapServerTest method handleMapRegisterTest_MappingMergeTrue.
@Test
public void handleMapRegisterTest_MappingMergeTrue() throws NoSuchFieldException, IllegalAccessException {
setConfigIniMappingMergeField(true);
final MappingRecordItemBuilder mappingRecordItemBuilder = new MappingRecordItemBuilder().setMappingRecord(OLD_MAPPING_RECORD_1);
final MapNotifyBuilder mapNotifyBuilder = getDefaultMapNotifyBuilder(mapRegister).setMappingRecordItem(new ArrayList<>());
mapNotifyBuilder.getMappingRecordItem().add(mappingRecordItemBuilder.build());
// no mapping changes
Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1)).thenReturn(OLD_MAPPING_DATA_1);
mappingData.setMergeEnabled(true);
mapServer.handleMapRegister(mapRegister);
final ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
Mockito.verify(mapService).addMapping(Mockito.eq(MappingOrigin.Southbound), Mockito.eq(IPV4_EID_1), Mockito.eq(mapRegister.getSiteId()), captor.capture());
assertEquals(captor.getValue().getRecord(), mappingData.getRecord());
Mockito.verify(notifyHandler).handleMapNotify(mapNotifyBuilder.setAuthenticationData(null).build(), null);
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MappingServiceTest method addMappingTest_fromSouthbound.
/**
* Tests {@link MappingService#addMapping} method from southbound.
*/
@Test
public void addMappingTest_fromSouthbound() throws ExecutionException, InterruptedException {
// input
final MappingRecord record = getDefaultMappingRecordBuilder().setXtrId(XTR_ID).build();
final MappingData data = getDefaultMappingData(record);
mappingService.addMapping(MappingOrigin.Southbound, IPV4_EID, SITE_ID, data);
Mockito.verify(mappingSystem).addMapping(MappingOrigin.Southbound, IPV4_EID, data);
Mockito.verify(dsbe).addMapping(DSBEInputUtil.toMapping(MappingOrigin.Southbound, IPV4_EID, SITE_ID, data));
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class MappingDataListenerTest method onDataTreeChangedTest_multipleChanges.
/**
* Tests {@link MappingDataListener#onDataTreeChanged} method with multiple changes.
*/
@Test
@Ignore
@SuppressWarnings("unchecked")
public void onDataTreeChangedTest_multipleChanges() throws InterruptedException {
final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(change_del, change_subtreeModified, change_write);
final MappingChanged mapChangedSubtreeMod = MSNotificationInputUtil.toMappingChanged(MAPPING_EID_2_NB.getMappingRecord(), null, null, null, MappingChange.Updated);
Mockito.when(mod_del.getDataBefore()).thenReturn(MAPPING_EID_1_NB);
Mockito.when(mod_subtreeModified.getDataAfter()).thenReturn(MAPPING_EID_2_NB);
Mockito.when(mod_write.getDataAfter()).thenReturn(MAPPING_EID_3_SB);
mappingDataListener.onDataTreeChanged(changes);
final ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
Mockito.verify(iMappingSystemMock).removeMapping(MappingOrigin.Northbound, IPV4_EID_1);
Mockito.verify(iMappingSystemMock).addMapping(Mockito.eq(MappingOrigin.Northbound), Mockito.eq(IPV4_EID_2), captor.capture());
assertEquals(captor.getValue().getRecord(), MAPPING_EID_2_NB.getMappingRecord());
Mockito.verify(notificationPublishServiceMock).putNotification(mapChangedSubtreeMod);
// Mockito.verifyNoMoreInteractions(iMappingSystemMock);
Mockito.verifyNoMoreInteractions(notificationPublishServiceMock);
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData in project lispflowmapping by opendaylight.
the class TimeBucketWheelUnitTest method getDefaultMappingDataWithProperTimestamp.
private MappingData getDefaultMappingDataWithProperTimestamp(Eid eid, long timeStamp) {
MappingData mappingData = getDefaultMappingData(eid);
Date date = new Date();
date.setTime(timeStamp);
mappingData.setTimestamp(date);
return mappingData;
}
use of org.opendaylight.lispflowmapping.lisp.type.MappingData 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());
}
Aggregations