Skip to content

Commit 17a7ae3

Browse files
committed
Update tests with upper case verbs
1 parent e057176 commit 17a7ae3

File tree

6 files changed

+32
-30
lines changed

6 files changed

+32
-30
lines changed

client/src/test/java/io/avaje/http/client/AuthTokenTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public AuthToken obtainToken(HttpClientRequest tokenRequest) {
3232
.url("https://foo/v2/token")
3333
.header("content-type", "application/json")
3434
.body(authRequestAsJson())
35-
.post()
35+
.POST()
3636
.bean(AuthTokenResponse.class);
3737

3838
Instant validUntil = Instant.now().plusSeconds(res.expires_in).minusSeconds(60);
@@ -58,14 +58,14 @@ void sendEmail() {
5858
.path(path)
5959
.header("Content-Type", "application/json")
6060
//.body(payload)
61-
.post()
61+
.POST()
6262
.asString();
6363

6464
HttpResponse<String> res2 = ctx.request()
6565
.path(path)
6666
.header("Content-Type", "application/json")
6767
//.body(payload)
68-
.post()
68+
.POST()
6969
.asString();
7070

7171
}

client/src/test/java/io/avaje/http/client/HelloControllerTest.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import java.util.Map;
1010

1111
import static org.assertj.core.api.Assertions.assertThat;
12-
import static org.junit.jupiter.api.Assertions.assertEquals;
13-
import static org.junit.jupiter.api.Assertions.assertNotNull;
14-
import static org.junit.jupiter.api.Assertions.fail;
12+
import static org.junit.jupiter.api.Assertions.*;
1513

1614
class HelloControllerTest extends BaseWebTest {
1715

@@ -22,7 +20,7 @@ void get_helloMessage() {
2220

2321
final HttpResponse<String> hres = clientContext.request()
2422
.path("hello").path("message")
25-
.get().asString();
23+
.GET().asString();
2624

2725
assertThat(hres.body()).contains("hello world");
2826
assertThat(hres.statusCode()).isEqualTo(200);
@@ -34,7 +32,7 @@ void get_helloMessage_via_url() {
3432
final HttpResponse<String> hres = clientContext.request()
3533
.url("http://127.0.0.1:8887")
3634
.path("hello").path("message")
37-
.get().asString();
35+
.GET().asString();
3836

3937
assertThat(hres.body()).contains("hello world");
4038
assertThat(hres.statusCode()).isEqualTo(200);
@@ -45,7 +43,7 @@ void get_hello_returningListOfBeans() {
4543

4644
final List<HelloDto> helloDtos = clientContext.request()
4745
.path("hello")
48-
.get().list(HelloDto.class);
46+
.GET().list(HelloDto.class);
4947

5048
assertThat(helloDtos).hasSize(2);
5149
}
@@ -54,8 +52,9 @@ void get_hello_returningListOfBeans() {
5452
void get_withPathParamAndQueryParam_returningBean() {
5553

5654
final HelloDto dto = clientContext.request()
57-
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", (String) null)
58-
.get().bean(HelloDto.class);
55+
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", null)
56+
.GET()
57+
.bean(HelloDto.class);
5958

6059
assertThat(dto.id).isEqualTo(43L);
6160
assertThat(dto.name).isEqualTo("2020-03-05");
@@ -73,7 +72,7 @@ void post_bean_returningBean_usingExplicitConverters() {
7372
final HelloDto bean = clientContext.request()
7473
.path("hello")
7574
.body(from.write(dto))
76-
.post()
75+
.POST()
7776
.read(toDto);
7877

7978
assertEquals("posted", bean.name);
@@ -87,7 +86,8 @@ void post_bean_returningVoid() {
8786

8887
final HttpResponse<Void> res = clientContext.request()
8988
.path("hello/savebean/foo")
90-
.body(dto).post()
89+
.body(dto)
90+
.POST()
9191
.asDiscarding();
9292

9393
assertThat(res.statusCode()).isEqualTo(201);
@@ -102,7 +102,7 @@ void postForm() {
102102
.formParam("email", "user@foo.com")
103103
.formParam("url", "http://foo.com")
104104
.formParam("startDate", "2030-12-03")
105-
.post()
105+
.POST()
106106
.asDiscarding();
107107

108108
assertThat(res.statusCode()).isEqualTo(201);
@@ -117,7 +117,7 @@ void postForm_returningBean() {
117117
.formParam("email", "user@foo.com")
118118
.formParam("url", "http://foo.com")
119119
.formParam("startDate", "2030-12-03")
120-
.post()
120+
.POST()
121121
.asDiscarding();
122122

123123
assertThat(res.statusCode()).isEqualTo(201);
@@ -128,7 +128,7 @@ void postForm_returningBean() {
128128
.formParam("email", "Bax@foo.com")
129129
.formParam("url", "http://foo.com")
130130
.formParam("startDate", "2030-12-03")
131-
.post()
131+
.POST()
132132
.bean(HelloDto.class);
133133

134134
assertThat(bean.name).isEqualTo("Bax");
@@ -143,7 +143,7 @@ void postForm_asVoid_validResponse() {
143143
.formParam("name", "baz")
144144
.formParam("email", "user@foo.com")
145145
.formParam("url", "http://foo")
146-
.post()
146+
.POST()
147147
.asVoid();
148148

149149
assertEquals(201, res.statusCode());
@@ -156,7 +156,7 @@ void postForm_asVoid_invokesValidation_expect_badRequest_extractError() {
156156
.path("hello/saveform")
157157
.formParam("email", "user@foo.com")
158158
.formParam("url", "notAValidUrl")
159-
.post()
159+
.POST()
160160
.asVoid();
161161

162162
fail();
@@ -183,7 +183,7 @@ void postForm_asBytes_validation_expect_badRequest_extractError() {
183183
.path("hello/saveform")
184184
.formParam("email", "user@foo.com")
185185
.formParam("url", "notAValidUrl")
186-
.post().asVoid();
186+
.POST().asVoid();
187187

188188
fail();
189189

@@ -212,7 +212,8 @@ void delete() {
212212
final HttpResponse<Void> res =
213213
clientContext.request()
214214
.path("hello/52")
215-
.delete().asDiscarding();
215+
.DELETE()
216+
.asDiscarding();
216217

217218
assertThat(res.statusCode()).isEqualTo(204);
218219
}
@@ -226,7 +227,8 @@ void get_withMatrixParam() {
226227
.matrixParam("country", "nz")
227228
.path("foo")
228229
.queryParam("extra", "banana")
229-
.get().asString();
230+
.GET()
231+
.asString();
230232

231233
assertEquals(200, httpRes.statusCode());
232234
assertEquals("yr:2011 au:rob co:nz other:foo extra:banana", httpRes.body());

client/src/test/java/io/avaje/http/client/RetryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void retryTest() {
2525

2626
HttpResponse<String> res = clientContext.request()
2727
.path("hello/retry")
28-
.get()
28+
.GET()
2929
.asString();
3030

3131
assertThat(res.body()).isEqualTo("All good at 3rd attempt");

client/src/test/java/io/avaje/http/client/UrlBuilderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void matrixParam_path() {
6363

6464
@Test
6565
void param() {
66-
assertThat(foo().queryParam("bar", (String) null).build()).isEqualTo("https://foo");
66+
assertThat(foo().queryParam("bar", null).build()).isEqualTo("https://foo");
6767
assertThat(foo().queryParam("bar", "a").build()).isEqualTo("https://foo?bar=a");
6868
assertThat(foo().queryParam("bar", "a").queryParam("baz", "b").build()).isEqualTo("https://foo?bar=a&baz=b");
6969
}
@@ -75,7 +75,7 @@ void param_encode() {
7575

7676
@Test
7777
void queryParam_when_null() {
78-
assertThat(foo().queryParam("bar", (String) null).build()).isEqualTo("https://foo");
78+
assertThat(foo().queryParam("bar", null).build()).isEqualTo("https://foo");
7979
assertThat(foo().queryParam("bar", (Boolean) null).build()).isEqualTo("https://foo");
8080
assertThat(foo().queryParam("bar", (Integer) null).build()).isEqualTo("https://foo");
8181
assertThat(foo().queryParam("bar", (Long) null).build()).isEqualTo("https://foo");

client/src/test/java/io/avaje/http/client/VerbTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void post() {
2323

2424
HttpResponse<String> res2 = clientContext.request()
2525
.path("post")
26-
.post()
26+
.POST()
2727
.asString();
2828

2929
assertThat(res2.body()).isEqualTo("post");
@@ -41,7 +41,7 @@ void put() {
4141

4242
HttpResponse<String> res2 = clientContext.request()
4343
.path("put")
44-
.put()
44+
.PUT()
4545
.asString();
4646

4747
assertThat(res2.body()).isEqualTo("put");

client/src/test/java/org/example/github/SimpleHttpClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public List<Repo> listRepos(String user, String other) throws HttpException {
2929
return context.request()
3030
.path("users").path(user).path("repos")
3131
.queryParam("other", other)
32-
.get().list(Repo.class);
32+
.GET().list(Repo.class);
3333
}
3434

3535
@Post("users")
@@ -38,23 +38,23 @@ public Repo post(Repo repo) throws HttpException {
3838
return context.request()
3939
.path("foo/users")
4040
.body(writeRepo.write(repo))
41-
.post().read(readRepo);
41+
.POST().read(readRepo);
4242
}
4343

4444
@Get("users/{id}")
4545
@Override
4646
public Repo getById(String id) {
4747
return context.request()
4848
.path("users").path(id)
49-
.get().bean(Repo.class);
49+
.GET().bean(Repo.class);
5050
}
5151

5252
public InputStream getById2(String id, InputStream is) {
5353
final HttpResponse<InputStream> response =
5454
context.request()
5555
.path("users").path(id).path("stream")
5656
.body(() -> is)
57-
.get().withResponseHandler(HttpResponse.BodyHandlers.ofInputStream());
57+
.GET().withResponseHandler(HttpResponse.BodyHandlers.ofInputStream());
5858

5959
context.checkResponse(response);
6060
return response.body();

0 commit comments

Comments
 (0)