File tree Expand file tree Collapse file tree 3 files changed +52
-2
lines changed
main/java/com/cae/http_client
test/java/com/cae/http_client Expand file tree Collapse file tree 3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change 77 <description >Meant for enabling applications to use HTTP at ease, without having to compromise the clean state of the overall architecture.</description >
88 <url >https://github.com/clean-arch-enablers-project/cae-utils-http-client/blob/main/README.md</url >
99 <groupId >com.clean-arch-enablers</groupId >
10- <artifactId >http-client</artifactId >
11- <version >1.1.1 </version >
10+ <artifactId >cae- http-client</artifactId >
11+ <version >1.0.0 </version >
1212 <packaging >jar</packaging >
1313 <licenses >
1414 <license >
Original file line number Diff line number Diff line change 1+ package com .cae .http_client ;
2+
3+ import com .cae .http_client .implementations .HttpRequestStarterImplementation ;
4+ import lombok .AccessLevel ;
5+ import lombok .NoArgsConstructor ;
6+
7+ @ NoArgsConstructor (access = AccessLevel .PRIVATE )
8+ public class CaeHttpClientFactory {
9+
10+ public static final HttpRequestStarter REQUEST_STARTER = new HttpRequestStarterImplementation ();
11+
12+ public static HttpRequestStarter getSingletonClient (){
13+ return CaeHttpClientFactory .REQUEST_STARTER ;
14+ }
15+
16+ }
Original file line number Diff line number Diff line change 1+ package com .cae .http_client ;
2+
3+ import org .junit .jupiter .api .Assertions ;
4+ import org .junit .jupiter .api .Test ;
5+ import org .junit .jupiter .api .extension .ExtendWith ;
6+ import org .mockito .junit .jupiter .MockitoExtension ;
7+
8+ @ ExtendWith (MockitoExtension .class )
9+ class CaeHttpClientFactoryTest {
10+
11+ @ Test
12+ void shouldReturnFilledInstance (){
13+ Assertions .assertNotNull (CaeHttpClientFactory .REQUEST_STARTER );
14+ }
15+
16+ @ Test
17+ void shouldReturnSingletonInstanceWhenDirectlyCallingAttribute (){
18+ var resultFromCallOne = CaeHttpClientFactory .REQUEST_STARTER ;
19+ var resultFromCallTwo = CaeHttpClientFactory .REQUEST_STARTER ;
20+ var resultFromCallThree = CaeHttpClientFactory .REQUEST_STARTER ;
21+ Assertions .assertEquals (resultFromCallOne , resultFromCallTwo );
22+ Assertions .assertEquals (resultFromCallTwo , resultFromCallThree );
23+ }
24+
25+ @ Test
26+ void shouldReturnSingletonInstanceWhenCallingGetter (){
27+ var resultFromCallOne = CaeHttpClientFactory .getSingletonClient ();
28+ var resultFromCallTwo = CaeHttpClientFactory .getSingletonClient ();
29+ var resultFromCallThree = CaeHttpClientFactory .getSingletonClient ();
30+ Assertions .assertEquals (resultFromCallOne , resultFromCallTwo );
31+ Assertions .assertEquals (resultFromCallTwo , resultFromCallThree );
32+ }
33+
34+ }
You can’t perform that action at this time.
0 commit comments