@Test(groups = "unit")
public void sessionRead_LegitimateNotFound() {

    long lsn = 651175;
    long globalCommittedLsn = 651174;
    String partitionKeyRangeId = "73";
    NotFoundException foundException = new NotFoundException();
    foundException.getResponseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn);
    foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(lsn));
    foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(lsn));
    foundException.getResponseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn));
    TransportClientWrapper transportClientWrapper = new TransportClientWrapper.Builder.ReplicaResponseBuilder
            .SequentialBuilder()
            .then(foundException) // 1st replica read returns not found lsn(response) >= lsn(request)
            .then(foundException) // 2nd replica read returns not found lsn(response) >= lsn(request)
            .then(foundException) // 3rd replica read returns not found lsn(response) >= lsn(request)
            .then(foundException) // 4th replica read returns not found lsn(response) >= lsn(request)
            .build();
    Uri primaryUri = Uri.create("primary");
    Uri secondaryUri1 = Uri.create("secondary1");
    Uri secondaryUri2 = Uri.create("secondary2");
    Uri secondaryUri3 = Uri.create("secondary3");
    AddressSelectorWrapper addressSelectorWrapper = AddressSelectorWrapper.Builder.Simple.create()
            .withPrimary(primaryUri)
            .withSecondary(ImmutableList.of(secondaryUri1, secondaryUri2, secondaryUri3))
            .build();
    ISessionContainer sessionContainer = Mockito.mock(ISessionContainer.class);
    TimeoutHelper timeoutHelper = Mockito.mock(TimeoutHelper.class);
    RxDocumentServiceRequest dsr = RxDocumentServiceRequest.createFromName(
            OperationType.Read, "/dbs/db/colls/col/docs/docId", ResourceType.Document);
    dsr.getHeaders().put(HttpConstants.HttpHeaders.CONSISTENCY_LEVEL, ConsistencyLevel.Session.name());
    dsr.requestContext = new DocumentServiceRequestContext();
    Utils.ValueHolder<ISessionToken> sessionToken = Utils.ValueHolder.initialize(null);
    assertThat(VectorSessionToken.tryCreate("-1#" + lsn , sessionToken)).isTrue();
    dsr.requestContext.timeoutHelper = timeoutHelper;
    dsr.requestContext.resolvedPartitionKeyRange = partitionKeyRangeWithId(partitionKeyRangeId);
    dsr.requestContext.requestChargeTracker = new RequestChargeTracker();
    Mockito.doReturn(sessionToken.v).when(sessionContainer).resolvePartitionLocalSessionToken(Mockito.eq(dsr), Mockito.anyString());
    Configs configs = new Configs();
    GatewayServiceConfiguratorReaderMock gatewayServiceConfigurationReaderWrapper = GatewayServiceConfiguratorReaderMock.from(ConsistencyLevel.Strong,
                                                                                                                              4,
                                                                                                                              3,
                                                                                                                              4,
                                                                                                                              3);
    IAuthorizationTokenProvider authTokenProvider = Mockito.mock(IAuthorizationTokenProvider.class);
    ConsistencyReader consistencyReader = new ConsistencyReader(configs,
                                                                addressSelectorWrapper.addressSelector,
                                                                sessionContainer,
                                                                transportClientWrapper.transportClient,
                                                                gatewayServiceConfigurationReaderWrapper.gatewayServiceConfigurationReader,
                                                                authTokenProvider);
    Single<StoreResponse> storeResponseSingle = consistencyReader.readAsync(dsr, timeoutHelper, false, false);
    FailureValidator failureValidator = FailureValidator.builder().resourceNotFound().instanceOf(NotFoundException.class).unknownSubStatusCode().build();
    validateException(storeResponseSingle, failureValidator);
}