forked from auth0/auth0-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVoidRequestTest.java
More file actions
48 lines (39 loc) · 1.52 KB
/
VoidRequestTest.java
File metadata and controls
48 lines (39 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.auth0.net;
import com.auth0.client.MockServer;
import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.Before;
import org.junit.Test;
import static com.auth0.client.MockServer.AUTH_TOKENS;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
public class VoidRequestTest {
private OkHttpClient client;
private MockServer server;
@Before
public void setUp() throws Exception {
client = new OkHttpClient();
server = new MockServer();
}
@Test
public void shouldCreateGETRequest() throws Exception {
VoidRequest request = new VoidRequest(client, server.getBaseUrl(), "GET");
assertThat(request, is(notNullValue()));
server.jsonResponse(AUTH_TOKENS, 200);
Void execute = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getMethod(), is("GET"));
assertThat(execute, is(nullValue()));
}
@Test
public void shouldCreatePOSTRequest() throws Exception {
VoidRequest request = new VoidRequest(client, server.getBaseUrl(), "POST");
assertThat(request, is(notNullValue()));
request.addParameter("non_empty", "body");
server.jsonResponse(AUTH_TOKENS, 200);
Void execute = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest.getMethod(), is("POST"));
assertThat(execute, is(nullValue()));
}
}