- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withDifferentEid() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder()
- // apply the change
- .setEid(IPV4_EID_2);
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_1.build()))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withDifferentRLOC() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder();
- // apply the change
- mappingRecordBuilder_1.getLocatorRecord().add(new LocatorRecordBuilder().build());
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_1.build()))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withDifferentAction() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder()
- // apply the change
- .setAction(MappingRecord.Action.NativelyForward);
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_1.build()))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withDifferentTTL() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder()
- // apply the change
- .setRecordTtl(10);
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_1.build()))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withDifferentMapVersion() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder()
- // apply the change
- .setMapVersion((short) 10);
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_1.build()))
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-
- @Test
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void mappingChangedTest_withNullMap() throws NoSuchFieldException, IllegalAccessException {
- setConfigIniMappingMergeField(true);
-
- final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
- final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
-
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
- Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SRC_RLOCS))
- .thenReturn(DEFAULT_IP_ADDRESS_SET);
-
- Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
- .thenReturn(null)
- .thenReturn(getDefaultMappingData(mappingRecordBuilder_2.build()))
- .thenReturn(null);
-
- mapServer.handleMapRegister(mapRegister);
- Mockito.verify(notifyHandler).handleMapNotify(Mockito.any(MapNotify.class), captor.capture());
- // verify that a list of transport addresses has 2 values - happens only if mappingUpdated == true
- assertEquals(2, captor.getValue().size());
- }
-