From cae18e206ddb5e151e89c39f4a22c525192f5cbf Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Fri, 26 Nov 2021 18:48:17 +0100 Subject: [PATCH] Remove redundant api prefix path --- .../java/io/volvox/chats/ChatResource.java | 4 +- .../src/main/resources/application.properties | 2 + .../io/volvox/chats/ChatsEndpointTest.java | 20 +- .../main/java/io/volvox/td/TdResource.java | 2 +- .../java/io/volvox/td/TdSessionResource.java | 2 +- .../resources/META-INF/resources/index.html | 175 ------------------ .../src/main/resources/application.properties | 2 + .../java/io/volvox/td/TdResourceTest.java | 10 +- 8 files changed, 23 insertions(+), 194 deletions(-) delete mode 100644 service-td/src/main/resources/META-INF/resources/index.html diff --git a/service-chats/src/main/java/io/volvox/chats/ChatResource.java b/service-chats/src/main/java/io/volvox/chats/ChatResource.java index 4cd1454..3ef9e15 100644 --- a/service-chats/src/main/java/io/volvox/chats/ChatResource.java +++ b/service-chats/src/main/java/io/volvox/chats/ChatResource.java @@ -17,7 +17,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/api/chats") +@Path("/chats") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public class ChatResource { @@ -39,7 +39,7 @@ public class ChatResource { @POST public Uni create(Chat chat) { return Panache.withTransaction(() -> chatRepository.persist(chat)) - .onItem().transform(inserted -> Response.created(URI.create("/api/" + chat.id)).build()); + .onItem().transform(inserted -> Response.created(URI.create("/chats/" + chat.id)).build()); } @PUT diff --git a/service-chats/src/main/resources/application.properties b/service-chats/src/main/resources/application.properties index 7b73292..ba1d2f5 100644 --- a/service-chats/src/main/resources/application.properties +++ b/service-chats/src/main/resources/application.properties @@ -1,3 +1,5 @@ +quarkus.http.port=8282 + %prod.quarkus.datasource.db-kind=postgresql %prod.quarkus.datasource.username=quarkus_test %prod.quarkus.datasource.password=quarkus_test diff --git a/service-chats/src/test/java/io/volvox/chats/ChatsEndpointTest.java b/service-chats/src/test/java/io/volvox/chats/ChatsEndpointTest.java index 7d552c5..f14d795 100644 --- a/service-chats/src/test/java/io/volvox/chats/ChatsEndpointTest.java +++ b/service-chats/src/test/java/io/volvox/chats/ChatsEndpointTest.java @@ -23,7 +23,7 @@ public class ChatsEndpointTest { //List all, should have all 3 usernames the database has initially: Response response = given() .when() - .get("/api/chats") + .get("/chats") .then() .statusCode(200) .contentType("application/json") @@ -35,7 +35,7 @@ public class ChatsEndpointTest { .when() .body("{\"name\" : \"Telegram Official\"}") .contentType("application/json") - .put("/api/chats/777000") + .put("/chats/777000") .then() .statusCode(200) .body( @@ -45,7 +45,7 @@ public class ChatsEndpointTest { //List all, Telegram Official should've replaced Telegram: response = given() .when() - .get("/api/chats") + .get("/chats") .then() .statusCode(200) .contentType("application/json") @@ -56,13 +56,13 @@ public class ChatsEndpointTest { //Delete Telegram: given() .when() - .delete("/api/chats/777000") + .delete("/chats/777000") .then() .statusCode(204); response = given() .when() - .get("/api/chats") + .get("/chats") .then() .statusCode(200) .contentType("application/json") @@ -75,7 +75,7 @@ public class ChatsEndpointTest { .when() .body("{\"id\": \"777001-u\", \"name\" : \"Telegram2\"}") .contentType("application/json") - .post("/api/chats") + .post("/chats") .then() .statusCode(201) .body(emptyString()); @@ -83,7 +83,7 @@ public class ChatsEndpointTest { //List all, Pineapple should be still missing now: response = given() .when() - .get("/api/chats") + .get("/chats") .then() .statusCode(200) .extract().response(); @@ -95,7 +95,7 @@ public class ChatsEndpointTest { public void testEntityNotFoundForDelete() { given() .when() - .delete("/api/chats/777123") + .delete("/chats/777123") .then() .statusCode(404) .body(emptyString()); @@ -107,7 +107,7 @@ public class ChatsEndpointTest { .when() .body("{\"id\": \"777234-u\", \"name\" : \"Juan\"}") .contentType("application/json") - .put("/api/chats/777234") + .put("/chats/777234") .then() .statusCode(200); } @@ -118,7 +118,7 @@ public class ChatsEndpointTest { .when() .body("{\"name\" : \"Juan\"}") .contentType("application/json") - .put("/api/chats/777234") + .put("/chats/777234") .then() .statusCode(500); } diff --git a/service-td/src/main/java/io/volvox/td/TdResource.java b/service-td/src/main/java/io/volvox/td/TdResource.java index 2c1aa72..b2832f7 100644 --- a/service-td/src/main/java/io/volvox/td/TdResource.java +++ b/service-td/src/main/java/io/volvox/td/TdResource.java @@ -6,7 +6,7 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -@Path("/api/td") +@Path("/td") public class TdResource { @Inject TdService tdService; diff --git a/service-td/src/main/java/io/volvox/td/TdSessionResource.java b/service-td/src/main/java/io/volvox/td/TdSessionResource.java index fe5b3a7..83faf17 100644 --- a/service-td/src/main/java/io/volvox/td/TdSessionResource.java +++ b/service-td/src/main/java/io/volvox/td/TdSessionResource.java @@ -14,7 +14,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -@Path("/api/td/session/{sessionId}") +@Path("/td/session/{sessionId}") public class TdSessionResource { @PathParam("sessionId") diff --git a/service-td/src/main/resources/META-INF/resources/index.html b/service-td/src/main/resources/META-INF/resources/index.html deleted file mode 100644 index a59e08f..0000000 --- a/service-td/src/main/resources/META-INF/resources/index.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - - service-td - 1.0.0-SNAPSHOT - - - - - - -
-
-

Congratulations, you have created a new Quarkus cloud application.

- -

What is this page?

- -

This page is served by Quarkus. The source is in - src/main/resources/META-INF/resources/index.html.

- -

What are your next steps?

- -

If not already done, run the application in dev mode using: ./mvnw compile quarkus:dev. -

-
    -
  • Your static assets are located in src/main/resources/META-INF/resources.
  • -
  • Configure your application in src/main/resources/application.properties.
  • -
  • Quarkus now ships with a Dev UI (available in dev mode only)
  • -
  • Play with the provided code located in src/main/java:
  • -
-
-

RESTEasy Reactive

-

Easily start your Reactive RESTful Web Services

-

@Path: /api/td

-

Related guide section...

-
- -
-
-
-

Application

-
    -
  • GroupId: it.volvox.service-td
  • -
  • ArtifactId: service-td
  • -
  • Version: 1.0.0-SNAPSHOT
  • -
  • Quarkus Version: 2.4.1.Final
  • -
-
-
-

Do you like Quarkus?

-
    -
  • Go give it a star on GitHub.
  • -
-
-
-

Selected extensions guides

-
    -
-
- -
-
- - \ No newline at end of file diff --git a/service-td/src/main/resources/application.properties b/service-td/src/main/resources/application.properties index 45fd8d3..fd09bf7 100644 --- a/service-td/src/main/resources/application.properties +++ b/service-td/src/main/resources/application.properties @@ -1 +1,3 @@ +quarkus.http.port=8283 + td.requests.timeout = 10s diff --git a/service-td/src/test/java/io/volvox/td/TdResourceTest.java b/service-td/src/test/java/io/volvox/td/TdResourceTest.java index 4619ff4..0069c1f 100644 --- a/service-td/src/test/java/io/volvox/td/TdResourceTest.java +++ b/service-td/src/test/java/io/volvox/td/TdResourceTest.java @@ -16,7 +16,7 @@ public class TdResourceTest { @Test public void testEmptyList() { given() - .when().get("/api/td/list") + .when().get("/td/list") .then() .statusCode(200) .body(is("")); @@ -25,7 +25,7 @@ public class TdResourceTest { @Test public void testCreateSession() { given() - .when().get("/api/td/create-session") + .when().get("/td/create-session") .then() .statusCode(200) .body(not(emptyOrNullString())); @@ -34,7 +34,7 @@ public class TdResourceTest { @Test public void testCreateMultipleSessions() { var sessionId1 = given() - .when().get("/api/td/create-session") + .when().get("/td/create-session") .then() .statusCode(200) .body(not(emptyOrNullString())) @@ -42,7 +42,7 @@ public class TdResourceTest { .body() .asString(); var sessionId2 = given() - .when().get("/api/td/create-session") + .when().get("/td/create-session") .then() .statusCode(200) .body(not(emptyOrNullString())) @@ -53,7 +53,7 @@ public class TdResourceTest { var expectedBodyElems = Set.of(sessionId1, sessionId2); var bodyElems = Set.of(given() - .when().get("/api/td/list") + .when().get("/td/list") .then() .statusCode(200) .extract()