Search in sources :

Example 61 with MappingData

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);
}
Also used : MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) MapNotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder) Test(org.junit.Test)

Example 62 with MappingData

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));
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Test(org.junit.Test)

Example 63 with MappingData

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);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) MappingChanged(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 64 with MappingData

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;
}
Also used : MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Date(java.util.Date)

Example 65 with 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());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) Test(org.junit.Test)

Aggregations

MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)69 Test (org.junit.Test)40 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)30 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)17 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)14 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)11 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)9 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)9 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)7 MapReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder)7 ArrayList (java.util.ArrayList)5 Ignore (org.junit.Ignore)5 Date (java.util.Date)4 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)4 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)4 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)4 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)4 Set (java.util.Set)3 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)3 IRowVisitor (org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor)3