Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Added Testing #858

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added request body test for RequestBuilder
elduwa committed Mar 23, 2020
commit 411c92b801f0ff61b695d68392bfe851132616f9
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
import static org.junit.Assert.assertThat;
import static org.opendatakit.briefcase.reused.http.RequestBuilder.url;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -29,6 +30,8 @@

public class RequestBuilderTest {

private static final String TEST_BODY = "{\"query\": \"some-text\" }";

@Test
public void can_compose_multiple_path_parts() {
List<String> baseUrls = Arrays.asList("http://foo.com", "http://foo.com/");
@@ -86,4 +89,11 @@ public void can_resolve_paths() {
is(url("http://foo.com/bar/baz"))
);
}

@Test
public void can_resolve_body(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't belong to this test class because what we're verifying is that the RequestSpy class can read a request body. You don't need a Request object for that.

Request<InputStream> request = RequestBuilder.get("http://foo.com").withBody(TEST_BODY).build();
String body = RequestSpy.read(request.getBody());
assertThat(body, is(TEST_BODY));
}
}