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()));
}
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);
}
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);
}
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);
}
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);
}
Aggregations