### Question:
AddressSelector { public Single<Uri> resolvePrimaryUriAsync(RxDocumentServiceRequest request, boolean forceAddressRefresh) { Single<List<AddressInformation>> replicaAddressesObs = this.resolveAddressesAsync(request, forceAddressRefresh); return replicaAddressesObs.flatMap(replicaAddresses -> { try { return Single.just(AddressSelector.getPrimaryUri(request, replicaAddresses)); } catch (Exception e) { return Single.error(e); } }); } 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 resolvePrimaryUriAsync() { 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)); Uri res = selector.resolvePrimaryUriAsync(request, false).toBlocking().value(); assertThat(res).isEqualTo(Uri.create("https: }