-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : handle service calls efficiently
- Loading branch information
1 parent
9f77cbb
commit aed94f9
Showing
11 changed files
with
103 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...boot-http-proxy/src/main/java/com/example/rest/proxy/exception/PostNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example.rest.proxy.exception; | ||
|
||
import java.net.URI; | ||
import java.time.Instant; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ProblemDetail; | ||
import org.springframework.web.ErrorResponseException; | ||
|
||
public class PostNotFoundException extends ErrorResponseException { | ||
|
||
public PostNotFoundException(Long id) { | ||
super(HttpStatus.NOT_FOUND, asProblemDetail(id), null); | ||
} | ||
|
||
private static ProblemDetail asProblemDetail(Long id) { | ||
ProblemDetail problemDetail = | ||
ProblemDetail.forStatusAndDetail( | ||
HttpStatus.NOT_FOUND, "Post with Id '%d' not found".formatted(id)); | ||
problemDetail.setTitle("Post Not Found"); | ||
problemDetail.setType(URI.create("http://api.posts.com/errors/not-found")); | ||
problemDetail.setProperty("errorCategory", "Generic"); | ||
problemDetail.setProperty("timestamp", Instant.now()); | ||
return problemDetail; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
...ents/boot-http-proxy/src/test/java/com/example/rest/proxy/ApplicationIntegrationTest.java
This file was deleted.
Oops, something went wrong.
18 changes: 14 additions & 4 deletions
18
httpClients/boot-http-proxy/src/test/java/com/example/rest/proxy/TestApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
package com.example.rest.proxy; | ||
|
||
import com.example.rest.proxy.config.DBTestContainersConfiguration; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.devtools.restart.RestartScope; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection; | ||
import org.springframework.context.annotation.Bean; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
|
||
@TestConfiguration(proxyBeanMethods = false) | ||
public class TestApplication { | ||
|
||
@Bean | ||
@ServiceConnection | ||
@RestartScope | ||
PostgreSQLContainer<?> postgresContainer() { | ||
return new PostgreSQLContainer<>("postgres:16.0-alpine"); | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.from(Application::main) | ||
.with(DBTestContainersConfiguration.class) | ||
.run(args); | ||
SpringApplication.from(Application::main).with(TestApplication.class).run(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
...http-proxy/src/test/java/com/example/rest/proxy/config/DBTestContainersConfiguration.java
This file was deleted.
Oops, something went wrong.
95 changes: 0 additions & 95 deletions
95
...lients/boot-http-proxy/src/test/java/com/example/rest/proxy/services/PostServiceTest.java
This file was deleted.
Oops, something went wrong.