Search in sources :

Example 1 with MappingChanged

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged in project lispflowmapping by opendaylight.

the class MappingDataListenerTest method onDataTreeChangedTest_subtreeModified_NB.

/**
 * Tests {@link MappingDataListener#onDataTreeChanged} method with SUBTREE_MODIFIED modification type from
 * northbound.
 */
@Test
@Ignore
@SuppressWarnings("unchecked")
public void onDataTreeChangedTest_subtreeModified_NB() throws InterruptedException {
    final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(change_subtreeModified);
    final MappingChanged mapChanged = MSNotificationInputUtil.toMappingChanged(MAPPING_EID_2_NB.getMappingRecord(), null, null, null, MappingChange.Updated);
    Mockito.when(mod_subtreeModified.getDataAfter()).thenReturn(MAPPING_EID_2_NB);
    mappingDataListener.onDataTreeChanged(changes);
    final ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
    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(mapChanged);
}
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 2 with MappingChanged

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged in project lispflowmapping by opendaylight.

the class MappingDataListenerTest method onDataTreeChangedTest_write_NB.

/**
 * Tests {@link MappingDataListener#onDataTreeChanged} method with WRITE modification type from northbound.
 */
@Test
@Ignore
@SuppressWarnings("unchecked")
public void onDataTreeChangedTest_write_NB() throws InterruptedException {
    final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(change_write);
    final MappingChanged mapChanged = MSNotificationInputUtil.toMappingChanged(MAPPING_EID_3_NB.getMappingRecord(), null, null, null, MappingChange.Created);
    Mockito.when(mod_write.getDataAfter()).thenReturn(MAPPING_EID_3_NB);
    mappingDataListener.onDataTreeChanged(changes);
    final ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
    Mockito.verify(iMappingSystemMock).addMapping(Mockito.eq(MappingOrigin.Northbound), Mockito.eq(IPV4_EID_3), captor.capture());
    assertEquals(captor.getValue().getRecord(), MAPPING_EID_3_NB.getMappingRecord());
    Mockito.verify(notificationPublishServiceMock).putNotification(mapChanged);
}
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 3 with MappingChanged

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged in project lispflowmapping by opendaylight.

the class MapServer method onMappingChanged.

@Override
public void onMappingChanged(MappingChanged notification) {
    if (subscriptionService) {
        Eid eid = notification.getEid();
        if (eid == null) {
            eid = notification.getMappingRecord().getEid();
        }
        LOG.trace("MappingChanged event for {} of type: `{}'", LispAddressStringifier.getString(eid), notification.getChangeType());
        Set<Subscriber> subscribers = MSNotificationInputUtil.toSubscriberSet(notification.getSubscriberItem());
        LoggingUtil.logSubscribers(LOG, eid, subscribers);
        if (mapService.isMaster()) {
            sendSmrs(eid, subscribers);
            if (eid.getAddress() instanceof SourceDestKey) {
                Set<Subscriber> dstSubscribers = MSNotificationInputUtil.toSubscriberSetFromDst(notification.getDstSubscriberItem());
                LoggingUtil.logSubscribers(LOG, SourceDestKeyHelper.getDstBinary(eid), dstSubscribers);
                sendSmrs(SourceDestKeyHelper.getDstBinary(eid), dstSubscribers);
            }
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)

Example 4 with MappingChanged

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged 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)

Aggregations

Ignore (org.junit.Ignore)3 Test (org.junit.Test)3 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)3 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)3 MappingChanged (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged)3 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)1 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)1 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)1