use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.
the class LispNotificationHelper method getMapping.
public static List<Mapping> getMapping(AddMapping mapRegisterNotification) {
List<Mapping> mappings = new ArrayList<Mapping>();
for (int i = 0; i < mapRegisterNotification.getMapRegister().getMappingRecordItem().size(); i++) {
MappingRecord record = mapRegisterNotification.getMapRegister().getMappingRecordItem().get(i).getMappingRecord();
MappingBuilder mb = new MappingBuilder();
mb.setEidUri(new EidUri(LispAddressStringifier.getURIString(record.getEid())));
mb.setOrigin(MappingOrigin.Southbound);
mb.setSiteId(getSiteId(mapRegisterNotification.getMapRegister()));
mb.setMappingRecord(record);
mappings.add(mb.build());
}
return mappings;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping 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.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.
the class MappingServiceTest method addMappingTest.
/**
* Tests {@link MappingService#addMapping} method.
*/
@Test
public void addMappingTest() throws ExecutionException, InterruptedException {
final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
final AddMappingInput addMappingInput = new AddMappingInputBuilder().setMappingRecord(mappingRecordBuilder.build()).build();
final Future<RpcResult<Void>> result = mappingService.addMapping(addMappingInput);
Mockito.verify(dsbe).addMapping(RPCInputConvertorUtil.toMapping(addMappingInput));
assertEquals(RPC_RESULT_SUCCESS.getErrors(), result.get().getErrors());
assertEquals(RPC_RESULT_SUCCESS.getResult(), result.get().getResult());
assertEquals(RPC_RESULT_SUCCESS.isSuccessful(), result.get().isSuccessful());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping 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.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping 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);
}
Aggregations