|
@@ -44,26 +44,29 @@ public class IdControllerTest {
|
44
|
44
|
public void getIdsSuccess() throws IOException {
|
45
|
45
|
String response = new Id("userId", "name", "githubId").toString().replace("\n", "");
|
46
|
46
|
|
47
|
|
- wireMockServer.stubFor(
|
|
47
|
+ wireMockServer.stubFor(
|
48
|
48
|
get(urlEqualTo("/ids"))
|
49
|
49
|
.willReturn(aResponse().withStatus(200).withBody(response))
|
50
|
50
|
);
|
51
|
51
|
|
52
|
|
- HttpResponse result = urlClient.client.execute(new HttpGet(urlClient.baseUrl + "/ids"));
|
|
52
|
+// HttpResponse result = urlClient.client.execute(new HttpGet(urlClient.baseUrl + "/ids"));
|
53
|
53
|
|
54
|
|
- assertEquals(result.getStatusLine().getStatusCode(), 200);
|
55
|
|
- assertEquals(urlClient.readCalls(result), response);
|
|
54
|
+ HttpResponse output = ic.get_ids();
|
|
55
|
+
|
|
56
|
+ assertEquals(output.getStatusLine().getStatusCode(), 200);
|
|
57
|
+ assertEquals(urlClient.readCalls(output), response);
|
56
|
58
|
}
|
57
|
59
|
|
58
|
60
|
@Test
|
59
|
61
|
public void testGetIdFail() throws IOException {
|
60
|
|
- // No body sent
|
|
62
|
+
|
61
|
63
|
wireMockServer.stubFor(
|
62
|
64
|
get(urlEqualTo("/ids"))
|
63
|
65
|
.willReturn(aResponse().withStatus(404))
|
64
|
66
|
);
|
65
|
67
|
|
66
|
|
- HttpResponse result = urlClient.client.execute(new HttpGet(urlClient.baseUrl + "/ids"));
|
|
68
|
+ HttpResponse result = ic.get_ids();
|
|
69
|
+// HttpResponse result = ic.get_ids();
|
67
|
70
|
assertEquals(result.getStatusLine().getStatusCode(), 404);
|
68
|
71
|
}
|
69
|
72
|
|
|
@@ -80,7 +83,17 @@ public class IdControllerTest {
|
80
|
83
|
|
81
|
84
|
@Test
|
82
|
85
|
public void testGetSpecificIds() {
|
|
86
|
+ String response = "nullId";
|
83
|
87
|
|
|
88
|
+ wireMockServer.stubFor(
|
|
89
|
+ get(urlEqualTo("/ids/githubId"))
|
|
90
|
+ .willReturn(aResponse().withStatus(200).withBody(response))
|
|
91
|
+ );
|
|
92
|
+
|
|
93
|
+ HttpResponse result = ic.getSpecificId("githubId");
|
|
94
|
+
|
|
95
|
+ assertEquals(result.getStatusLine().getStatusCode(), 200);
|
|
96
|
+ assertEquals(urlClient.readCalls(result), response);
|
84
|
97
|
|
85
|
98
|
}
|
86
|
99
|
}
|