Java Code Examples for okhttp3.mockwebserver.MockWebServer#takeRequest()

The following examples show how to use okhttp3.mockwebserver.MockWebServer#takeRequest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FieldsConverterShould.java    From dhis2-android-sdk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void have_correct_retrofit_request_format() throws IOException, InterruptedException {
    MockWebServer mockWebServer = new MockWebServer();
    mockWebServer.start();
    mockWebServer.enqueue(new MockResponse());

    TestService testService = testService(mockWebServer);

    testService.test(Fields.<String>builder()
            .fields(
                    Field.<String, String>create("property_one"),
                    Field.<String, String>create("property_two"),
                    NestedField.<String, String>create("nested_property").with(
                            Field.<String, String>create("nested_property_one")))
            .build())
            .execute();

    RecordedRequest recordedRequest = mockWebServer.takeRequest();
    assertThat(recordedRequest.getPath()).isEqualTo(
            "/api/?fields=property_one,property_two,nested_property[nested_property_one]");

    mockWebServer.shutdown();
}
 
Example 2
Source File: EmitterTest.java    From snowplow-android-tracker with Apache License 2.0 6 votes vote down vote up
public void testEmitTwoGetEvents() throws InterruptedException, IOException {
    MockWebServer mockServer = getMockServer();
    EmittableEvents emittableEvents = getEmittableEvents(mockServer, 2);
    Emitter emitter = getEmitter(getMockServerURI(mockServer), HttpMethod.GET, BufferOption.Single, RequestSecurity.HTTP);

    LinkedList<RequestResult> result = emitter.performAsyncEmit(emitter.buildRequests(emittableEvents));
    assertEquals(2, result.size());
    assertEquals(0, result.getFirst().getEventIds().getFirst().intValue());
    assertEquals(1, result.get(1).getEventIds().getFirst().intValue());

    RecordedRequest req = mockServer.takeRequest(2, TimeUnit.SECONDS);
    assertGETRequest(req);

    req = mockServer.takeRequest(2, TimeUnit.SECONDS);
    assertGETRequest(req);

    mockServer.shutdown();
}
 
Example 3
Source File: EmitterTest.java    From snowplow-android-tracker with Apache License 2.0 6 votes vote down vote up
public void testEmitSinglePostEvent() throws InterruptedException, IOException, JSONException {
    MockWebServer mockServer = getMockServer();
    EmittableEvents emittableEvents = getEmittableEvents(mockServer, 1);
    Emitter emitter = getEmitter(getMockServerURI(mockServer), HttpMethod.POST, BufferOption.DefaultGroup, RequestSecurity.HTTP);

    LinkedList<RequestResult> result = emitter.performAsyncEmit(emitter.buildRequests(emittableEvents));
    assertEquals(1, result.size());
    assertEquals(0, result.getFirst().getEventIds().getFirst().intValue());

    RecordedRequest req = mockServer.takeRequest(2, TimeUnit.SECONDS);
    JSONObject payload = assertPOSTRequest(req);

    JSONArray data = payload.getJSONArray("data");
    assertEquals(1, data.length());
    JSONObject event = data.getJSONObject(0);
    assertEquals(2, event.length());
    assertEquals(0, event.getInt("a"));

    mockServer.shutdown();
}
 
Example 4
Source File: EmitterTest.java    From snowplow-android-tracker with Apache License 2.0 6 votes vote down vote up
public void testEmitTwoEventsPostAsGroup() throws InterruptedException, IOException, JSONException {
    MockWebServer mockServer = getMockServer();
    EmittableEvents emittableEvents = getEmittableEvents(mockServer, 2);
    Emitter emitter = getEmitter(getMockServerURI(mockServer), HttpMethod.POST, BufferOption.DefaultGroup, RequestSecurity.HTTP);

    LinkedList<RequestResult> result = emitter.performAsyncEmit(emitter.buildRequests(emittableEvents));
    assertEquals(1, result.size());
    assertEquals(0, result.getFirst().getEventIds().getFirst().intValue());
    assertEquals(1, result.getFirst().getEventIds().get(1).intValue());

    RecordedRequest req = mockServer.takeRequest(2, TimeUnit.SECONDS);
    JSONObject payload = assertPOSTRequest(req);

    JSONArray data = payload.getJSONArray("data");
    assertEquals(2, data.length());
    JSONObject event1 = data.getJSONObject(0);
    assertEquals(2, event1.length());
    assertEquals(0, event1.getInt("a"));
    JSONObject event2 = data.getJSONObject(1);
    assertEquals(2, event2.length());
    assertEquals(1, event2.getInt("a"));

    mockServer.shutdown();
}
 
Example 5
Source File: IndexTests.java    From java-cloudant with Apache License 2.0 6 votes vote down vote up
/**
 * Uses a mock web server to record a _find request using the specified options
 *
 * @param builder query to make
 * @return the JsonElement from the use_index property of the JsonObject POSTed with the request
 * @throws Exception
 */
private JsonElement getUseIndexFromRequest(QueryBuilder builder) throws Exception {
    JsonElement useIndexRequestProperty = null;
    MockWebServer mockWebServer = new MockWebServer();
    // Return 200 OK with empty array of docs (once for each request)
    mockWebServer.enqueue(new MockResponse().setBody("{ \"docs\" : []}"));
    mockWebServer.start();
    try {
        CloudantClient client = CloudantClientHelper.newMockWebServerClientBuilder
                (mockWebServer).build();
        Database db = client.database("mock", false);
        db.query(builder.build(), Movie.class);
        RecordedRequest request = mockWebServer.takeRequest(1, TimeUnit.SECONDS);
        JsonObject body = new Gson().fromJson(request.getBody().readUtf8(), JsonObject.class);
        useIndexRequestProperty = body.get("use_index");
    } finally {
        mockWebServer.shutdown();
    }
    return useIndexRequestProperty;
}
 
Example 6
Source File: ZipkinTests.java    From spring-cloud-sleuth with Apache License 2.0 6 votes vote down vote up
void spansSentToZipkin(MockWebServer zipkin, long traceId)
		throws InterruptedException {
	RecordedRequest request = zipkin.takeRequest();
	List<Span> spans = SpanBytesDecoder.JSON_V2
			.decodeList(request.getBody().readByteArray());
	List<String> traceIdsNotFoundInZipkin = traceIdsNotFoundInZipkin(spans, traceId);
	List<String> serviceNamesNotFoundInZipkin = serviceNamesNotFoundInZipkin(spans);
	List<String> tagsNotFoundInZipkin = hasRequiredTag(spans);
	log.info(String.format("The following trace IDs were not found in Zipkin %s",
			traceIdsNotFoundInZipkin));
	log.info(String.format("The following services were not found in Zipkin %s",
			serviceNamesNotFoundInZipkin));
	log.info(String.format("The following tags were not found in Zipkin %s",
			tagsNotFoundInZipkin));
	then(traceIdsNotFoundInZipkin).isEmpty();
	then(serviceNamesNotFoundInZipkin).isEmpty();
	then(tagsNotFoundInZipkin).isEmpty();
	log.info("Zipkin tracing is working! Sleuth is working! Let's be happy!");
}
 
Example 7
Source File: TrackerTest.java    From snowplow-android-tracker with Apache License 2.0 6 votes vote down vote up
public void testTrackWithoutDataCollection() throws Exception {
    MockWebServer mockWebServer = getMockServer(1);

    Emitter emitter = new Emitter.EmitterBuilder(getMockServerURI(mockWebServer), getContext())
            .option(BufferOption.Single)
            .build();
    emitter.waitForEventStore();

    Tracker tracker = new Tracker.TrackerBuilder(emitter, "myNamespace", "myAppId", getContext())
        .base64(false)
        .level(LogLevel.VERBOSE)
        .sessionContext(false)
        .mobileContext(false)
        .geoLocationContext(false)
        .build();

    tracker.pauseEventTracking();
    tracker.track(ScreenView.builder().build());
    RecordedRequest req = mockWebServer.takeRequest(2, TimeUnit.SECONDS);

    assertEquals(0, tracker.getEmitter().getEventStore().getSize());
    assertNull(req);

    mockWebServer.shutdown();
}
 
Example 8
Source File: WebViewDataTest.java    From focus-android with Mozilla Public License 2.0 6 votes vote down vote up
private void assertPathsHaveBeenRequested(MockWebServer webServer, String... paths) throws InterruptedException {
    final List<String> expectedPaths = new ArrayList<>(paths.length);
    Collections.addAll(expectedPaths, paths);

    RecordedRequest request;

    while ((request = webServer.takeRequest(waitingTime, TimeUnit.MILLISECONDS)) != null) {
        if (!expectedPaths.remove(request.getPath())) {
            throw new AssertionError("Unknown path requested: " + request.getPath());
        }
    }

    if (!expectedPaths.isEmpty()) {
        throw new AssertionError("Expected paths not requested: " + expectedPaths);
    }
}
 
Example 9
Source File: TelemetryInterceptorTest.java    From auth0-java with MIT License 6 votes vote down vote up
@Test
public void shouldNotAddTelemetryHeaderIfDisabled() throws Exception {
    TelemetryInterceptor interceptor = new TelemetryInterceptor(telemetry);
    interceptor.setEnabled(false);
    OkHttpClient client = new OkHttpClient.Builder()
            .addInterceptor(interceptor)
            .build();

    MockWebServer server = new MockWebServer();
    server.start();
    server.enqueue(new MockResponse());

    Request request = new Request.Builder()
            .get()
            .url(server.url("/"))
            .build();
    client.newCall(request).execute();

    RecordedRequest finalRequest = server.takeRequest();
    assertThat(finalRequest.getHeader("Auth0-Client"), is(nullValue()));

    server.shutdown();
}
 
Example 10
Source File: TelemetryInterceptorTest.java    From auth0-java with MIT License 6 votes vote down vote up
@Test
public void shouldAddTelemetryHeaderIfEnabled() throws Exception {
    TelemetryInterceptor interceptor = new TelemetryInterceptor(telemetry);
    interceptor.setEnabled(true);
    OkHttpClient client = new OkHttpClient.Builder()
            .addInterceptor(interceptor)
            .build();

    MockWebServer server = new MockWebServer();
    server.start();
    server.enqueue(new MockResponse());

    Request request = new Request.Builder()
            .get()
            .url(server.url("/"))
            .build();
    client.newCall(request).execute();

    RecordedRequest finalRequest = server.takeRequest();
    assertThat(finalRequest.getHeader("Auth0-Client"), is("ClientInfo"));

    server.shutdown();
}
 
Example 11
Source File: TelemetryInterceptorTest.java    From auth0-java with MIT License 6 votes vote down vote up
@Test
public void shouldAllowToModifyTelemetryOnceSet() throws Exception {
    TelemetryInterceptor interceptor = new TelemetryInterceptor(telemetry);
    Telemetry updatedTelemetry = mock(Telemetry.class);
    when(updatedTelemetry.getValue()).thenReturn("UpdatedClientInfo");
    interceptor.setTelemetry(updatedTelemetry);

    OkHttpClient client = new OkHttpClient.Builder()
            .addInterceptor(interceptor)
            .build();

    MockWebServer server = new MockWebServer();
    server.start();
    server.enqueue(new MockResponse());

    Request request = new Request.Builder()
            .get()
            .url(server.url("/"))
            .build();
    client.newCall(request).execute();

    RecordedRequest finalRequest = server.takeRequest();
    assertThat(finalRequest.getHeader("Auth0-Client"), is("UpdatedClientInfo"));

    server.shutdown();
}
 
Example 12
Source File: EmitterTest.java    From snowplow-android-tracker with Apache License 2.0 5 votes vote down vote up
public void testEmitOnlyFailingEvents() throws InterruptedException, IOException, JSONException {
    Executor.setThreadCount(10);
    Executor.shutdown();

    MockWebServer mockServer = getMockServer();
    getBadEmittableEvents(mockServer, 10);

    new EventStore(getContext(), 5).removeAllEvents();
    Emitter emitter = new Emitter.EmitterBuilder(getMockServerURI(mockServer), getContext())
            .option(BufferOption.Single)
            .method(HttpMethod.GET)
            .tick(1)
            .callback(getCallback())
            .emptyLimit(5)
            .sendLimit(10)
            .build();

    TrackerPayload payload = new TrackerPayload();
    payload.add("key", "value");
    payload.add("e", "pv");

    for (int i = 0; i < 10; i++) {
        emitter.add(payload);
    }
    Thread.sleep(1000);

    for (int i = 0; i < 10; i++) {
        mockServer.takeRequest(20, TimeUnit.SECONDS);
    }

    emitter.getEventStore().removeAllEvents();
    emitter.shutdown();

    mockServer.shutdown();
}
 
Example 13
Source File: EmitterTest.java    From snowplow-android-tracker with Apache License 2.0 5 votes vote down vote up
public void testEmitTwoEventsPostAsSingles() throws InterruptedException, IOException, JSONException {
    MockWebServer mockServer = getMockServer();
    EmittableEvents emittableEvents = getEmittableEvents(mockServer, 2);
    Emitter emitter = getEmitter(getMockServerURI(mockServer), HttpMethod.POST, BufferOption.Single, RequestSecurity.HTTP);

    LinkedList<RequestResult> result = emitter.performAsyncEmit(emitter.buildRequests(emittableEvents));
    assertEquals(2, result.size());
    assertEquals(0, result.getFirst().getEventIds().getFirst().intValue());
    assertEquals(1, result.get(1).getEventIds().getFirst().intValue());

    // Process first request
    RecordedRequest req = mockServer.takeRequest(2, TimeUnit.SECONDS);
    JSONObject payload = assertPOSTRequest(req);

    JSONArray data1 = payload.getJSONArray("data");
    assertEquals(1, data1.length());
    JSONObject event1 = data1.getJSONObject(0);
    assertEquals(2, event1.length());

    // Process second request
    RecordedRequest req2 = mockServer.takeRequest(2, TimeUnit.SECONDS);
    JSONObject payload2 = assertPOSTRequest(req2);

    JSONArray data2 = payload2.getJSONArray("data");
    assertEquals(1, data2.length());
    JSONObject event2 = data2.getJSONObject(0);
    assertEquals(2, event2.length());

    mockServer.shutdown();
}
 
Example 14
Source File: OffersRequestBuilderTest.java    From java-stellar-sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testOffer() throws IOException, InterruptedException {
  MockWebServer mockWebServer = new MockWebServer();
  mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(offerResponse));
  String mockUrl = String.format("http://%s:%d", mockWebServer.getHostName(), mockWebServer.getPort());
  Server server = new Server(mockUrl);
  long offerId = 12345L;
  server.offers().offer(offerId);
  RecordedRequest recordedRequest = mockWebServer.takeRequest();
  assertEquals(String.format("/offers/%s", offerId), recordedRequest.getPath());
}
 
Example 15
Source File: EmitterTest.java    From snowplow-android-tracker with Apache License 2.0 5 votes vote down vote up
public void testEmitOnlySuccessEvents() throws InterruptedException, IOException, JSONException {
    Executor.setThreadCount(10);
    Executor.shutdown();

    MockWebServer mockServer = getMockServer();
    getEmittableEvents(mockServer, 10);

    new EventStore(getContext(), 5).removeAllEvents();
    Emitter emitter = new Emitter.EmitterBuilder(getMockServerURI(mockServer), getContext())
            .option(BufferOption.Single)
            .method(HttpMethod.GET)
            .tick(1)
            .callback(getCallback())
            .emptyLimit(5)
            .sendLimit(10)
            .build();

    TrackerPayload payload = new TrackerPayload();
    payload.add("key", "value");
    payload.add("e", "pv");

    for (int i = 0; i < 10; i++) {
        emitter.add(payload);
    }
    Thread.sleep(1000);

    for (int i = 0; i < 10; i++) {
        mockServer.takeRequest(20, TimeUnit.SECONDS);
    }

    emitter.getEventStore().removeAllEvents();
    emitter.shutdown();

    mockServer.shutdown();
}
 
Example 16
Source File: EmitterTest.java    From snowplow-android-tracker with Apache License 2.0 5 votes vote down vote up
public void testEmitSingleGetEvent() throws InterruptedException, IOException {
    MockWebServer mockServer = getMockServer();
    EmittableEvents emittableEvents = getEmittableEvents(mockServer, 1);
    Emitter emitter = getEmitter(getMockServerURI(mockServer), HttpMethod.GET, BufferOption.Single, RequestSecurity.HTTP);

    LinkedList<RequestResult> result = emitter.performAsyncEmit(emitter.buildRequests(emittableEvents));
    assertEquals(1, result.size());
    assertEquals(0, result.getFirst().getEventIds().getFirst().intValue());

    RecordedRequest req = mockServer.takeRequest(2, TimeUnit.SECONDS);
    assertGETRequest(req);

    mockServer.shutdown();
}
 
Example 17
Source File: SteamDirectoryTest.java    From JavaSteam with MIT License 5 votes vote down vote up
@Test
public void load() throws IOException, InterruptedException {
    MockWebServer server = new MockWebServer();

    server.enqueue(new MockResponse().setBody(IOUtils.toString(
            WebAPITest.class.getClassLoader().getResource("testresponses/GetCMList.vdf"), "UTF-8")));

    server.start();

    final HttpUrl baseUrl = server.url("/");

    SteamConfiguration config = SteamConfiguration.create(new Consumer<ISteamConfigurationBuilder>() {
        @Override
        public void accept(ISteamConfigurationBuilder b) {
            b.withWebAPIBaseAddress(baseUrl.toString());
        }
    });

    List<ServerRecord> servers = SteamDirectory.load(config);

    assertEquals(200, servers.size());

    RecordedRequest request = server.takeRequest();
    assertEquals("/ISteamDirectory/GetCMList/v1?format=vdf&cellid=0", request.getPath());
    assertEquals("GET", request.getMethod());

    server.shutdown();
}
 
Example 18
Source File: ZooniverseClientTest.java    From android-galaxyzoo with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void testMoreItems() throws IOException, InterruptedException, ZooniverseClient.RequestMoreItemsException {
    final MockWebServer server = new MockWebServer();

    final String strResponse = getStringFromStream(
            MoreItemsJsonParserTest.class.getClassLoader().getResourceAsStream("test_more_items_response.json"));
    assertNotNull(strResponse);
    server.enqueue(new MockResponse().setBody(strResponse));
    server.start();

    final ZooniverseClient client = createZooniverseClient(server);

    final int COUNT = 10;
    final List<ZooniverseClient.Subject> subjects = client.requestMoreItemsSync(TEST_GROUP_ID, COUNT);
    assertNotNull(subjects);
    assertEquals(COUNT, subjects.size());

    final ZooniverseClient.Subject subject = subjects.get(0);
    assertNotNull(subject);

    assertNotNull(subject.getId());
    assertEquals("16216418", subject.getId());

    // This is apparently always null in the JSON.
    // assertNotNull(subject.getZooniverseId());
    // assertEquals("AGZ00081ls", subject.getZooniverseId());

    // TODO
    // assertNotNull(subject.getGroupId());
    // assertEquals(TEST_GROUP_ID, subject.getGroupId());

    assertNotNull(subject.getLocationStandard());
    assertEquals("https://panoptes-uploads.zooniverse.org/production/subject_location/772f8b1b-b0fe-4dac-9afe-472f3e8d381a.jpeg",
            subject.getLocationStandard());
    /* TODO:
    assertNotNull(subject.getLocationThumbnail());
    assertEquals("http://www.galaxyzoo.org.s3.amazonaws.com/subjects/thumbnail/goods_full_n_27820_thumbnail.jpg",
            subject.getLocationThumbnail());
    assertNotNull(subject.getLocationInverted());
    assertEquals("http://www.galaxyzoo.org.s3.amazonaws.com/subjects/inverted/goods_full_n_27820_inverted.jpg",
            subject.getLocationInverted());
    */


    //Test what the server received:
    assertEquals(1, server.getRequestCount());
    final RecordedRequest request = server.takeRequest();
    assertEquals("GET", request.getMethod());

    //ZooniverseClient uses one of several possible group IDs at random:
    //See com.murrayc.galaxyzoo.app.provider.Config
    // TODO: Use more.  /subjects/queued?http_cache=true&workflow_id=5853fab395ad361930000003&limit=5
    final String possiblePath1 = "/subjects/queued?http_cache=true&workflow_id=" + TEST_GROUP_ID + "&limit=5";
    final String possiblePath2 = "/subjects/queued?http_cache=true&workflow_id=" + Config.SUBJECT_GROUP_ID_GAMA_15 + "&limit=5";

    //TODO: Can we use this?
    // assertThat(request.getPath(), anyOf(is(possiblePath1), is(possiblePath2)));
    final String path = request.getPath();
    assertEquals(possiblePath1, path);
    assertTrue( path.equals(possiblePath1) || path.equals(possiblePath2));

    server.shutdown();
}
 
Example 19
Source File: ExternalVolumeTest.java    From marathon-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testExternalVolumes() throws Exception {
    final MockWebServer server = new MockWebServer();
    final String mockResponse = "{\"container\": {\"volumes\": [" +
            "{\"containerPath\":\"/data/db\",\"mode\":\"RW\",\"external\":" +
            "{\"name\":\"mongodb-testvol\",\"provider\":\"dvdi\",\"options\":" +
            "{\"dvdi/driver\":\"rexray\"}}}]}}";

    try {
        server.enqueue(new MockResponse().setBody(mockResponse));
        server.start();
        Marathon client = MarathonClient.getInstance(server.url("/").toString());

        App app = new App();
        app.setId("mongo");
        app.setCpus(1.0);
        app.setMem(256.0);
        app.setContainer(new Container());
        app.getContainer().setDocker(new Docker());
        app.getContainer().getDocker().setImage("mongo");
        app.getContainer().setVolumes(new ArrayList<Volume>());

        ExternalVolume externalVolume = new ExternalVolume();
        externalVolume.setName("mongodb-testvol");
        externalVolume.setMode("RW");
        externalVolume.setContainerPath("/data/db");
        externalVolume.setProvider("dvdi");
        externalVolume.setDriver("rexray");

        app.getContainer().getVolumes().add(externalVolume);

        final App appRes = client.createApp(app);
        assertFalse(appRes.getContainer().getVolumes().isEmpty());

        ExternalVolume responseVolume = (ExternalVolume) appRes.getContainer().getVolumes().iterator().next();
        assertEquals("mongodb-testvol", responseVolume.getExternalVolumeInfo().getName());

        RecordedRequest request = server.takeRequest();
        assertNotNull(request);

        final String requestBody = request.getBody().readUtf8();
        assertNotNull(requestBody);

        // request to JSON
        JsonObject requestPayload = new Gson().fromJson(requestBody, JsonObject.class);
        assertNotNull(requestPayload);
        JsonObject requestVolume = requestPayload.getAsJsonObject("container").getAsJsonArray("volumes").get(0).getAsJsonObject();
        assertNotNull(requestVolume);
        assertEquals("RW", requestVolume.get("mode").getAsString());
        assertEquals("/data/db", requestVolume.get("containerPath").getAsString());
    } finally {
        server.shutdown();
    }
}
 
Example 20
Source File: ZooniverseClientTest.java    From android-galaxyzoo with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void testUploadWithSuccess() throws IOException, InterruptedException, ZooniverseClient.UploadException {
    final MockWebServer server = new MockWebServer();


    final MockResponse response = new MockResponse();
    response.setResponseCode(HttpURLConnection.HTTP_CREATED);
    response.setBody("TODO");
    server.enqueue(response);
    server.start();

    final ZooniverseClient client = createZooniverseClient(server);

    //SyncAdapter.doUploadSync() adds an "interface" parameter too,
    //but we are testing a more generic API here:
    final List<HttpUtils.NameValuePair> values = new ArrayList<>();
    values.add(new HttpUtils.NameValuePair("classification[subject_ids][]", "504e4a38c499611ea6010c6a"));
    values.add(new HttpUtils.NameValuePair("classification[favorite][]", "true"));
    values.add(new HttpUtils.NameValuePair("classification[annotations][0][sloan-0]", "a-0"));
    values.add(new HttpUtils.NameValuePair("classification[annotations][1][sloan-7]", "a-1"));
    values.add(new HttpUtils.NameValuePair("classification[annotations][2][sloan-5]", "a-0"));
    values.add(new HttpUtils.NameValuePair("classification[annotations][3][sloan-6]", "x-5"));

    final boolean result = client.uploadClassificationSync("testAuthName",
            "testAuthApiKey", TEST_GROUP_ID, values);
    assertTrue(result);

    assertEquals(1, server.getRequestCount());

    //This is really just a regression test,
    //so we notice if something changes unexpectedly:
    final RecordedRequest request = server.takeRequest();
    assertEquals("POST", request.getMethod());
    assertEquals("/workflows/" + TEST_GROUP_ID + "/classifications", request.getPath());
    assertNotNull(request.getHeader("Authorization"));
    assertEquals("application/x-www-form-urlencoded", request.getHeader("Content-Type"));

    final Buffer contents = request.getBody();
    final String strContents = contents.readUtf8();
    assertEquals("classification%5Bsubject_ids%5D%5B%5D=504e4a38c499611ea6010c6a&classification%5Bfavorite%5D%5B%5D=true&classification%5Bannotations%5D%5B0%5D%5Bsloan-0%5D=a-0&classification%5Bannotations%5D%5B1%5D%5Bsloan-7%5D=a-1&classification%5Bannotations%5D%5B2%5D%5Bsloan-5%5D=a-0&classification%5Bannotations%5D%5B3%5D%5Bsloan-6%5D=x-5",
            strContents);

    server.shutdown();
}