### Question:
AddressSelector { public Single<List<Uri>> resolveAllUriAsync( RxDocumentServiceRequest request, boolean includePrimary, boolean forceRefresh) { Single<List<AddressInformation>> allReplicaAddressesObs = this.resolveAddressesAsync(request, forceRefresh); return allReplicaAddressesObs.map(allReplicaAddresses -> allReplicaAddresses.stream().filter(a -> includePrimary || !a.isPrimary()) .map(a -> a.getPhysicalUri()).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 resolveAllUriAsync() { 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<Uri> res = selector.resolveAllUriAsync(request, true, false).toBlocking().value(); assertThat(res).isEqualTo(ImmutableList.of(Uri.create("https: }
@Test(groups = "unit") public void resolveAllUriAsync_RNTBD() { IAddressResolver addressResolver = Mockito.mock(IAddressResolver.class); AddressSelector selector = new AddressSelector(addressResolver, Protocol.Tcp); RxDocumentServiceRequest request = Mockito.mock(RxDocumentServiceRequest.class); Mockito.doReturn(null).when(request).getDefaultReplicaIndex(); List<AddressInformation> replicaAddresses = new ArrayList<>(); replicaAddresses.add(new AddressInformation(true, false, "rntbd: replicaAddresses.add(new AddressInformation(true, true, "rntbd: 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<Uri> res = selector.resolveAllUriAsync(request, true, false).toBlocking().value(); assertThat(res).isEqualTo(ImmutableList.of(Uri.create("rntbd: }