Skip to content

Refact/rename #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Welcome to the _cae-utils-http-client_ repository! The _cae-utils-http-client_ i

<dependency>
<groupId>com.clean-arch-enablers</groupId>
<artifactId>http-client</artifactId>
<artifactId>cae-http-client</artifactId>
<version>${version}</version>
</dependency>

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<description>Meant for enabling applications to use HTTP at ease, without having to compromise the clean state of the overall architecture.</description>
<url>https://github.com/clean-arch-enablers-project/cae-utils-http-client/blob/main/README.md</url>
<groupId>com.clean-arch-enablers</groupId>
<artifactId>http-client</artifactId>
<version>1.1.1</version>
<artifactId>cae-http-client</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<licenses>
<license>
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/cae/http_client/CaeHttpClientFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.cae.http_client;

import com.cae.http_client.implementations.HttpRequestStarterImplementation;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CaeHttpClientFactory {

public static final HttpRequestStarter REQUEST_STARTER = new HttpRequestStarterImplementation();

public static HttpRequestStarter getSingletonClient(){
return CaeHttpClientFactory.REQUEST_STARTER;
}

}
34 changes: 34 additions & 0 deletions src/test/java/com/cae/http_client/CaeHttpClientFactoryTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.cae.http_client;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class CaeHttpClientFactoryTest {

@Test
void shouldReturnFilledInstance(){
Assertions.assertNotNull(CaeHttpClientFactory.REQUEST_STARTER);
}

@Test
void shouldReturnSingletonInstanceWhenDirectlyCallingAttribute(){
var resultFromCallOne = CaeHttpClientFactory.REQUEST_STARTER;
var resultFromCallTwo = CaeHttpClientFactory.REQUEST_STARTER;
var resultFromCallThree = CaeHttpClientFactory.REQUEST_STARTER;
Assertions.assertEquals(resultFromCallOne, resultFromCallTwo);
Assertions.assertEquals(resultFromCallTwo, resultFromCallThree);
}

@Test
void shouldReturnSingletonInstanceWhenCallingGetter(){
var resultFromCallOne = CaeHttpClientFactory.getSingletonClient();
var resultFromCallTwo = CaeHttpClientFactory.getSingletonClient();
var resultFromCallThree = CaeHttpClientFactory.getSingletonClient();
Assertions.assertEquals(resultFromCallOne, resultFromCallTwo);
Assertions.assertEquals(resultFromCallTwo, resultFromCallThree);
}

}
Loading