- public void getTopologyDetailsWithExceptionTest() throws InterruptedException, ExecutionException {
- DataBroker dataBroker = Mockito.mock(DataBroker.class);
- when(dataBroker.newReadOnlyTransaction())
- .thenReturn(new ReadTransactionMock());
-
- GetTopologyDetailsInput input = TopologyDataUtils.buildGetTopologyDetailsInput(TopologyUtils.T0_MULTILAYER);
- TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(dataBroker);
- ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
- RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
- Topology topology = rpcResult.getResult().getTopology();
- assertNull("Topology should be null", topology);
- }
-
- private class ReadTransactionMock implements ReadTransaction {
-
- @Override
- public @NonNull Object getIdentifier() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public <T extends DataObject> @NonNull FluentFuture<Optional<T>> read(@NonNull LogicalDatastoreType store,
- @NonNull InstanceIdentifier<T> path) {
- return FluentFuture.from(Futures.immediateFailedFuture(new InterruptedException()));
- }
-
- @Override
- public @NonNull FluentFuture<Boolean> exists(@NonNull LogicalDatastoreType store,
- @NonNull InstanceIdentifier<?> path) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void close() {
- // TODO Auto-generated method stub
- }
+ void getTopologyDetailsWithExceptionTest() throws InterruptedException, ExecutionException {
+ when(networkTransactionService.read(any(), any()))
+ .thenReturn(FluentFuture.from(Futures.immediateFailedFuture(new InterruptedException())));
+ when(rpcService.getRpc(GetTopologyDetails.class))
+ .thenReturn(new GetTopologyDetailsImpl(tapiContext, topologyUtils, tapiLink, networkTransactionService));
+ Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(
+ Charset.forName("UTF-8"))).toString());
+ GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
+ ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = rpcService
+ .getRpc(GetTopologyDetails.class).invoke(input);
+ assertFalse(result.get().isSuccessful(), "RpcResult is not successful");
+ assertNull(result.get().getResult(), "RpcResult result should be null");
+ assertEquals(ErrorType.RPC, result.get().getErrors().get(0).getErrorType());
+ assertEquals("Error building topology", result.get().getErrors().get(0).getMessage());