}
int queries = Helper.getQueries(exchange);
World[] worlds = new World[queries];
for (int i = 0; i < queries; i++) {
int id = Helper.randomWorld();
DBObject key = new BasicDBObject("_id", id);
//
// The requirements for the test dictate that we must fetch the World
// object from the data store and read its randomNumber field, even though
// we could technically avoid doing either of those things and still
// produce the correct output and side effects.
//
DBObject object = database.getCollection("World").findOne(key);
@SuppressWarnings("unused")
// Per test requirement the old value must be read
int oldRandomNumber = ((Number) object.get("randomNumber")).intValue();
int newRandomNumber = Helper.randomWorld();
object.put("randomNumber", newRandomNumber);
database.getCollection("World").update(key, object);
worlds[i] = new World(id, newRandomNumber);
}
exchange.getResponseHeaders().put(
Headers.CONTENT_TYPE, JSON_UTF8);