@Test public void getNonExistingSchemaSource() throws InterruptedException { doReturn(Futures.failed(new SchemaSourceException("Source not provided"))) .when(mockedRemoteSchemaRepository).getYangTextSchemaSource(ID); ListenableFuture<YangTextSchemaSource> sourceFuture = remoteSchemaProvider.getSource(ID); assertTrue(sourceFuture.isDone()); try { sourceFuture.get(); fail("Expected a failure to occur"); } catch (ExecutionException e) { assertThat(e.getCause(), instanceOf(SchemaSourceException.class)); } }
@Override public ListenableFuture<YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) { LOG.trace("Getting yang schema source for {}", sourceIdentifier.getName()); Future<YangTextSchemaSourceSerializationProxy> result = remoteRepo.getYangTextSchemaSource(sourceIdentifier); final SettableFuture<YangTextSchemaSource> res = SettableFuture.create(); result.onComplete(new OnComplete<YangTextSchemaSourceSerializationProxy>() { @Override public void onComplete(final Throwable throwable, final YangTextSchemaSourceSerializationProxy yangTextSchemaSourceSerializationProxy) { if (yangTextSchemaSourceSerializationProxy != null) { res.set(yangTextSchemaSourceSerializationProxy.getRepresentation()); } if (throwable != null) { res.setException(throwable); } } }, executionContext); return res; }
RemoteSchemaProvider implements SchemaSourceProvider<YangTextSchemaSource> { @Override public ListenableFuture<YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) { LOG.trace("Getting yang schema source for {}", sourceIdentifier.getName()); Future<YangTextSchemaSourceSerializationProxy> result = remoteRepo.getYangTextSchemaSource(sourceIdentifier); final SettableFuture<YangTextSchemaSource> res = SettableFuture.create(); result.onComplete(new OnComplete<YangTextSchemaSourceSerializationProxy>() { @Override public void onComplete(final Throwable throwable, final YangTextSchemaSourceSerializationProxy yangTextSchemaSourceSerializationProxy) { if (yangTextSchemaSourceSerializationProxy != null) { res.set(yangTextSchemaSourceSerializationProxy.getRepresentation()); } if (throwable != null) { res.setException(throwable); } } }, executionContext); return res; } }
RemoteSchemaProvider implements SchemaSourceProvider<YangTextSchemaSource> { @Override public ListenableFuture<YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) { LOG.trace("Getting yang schema source for {}", sourceIdentifier.getName()); Future<YangTextSchemaSourceSerializationProxy> result = remoteRepo.getYangTextSchemaSource(sourceIdentifier); final SettableFuture<YangTextSchemaSource> res = SettableFuture.create(); result.onComplete(new OnComplete<YangTextSchemaSourceSerializationProxy>() { @Override public void onComplete(final Throwable throwable, final YangTextSchemaSourceSerializationProxy yangTextSchemaSourceSerializationProxy) { if (yangTextSchemaSourceSerializationProxy != null) { res.set(yangTextSchemaSourceSerializationProxy.getRepresentation()); } if (throwable != null) { res.setException(throwable); } } }, executionContext); return res; } RemoteSchemaProvider(final RemoteYangTextSourceProvider remoteRepo,
            final ExecutionContext executionContext); }
RemoteSchemaProvider implements SchemaSourceProvider<YangTextSchemaSource> { @Override public ListenableFuture<YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) { LOG.trace("Getting yang schema source for {}", sourceIdentifier.getName()); Future<YangTextSchemaSourceSerializationProxy> result = remoteRepo.getYangTextSchemaSource(sourceIdentifier); final SettableFuture<YangTextSchemaSource> res = SettableFuture.create(); result.onComplete(new OnComplete<YangTextSchemaSourceSerializationProxy>() { @Override public void onComplete(final Throwable throwable, final YangTextSchemaSourceSerializationProxy yangTextSchemaSourceSerializationProxy) { if (yangTextSchemaSourceSerializationProxy != null) { res.set(yangTextSchemaSourceSerializationProxy.getRepresentation()); } if (throwable != null) { res.setException(throwable); } } }, executionContext); return res; } RemoteSchemaProvider(final RemoteYangTextSourceProvider remoteRepo,
            final ExecutionContext executionContext); @Override ListenableFuture<YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier); }
RemoteSchemaProvider implements SchemaSourceProvider<YangTextSchemaSource> { @Override public ListenableFuture<YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) { LOG.trace("Getting yang schema source for {}", sourceIdentifier.getName()); Future<YangTextSchemaSourceSerializationProxy> result = remoteRepo.getYangTextSchemaSource(sourceIdentifier); final SettableFuture<YangTextSchemaSource> res = SettableFuture.create(); result.onComplete(new OnComplete<YangTextSchemaSourceSerializationProxy>() { @Override public void onComplete(final Throwable throwable, final YangTextSchemaSourceSerializationProxy yangTextSchemaSourceSerializationProxy) { if (yangTextSchemaSourceSerializationProxy != null) { res.set(yangTextSchemaSourceSerializationProxy.getRepresentation()); } if (throwable != null) { res.setException(throwable); } } }, executionContext); return res; } RemoteSchemaProvider(final RemoteYangTextSourceProvider remoteRepo,
            final ExecutionContext executionContext); @Override ListenableFuture<YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier);  }