use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.
the class MappingServiceTest method getMappingTest_withNullMapRecord.
/**
* Tests {@link MappingService#getMapping} method with null MappingRecord.
*/
@Test
public void getMappingTest_withNullMapRecord() throws ExecutionException, InterruptedException {
// input
final GetMappingInput getMappingInput = new GetMappingInputBuilder().setEid(IPV4_EID).build();
Mockito.when(mappingSystem.getMapping(getMappingInput.getEid())).thenReturn(null);
final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, "data-missing", "No mapping was found in the mapping database").build();
final RpcError error = rpc.getErrors().iterator().next();
// result
final Future<RpcResult<GetMappingOutput>> result = (mappingService.getMapping(getMappingInput));
final RpcError errorResult = result.get().getErrors().iterator().next();
assertEquals(1, result.get().getErrors().size());
assertEquals(error.getMessage(), errorResult.getMessage());
assertEquals(error.getApplicationTag(), errorResult.getApplicationTag());
assertEquals(error.getCause(), errorResult.getCause());
assertEquals(error.getErrorType(), errorResult.getErrorType());
assertEquals(error.getInfo(), errorResult.getInfo());
assertEquals(error.getTag(), errorResult.getTag());
assertEquals(error.getSeverity(), errorResult.getSeverity());
assertEquals(rpc.getResult(), result.get().getResult());
assertEquals(rpc.isSuccessful(), result.get().isSuccessful());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.
the class MappingServiceTest method getKeyTest_withNullMappingAuthkey.
/**
* Tests {@link MappingService#getKey} method with null MappingAuthkey.
*/
@Test
public void getKeyTest_withNullMappingAuthkey() throws ExecutionException, InterruptedException {
// input
final GetKeyInput getKeyInput = new GetKeyInputBuilder().setEid(IPV4_EID).build();
Mockito.when(mappingSystem.getAuthenticationKey(getKeyInput.getEid())).thenReturn(null);
final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, "data-missing", "Key was not found in the mapping database").build();
final RpcError error = rpc.getErrors().iterator().next();
// result
final Future<RpcResult<GetKeyOutput>> result = mappingService.getKey(getKeyInput);
final RpcError errorResult = result.get().getErrors().iterator().next();
assertEquals(1, result.get().getErrors().size());
assertEquals(error.getMessage(), errorResult.getMessage());
assertEquals(error.getApplicationTag(), errorResult.getApplicationTag());
assertEquals(error.getCause(), errorResult.getCause());
assertEquals(error.getErrorType(), errorResult.getErrorType());
assertEquals(error.getInfo(), errorResult.getInfo());
assertEquals(error.getTag(), errorResult.getTag());
assertEquals(error.getSeverity(), errorResult.getSeverity());
assertEquals(rpc.getResult(), result.get().getResult());
assertEquals(rpc.isSuccessful(), result.get().isSuccessful());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.
the class MappingDataListenerTest method init.
@Before
@SuppressWarnings("unchecked")
public void init() {
final DataBroker dataBrokerMock = Mockito.mock(DataBroker.class);
iMappingSystemMock = Mockito.mock(IMappingSystem.class);
notificationPublishServiceMock = Mockito.mock(NotificationPublishService.class);
mappingDataListener = new MappingDataListener(dataBrokerMock, iMappingSystemMock, notificationPublishServiceMock);
final InstanceIdentifier<Mapping> instanceIdentifierMock = Mockito.mock(InstanceIdentifier.class);
final DataTreeIdentifier<Mapping> dataTreeIdentifier = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, instanceIdentifierMock);
change_del = Mockito.mock(DataTreeModification.class);
change_subtreeModified = Mockito.mock(DataTreeModification.class);
change_write = Mockito.mock(DataTreeModification.class);
mod_del = Mockito.mock(DataObjectModification.class);
mod_subtreeModified = Mockito.mock(DataObjectModification.class);
mod_write = Mockito.mock(DataObjectModification.class);
Mockito.when(change_del.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_del.getRootNode()).thenReturn(mod_del);
Mockito.when(change_subtreeModified.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_subtreeModified.getRootNode()).thenReturn(mod_subtreeModified);
Mockito.when(change_write.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_write.getRootNode()).thenReturn(mod_write);
Mockito.when(mod_del.getModificationType()).thenReturn(ModificationType.DELETE);
Mockito.when(mod_subtreeModified.getModificationType()).thenReturn(ModificationType.SUBTREE_MODIFIED);
Mockito.when(mod_write.getModificationType()).thenReturn(ModificationType.WRITE);
Mockito.when(iMappingSystemMock.isMaster()).thenReturn(true);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping 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.mappingservice.rev150906.db.instance.Mapping 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