Search in sources :

Example 11 with AddMapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.

the class LispMappingServiceTest method onAddMappingTest.

/**
 * Tests {@link LispMappingService#onAddMapping} method.
 */
@Test
public void onAddMappingTest() {
    final org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegister mapRegister = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegister.class);
    final AddMapping addMapping = Mockito.mock(AddMapping.class);
    Mockito.when(addMapping.getMapRegister()).thenReturn(mapRegister);
    Mockito.when(mapRegister.getMappingRecordItem()).thenReturn(Lists.newArrayList(MAPPING_RECORD_ITEM_BUILDER.build()));
    Mockito.when(tlsMapNotifyMock.get()).thenReturn(getDefaultMapNotifyPair());
    lispMappingService.onAddMapping(addMapping);
    Mockito.verify(odlLispSbService, Mockito.times(2)).sendMapNotify(Mockito.argThat(new TransportAddressMatch()));
}
Also used : AddMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping) Test(org.junit.Test)

Example 12 with AddMapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.

the class MappingSystemTest method restoreDaoFromDatastoreTest.

/**
 * Tests {@link MappingSystem#restoreDaoFromDatastore} method.
 */
@Test
public void restoreDaoFromDatastoreTest() {
    final Mapping mapping_1 = new MappingBuilder().setOrigin(MappingOrigin.Northbound).setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_1).build()).build();
    final Mapping mapping_2 = new MappingBuilder().setOrigin(MappingOrigin.Northbound).setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_2).build()).build();
    final MappingAuthkey mappingAuthkey_1 = MAPPING_AUTHKEY_BUILDER.build();
    final AuthenticationKey authenticationKey_1 = new AuthenticationKeyBuilder().setMappingAuthkey(mappingAuthkey_1).setEid(EID_IPV4_1).build();
    final MappingAuthkey mappingAuthkey_2 = MAPPING_AUTHKEY_BUILDER.setKeyString("pass-2").build();
    final AuthenticationKey authenticationKey_2 = new AuthenticationKeyBuilder().setMappingAuthkey(mappingAuthkey_2).setEid(EID_IPV4_2).build();
    final List<Mapping> mappings = Lists.newArrayList(mapping_1, mapping_2);
    final List<AuthenticationKey> authenticationKeys = Lists.newArrayList(authenticationKey_1, authenticationKey_2);
    Mockito.when(dsbeMock.getLastUpdateTimestamp()).thenReturn(System.currentTimeMillis());
    Mockito.when(dsbeMock.getAllMappings(LogicalDatastoreType.CONFIGURATION)).thenReturn(mappings);
    Mockito.when(dsbeMock.getAllAuthenticationKeys()).thenReturn(authenticationKeys);
    Mockito.when(tableMapMock.get(MappingOrigin.Northbound)).thenReturn(pmcMock);
    mappingSystem.initialize();
    ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
    Mockito.verify(pmcMock).addMapping(Mockito.eq(EID_IPV4_1), captor.capture());
    assertEquals(captor.getValue().getRecord(), mapping_1.getMappingRecord());
    Mockito.verify(pmcMock).addMapping(Mockito.eq(EID_IPV4_2), captor.capture());
    assertEquals(captor.getValue().getRecord(), mapping_2.getMappingRecord());
    Mockito.verify(akdbMock).addAuthenticationKey(EID_IPV4_1, mappingAuthkey_1);
    Mockito.verify(akdbMock).addAuthenticationKey(EID_IPV4_2, mappingAuthkey_2);
}
Also used : AuthenticationKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder) MappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder) AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey) MappingAuthkey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 13 with AddMapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping in project lispflowmapping by opendaylight.

the class MappingServiceTest method addMappingTest_fromNorthbound.

/**
 * Tests {@link MappingService#addMapping} method from northbound.
 */
@Test
public void addMappingTest_fromNorthbound() throws ExecutionException, InterruptedException {
    // input
    final MappingOrigin origin = MappingOrigin.Northbound;
    final MappingRecord record = getDefaultMappingRecordBuilder().setXtrId(XTR_ID).build();
    final MappingData data = getDefaultMappingData(record);
    mappingService.addMapping(origin, IPV4_EID, SITE_ID, data);
    Mockito.verify(dsbe).addMapping(DSBEInputUtil.toMapping(origin, IPV4_EID, SITE_ID, data));
    Mockito.verifyZeroInteractions(mappingSystem);
    Mockito.verifyNoMoreInteractions(dsbe);
}
Also used : MappingOrigin(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin) 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 14 with AddMapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping 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 15 with AddMapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping 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)

Aggregations

Test (org.junit.Test)21 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)8 AddMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping)8 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 AddMappingInput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInput)6 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)4 Ignore (org.junit.Ignore)3 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)3 ILispDAO (org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)3 MappingChanged (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged)3 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)3 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)2 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)2 MapRegisterCacheKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.key.container.MapRegisterCacheKey)2 MapNotifyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder)2 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)2 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)2 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)2