use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder 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.mapping.record.list.MappingRecordItemBuilder in project lispflowmapping by opendaylight.
the class MapServerTest method handleMapRegisterTest_verifyTransportAddresses.
@Test
public void handleMapRegisterTest_verifyTransportAddresses() throws NoSuchFieldException, IllegalAccessException {
setConfigIniMappingMergeField(true);
// input
Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1)).thenReturn(OLD_MAPPING_DATA_1).thenReturn(OLD_MAPPING_DATA_2).thenReturn(getDefaultMappingData(getDefaultMappingRecordBuilder().build()));
Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock_1);
Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS)).thenReturn(DEFAULT_IP_ADDRESS_SET);
// result
final List<TransportAddress> transportAddressList = getTransportAddressList();
final MapNotifyBuilder mapNotifyBuilder = getDefaultMapNotifyBuilder(mapRegister);
mapNotifyBuilder.setMappingRecordItem(new ArrayList<>());
mapNotifyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(getDefaultMappingRecordBuilder().build()).build());
mapServer.handleMapRegister(mapRegister);
Mockito.verify(notifyHandler).handleMapNotify(mapNotifyBuilder.build(), transportAddressList);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder in project lispflowmapping by opendaylight.
the class MapServerTest method handleMapRegisterTest_withTwoMappingRecords.
@Test
@Ignore
public void handleMapRegisterTest_withTwoMappingRecords() throws NoSuchFieldException, IllegalAccessException {
setConfigIniMappingMergeField(true);
// Input
// Add a MappingRecord with SrcDestKey Eid Type
final MappingRecordItemBuilder mappingRecordItemBuilder = new MappingRecordItemBuilder().setMappingRecord(getDefaultMappingRecordBuilder().setEid(SOURCE_DEST_KEY_EID).build());
final MapRegisterBuilder mapRegisterSrcDstBuilder = getDefaultMapRegisterBuilder();
final List<MappingRecordItem> list = mapRegisterSrcDstBuilder.getMappingRecordItem();
list.add(mappingRecordItemBuilder.build());
// ------------- Stubbing for SourceDestKey type Eid mapping -------------------
Mockito.when(mapService.getAuthenticationKey(SOURCE_DEST_KEY_EID)).thenReturn(MAPPING_AUTHKEY);
Mockito.when(mapService.getMapping(MappingOrigin.Southbound, SOURCE_DEST_KEY_EID)).thenReturn(OLD_MAPPING_DATA_1).thenReturn(OLD_MAPPING_DATA_2).thenReturn(OLD_MAPPING_DATA_2);
// return a subscriberSet for SrcDestKeyEid MappingRecord
Mockito.when(mapService.getData(MappingOrigin.Southbound, SOURCE_DEST_KEY_EID, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock_1);
// return a subscriberSet for SrcDestKeyEid destination MappingRecord
Mockito.when(mapService.getData(MappingOrigin.Southbound, SourceDestKeyHelper.getDstBinary(SOURCE_DEST_KEY_EID), SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock_2);
// ----------------- Stubbing for Ipv4 type Eid mapping ------------------------
Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1)).thenReturn(OLD_MAPPING_DATA_1).thenReturn(OLD_MAPPING_DATA_2);
// return a subscriberSet for Ipv4Eid MappingRecord
Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock_3);
// -----------------------------------------------------------------------------
// result
mapServer.handleMapRegister(mapRegisterSrcDstBuilder.build());
// for SrcDstKey mapping
final ArgumentCaptor<MapRequest> captor_1 = ArgumentCaptor.forClass(MapRequest.class);
Mockito.verify(notifyHandler, Mockito.times(1)).handleSMR(captor_1.capture(), Mockito.eq(RLOC_2));
final Eid resultEid_1 = captor_1.getValue().getEidItem().iterator().next().getEid();
assertEquals(IPV4_SOURCE_EID_2, resultEid_1);
// for SrcDst destination mapping
final ArgumentCaptor<MapRequest> captor_2 = ArgumentCaptor.forClass(MapRequest.class);
Mockito.verify(notifyHandler, Mockito.times(1)).handleSMR(captor_2.capture(), Mockito.eq(RLOC_4));
final Eid resultEid_2 = captor_2.getValue().getEidItem().iterator().next().getEid();
assertEquals(IPV4_SOURCE_EID_4, resultEid_2);
// for Ipv4 mapping
final ArgumentCaptor<MapRequest> captor_3 = ArgumentCaptor.forClass(MapRequest.class);
Mockito.verify(notifyHandler, Mockito.times(2)).handleSMR(captor_3.capture(), Mockito.eq(RLOC_6));
final Eid resultEid_3 = captor_3.getValue().getEidItem().iterator().next().getEid();
assertEquals(IPV4_SOURCE_EID_6, resultEid_3);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder in project lispflowmapping by opendaylight.
the class LispNotificationHelperTest method getDefaultAddMapping.
private static AddMapping getDefaultAddMapping(boolean isXtrSiteIdPresent) {
final MappingRecordItem mappingRecordItem_1 = new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(EID_IPV4).build()).build();
final MappingRecordItem mappingRecordItem_2 = new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(EID_IPV6).build()).build();
final MapRegisterBuilder mapRegisterBuilder = new MapRegisterBuilder().setMappingRecordItem(Lists.newArrayList(mappingRecordItem_1, mappingRecordItem_2)).setXtrSiteIdPresent(isXtrSiteIdPresent).setSiteId(SITE_ID);
return new AddMappingBuilder().setMapRegister(mapRegisterBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder in project lispflowmapping by opendaylight.
the class MapReplySerializer method deserialize.
public MapReply deserialize(ByteBuffer replyBuffer) {
final byte typeAndFlags = replyBuffer.get();
final int type = typeAndFlags >> 4;
if (MessageType.forValue(type) != MessageType.MapReply) {
throw new LispSerializationException("Expected Map-Reply packet (type 2), but was type " + type);
}
MapReplyBuilder builder = new MapReplyBuilder();
builder.setProbe(ByteUtil.extractBit(typeAndFlags, Flags.PROBE));
builder.setEchoNonceEnabled(ByteUtil.extractBit(typeAndFlags, Flags.ECHO_NONCE_ENABLED));
builder.setSecurityEnabled(ByteUtil.extractBit(typeAndFlags, Flags.SECURITY_ENABLED));
replyBuffer.getShort();
int recordCount = ByteUtil.getUnsignedByte(replyBuffer);
builder.setNonce(replyBuffer.getLong());
builder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
for (int i = 0; i < recordCount; i++) {
builder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(MappingRecordSerializer.getInstance().deserialize(replyBuffer)).build());
}
return builder.build();
}
Aggregations