public void testDoNotGetCommandIfNotLastResponse() throws Exception {
CapturedBrowsers browsers = new CapturedBrowsers(new BrowserIdStrategy(new MockTime(0)));
String id = "1";
SlaveBrowser slave =
new SlaveBrowser(new TimeImpl(), id, new BrowserInfo(), 20, null, CaptureHandler.QUIRKS,
RunnerType.CLIENT, BrowserState.CAPTURED, new Instant(0));
browsers.addSlave(slave);
BrowserQueryResponseHandler handler =
new BrowserQueryResponseHandler(null, null, browsers, streamedResponses);
slave.createCommand("awaitingResponse");
slave.dequeueCommand();
slave.createCommand("BrowserCommand");
Gson gson = new Gson();
Response response = new Response();
response.setResponse("response");
BrowserInfo browserInfo = new BrowserInfo();
browserInfo.setId(1l);
browserInfo.setName("browser");
browserInfo.setOs("OS");
browserInfo.setVersion("version");
response.setBrowser(browserInfo);
handler.service(id, gson.toJson(response), "", null, writer);
assertEquals(new Gson().toJson(new BrowserStreamAcknowledged(Collections.<String>emptyList())),
out.toString());
}