### Question:
Datastore { public AllocateIdsResponse allocateIds(AllocateIdsRequest request) throws DatastoreException { try (InputStream is = remoteRpc.call("allocateIds", request)) { return AllocateIdsResponse.parseFrom(is); } catch (IOException exception) { throw invalidResponseException("allocateIds", exception); } } Datastore(RemoteRpc remoteRpc); void resetRpcCount(); int getRpcCount(); AllocateIdsResponse allocateIds(AllocateIdsRequest request); BeginTransactionResponse beginTransaction(BeginTransactionRequest request); CommitResponse commit(CommitRequest request); LookupResponse lookup(LookupRequest request); ReserveIdsResponse reserveIds(ReserveIdsRequest request); RollbackResponse rollback(RollbackRequest request); RunQueryResponse runQuery(RunQueryRequest request);  }### Answer:
@Test public void initializer() throws Exception { options.initializer(new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) { request.getHeaders().setCookie("magic"); } }); Datastore datastore = factory.create(options.build()); MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; AllocateIdsRequest request = AllocateIdsRequest.newBuilder().build(); AllocateIdsResponse response = AllocateIdsResponse.newBuilder().build(); mockClient.setNextResponse(response); assertEquals(response, datastore.allocateIds(request)); assertEquals("magic", mockClient.lastCookies.get(0)); }
@Test public void allocateIds() throws Exception { AllocateIdsRequest.Builder request = AllocateIdsRequest.newBuilder(); AllocateIdsResponse.Builder response = AllocateIdsResponse.newBuilder(); expectRpc("allocateIds", request.build(), response.build()); }