Skip to content

Commit 8206744

Browse files
committed
Delete @delete test for Javalin
1 parent 235c400 commit 8206744

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

examples/example-javalin/src/main/java/org/example/myapp/web/HelloController.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
import java.time.LocalDate;
1818
import java.util.ArrayList;
1919
import java.util.List;
20+
import java.util.Objects;
2021

22+
import static java.util.Objects.nonNull;
23+
import static java.util.Objects.requireNonNull;
2124
import static org.example.myapp.web.AppRoles.ADMIN;
2225

2326
/**
@@ -38,6 +41,12 @@ class HelloController {
3841
this.myService = myService;
3942
}
4043

44+
@Produces(MediaType.TEXT_PLAIN)
45+
@Get("message")
46+
String getPlainMessage() {
47+
return "hello world";
48+
}
49+
4150
/**
4251
* Return the Hello DTO.
4352
*
@@ -85,6 +94,9 @@ HelloDto post(HelloDto dto) {
8594
void saveBean(String foo, HelloDto dto, Context context) {
8695
// save hello data ...
8796
System.out.println("save " + foo + " dto:" + dto);
97+
requireNonNull(foo);
98+
requireNonNull(dto);
99+
requireNonNull(context);
88100
}
89101

90102
/**
@@ -121,9 +133,4 @@ void deleteById(int id) {
121133
System.out.println("deleting " + id);
122134
}
123135

124-
@Produces(MediaType.TEXT_PLAIN)
125-
@Get("message")
126-
String getPlainMessage() {
127-
return "hello world";
128-
}
129136
}

examples/example-javalin/src/main/resources/public/openapi.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,35 @@
365365
}
366366
}
367367
},
368+
"/hello/saveform3" : {
369+
"post" : {
370+
"tags" : [ ],
371+
"summary" : "",
372+
"description" : "",
373+
"requestBody" : {
374+
"content" : {
375+
"application/x-www-form-urlencoded" : {
376+
"schema" : {
377+
"$ref" : "#/components/schemas/HelloForm"
378+
}
379+
}
380+
},
381+
"required" : true
382+
},
383+
"responses" : {
384+
"201" : {
385+
"description" : "",
386+
"content" : {
387+
"application/json" : {
388+
"schema" : {
389+
"$ref" : "#/components/schemas/HelloDto"
390+
}
391+
}
392+
}
393+
}
394+
}
395+
}
396+
},
368397
"/hello/{id}" : {
369398
"delete" : {
370399
"tags" : [ ],

examples/example-javalin/src/test/java/org/example/myapp/HelloControllerTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,11 @@ void postForm3_controllerFormBean_responseJsonDto() {
9393
.body("id", equalTo(52))
9494
.statusCode(201);
9595
}
96+
97+
@Test
98+
void delete() {
99+
given().delete(baseUrl + "/hello/52")
100+
.then()
101+
.statusCode(204);
102+
}
96103
}

0 commit comments

Comments
 (0)