Source:
<code>public void singleSyncTokenTest() throws Exception { final SyncTokenPolicy syncTokenPolicy = new SyncTokenPolicy(); final String firstSyncToken = constructSyncTokenString(ID, VALUE, SEQUENCE_NUMBER); final HttpPipeline pipeline = customizedPipeline(firstSyncToken, syncTokenPolicy); <START> final HttpResponse response = pipeline.send(new HttpRequest(HttpMethod.GET, new URL("http://localhost/"))).block(); <END> final String firstRequestHeader = response.getRequest().getHeaders().getValue(SYNC_TOKEN); assertEquals("", firstRequestHeader); final String firstResponseHeader = response.getHeaders().getValue(SYNC_TOKEN); assertEquals(firstSyncToken, firstResponseHeader); final String secondSyncToken = constructSyncTokenString(ID, UPDATED_VALUE, UPDATED_SEQUENCE_NUMBER); final HttpPipeline pipeline2 = customizedPipeline(secondSyncToken, syncTokenPolicy); final HttpResponse response2 = pipeline2.send(new HttpRequest(HttpMethod.GET, new URL("http://localhost/"))).block(); final String secondRequestHeader = response2.getRequest().getHeaders().getValue(SYNC_TOKEN); assertEquals(constructSyncTokenStringWithoutSeqNumber(ID, VALUE), secondRequestHeader); final HttpResponse response3 = pipeline2.send(new HttpRequest(HttpMethod.GET, new URL("http://localhost/"))).block(); final String thirdRequestHeader = response3.getRequest().getHeaders().getValue(SYNC_TOKEN); assertEquals(constructSyncTokenStringWithoutSeqNumber(ID, UPDATED_VALUE), thirdRequestHeader); }</code><technical_language>Step Verifier used... Mockito mock HttpResponse instead</technical_language>

Target:
public void singleSyncTokenTest() throws MalformedURLException { final String firstResponseHeadersExpected = constructSyncTokenString(ID, VALUE, SN_NAME, SEQUENCE_NUMBER); final String secondResponseHeaderExpected = constructSyncTokenString(ID, UPDATED_VALUE, SN_NAME, UPDATED_SEQUENCE_NUMBER); final HttpRequest firstRequest = new HttpRequest(HttpMethod.GET, new URL(LOCAL_HOST), new HttpHeaders(), null); final HttpRequest secondRequest = new HttpRequest(HttpMethod.GET, new URL(LOCAL_HOST), new HttpHeaders().put(SYNC_TOKEN, firstResponseHeadersExpected), null); final String secondResponseRequestHeaderExpected = constructSyncTokenString(ID, VALUE, null, null); when(httpPipelineCallContext.getHttpRequest()).thenReturn(firstRequest, secondRequest); when(httpPipelineNextPolicy.process()).thenReturn( Mono.just(new MockHttpResponse(firstRequest, 200, new HttpHeaders().put(SYNC_TOKEN, firstResponseHeadersExpected))), Mono.just(new MockHttpResponse(secondRequest, 200, new HttpHeaders().put(SYNC_TOKEN, secondResponseHeaderExpected)))); final SyncTokenPolicy syncTokenPolicy = new SyncTokenPolicy(); final HttpResponse firstResponse = syncTokenPolicy.process(httpPipelineCallContext, httpPipelineNextPolicy).block(); final HttpResponse secondResponse = syncTokenPolicy.process(httpPipelineCallContext, httpPipelineNextPolicy).block(); assertTrue(firstResponse.getRequest().getHeaders().getValue(SYNC_TOKEN).isEmpty()); assertEquals(firstResponseHeadersExpected, firstResponse.getHeaders().getValue(SYNC_TOKEN)); assertEquals( secondResponseRequestHeaderExpected.substring(0, secondResponseRequestHeaderExpected.length() - 1), secondResponse.getRequest().getHeaders().getValue(SYNC_TOKEN)); assertEquals(secondResponseHeaderExpected, secondResponse.getHeaders().getValue(SYNC_TOKEN)); }