### Question:
AddressSelector { public Single<List<AddressInformation>> resolveAddressesAsync(RxDocumentServiceRequest request, boolean forceAddressRefresh) { Single<List<AddressInformation>> resolvedAddressesObs = (this.addressResolver.resolveAsync(request, forceAddressRefresh)) .map(addresses -> Arrays.stream(addresses) .filter(address -> { return !Strings.isNullOrEmpty(address.getPhysicalUri().getURIAsString()) && Strings.areEqualIgnoreCase(address.getProtocolScheme(), this.protocol.scheme()); }) .collect(Collectors.toList())); return resolvedAddressesObs.map( resolvedAddresses -> { List<AddressInformation> r = resolvedAddresses.stream().filter(address -> !address.isPublic()).collect(Collectors.toList()); if (r.size() > 0) { return r; } else { return resolvedAddresses.stream().filter(address -> address.isPublic()).collect(Collectors.toList()); } } ); } AddressSelector(IAddressResolver addressResolver, Protocol protocol); Single<List<Uri>> resolveAllUriAsync(
        RxDocumentServiceRequest request,
        boolean includePrimary,
        boolean forceRefresh); Single<Uri> resolvePrimaryUriAsync(RxDocumentServiceRequest request, boolean forceAddressRefresh); static Uri getPrimaryUri(RxDocumentServiceRequest request, List<AddressInformation> replicaAddresses); Single<List<AddressInformation>> resolveAddressesAsync(RxDocumentServiceRequest request, boolean forceAddressRefresh);  }### Answer:
@Test(groups = "unit") public void resolveAddressesAsync() { IAddressResolver addressResolver = Mockito.mock(IAddressResolver.class); AddressSelector selector = new AddressSelector(addressResolver, Protocol.Https); RxDocumentServiceRequest request = Mockito.mock(RxDocumentServiceRequest.class); Mockito.doReturn(null).when(request).getDefaultReplicaIndex(); List<AddressInformation> replicaAddresses = new ArrayList<>(); replicaAddresses.add(new AddressInformation(true, false, "https: replicaAddresses.add(new AddressInformation(true, true, "https: replicaAddresses.add(new AddressInformation(true, false, "https: replicaAddresses.add(new AddressInformation(true, true, "https: replicaAddresses.add(new AddressInformation(true, false, "https: Mockito.doReturn(Single.just(replicaAddresses.toArray(new AddressInformation[0]))).when(addressResolver).resolveAsync(Mockito.any(RxDocumentServiceRequest.class), Matchers.eq(false)); List<AddressInformation> res = selector.resolveAddressesAsync(request, false).toBlocking().value(); assertThat(res).isEqualTo(replicaAddresses.stream().filter(a -> a.getProtocolName().equals(Protocol.Https.name())).collect(Collectors.toList())); }