-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: resolv spring build with feign module
- Loading branch information
Showing
16 changed files
with
261 additions
and
28 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
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
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,95 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>modular-architecture</artifactId> | ||
<groupId>br.com.helpdev</groupId> | ||
<version>0.0.4-SNAPSHOT</version> | ||
<relativePath>../../../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>feign-http-services</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<coverage.exclude.code>**/*Dto.*</coverage.exclude.code> | ||
<mutation.excluded.code>**.dto.*</mutation.excluded.code> | ||
<feign-jaxrs.version>12.1</feign-jaxrs.version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>${spring-cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>javax.ws.rs</groupId> | ||
<artifactId>javax.ws.rs-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-openfeign</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>feign-jaxrs</artifactId> | ||
<version>${feign-jaxrs.version}</version> | ||
</dependency> | ||
|
||
<!-- Project dependencies--> | ||
<dependency> | ||
<groupId>br.com.helpdev</groupId> | ||
<artifactId>use-case</artifactId> | ||
</dependency> | ||
|
||
<!-- Tests dependencies --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-junit-jupiter</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
</project> |
27 changes: 27 additions & 0 deletions
27
...-http-services/src/main/java/br/com/helpdev/output/feign/ProtocolGeneratorClientImpl.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,27 @@ | ||
package br.com.helpdev.output.feign; | ||
|
||
|
||
import br.com.helpdev.output.feign.client.RandomDataApiClient; | ||
import br.com.helpdev.usecase.port.ProtocolGeneratorClient; | ||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
@ApplicationScoped | ||
@Named | ||
public class ProtocolGeneratorClientImpl implements ProtocolGeneratorClient { | ||
|
||
private final RandomDataApiClient randomDataApiClient; | ||
|
||
@Inject | ||
public ProtocolGeneratorClientImpl(final RandomDataApiClient randomDataApiClient) { | ||
this.randomDataApiClient = randomDataApiClient; | ||
} | ||
|
||
@Override | ||
public String generateNewProtocol() { | ||
/* Generate US-SSN to simulate protocol */ | ||
return randomDataApiClient.generate().getValidUsSsn(); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...n-http-services/src/main/java/br/com/helpdev/output/feign/client/RandomDataApiClient.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,14 @@ | ||
package br.com.helpdev.output.feign.client; | ||
|
||
import br.com.helpdev.output.feign.client.dto.RandomIdNumberDto; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Produces; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
|
||
@FeignClient(name = "random-data-api", url = "${random-data-api.url}", path = "/api/id_number/random_id_number") | ||
public interface RandomDataApiClient { | ||
|
||
@GET | ||
@Produces("application/json") | ||
RandomIdNumberDto generate(); | ||
} |
14 changes: 14 additions & 0 deletions
14
...http-services/src/main/java/br/com/helpdev/output/feign/client/dto/RandomIdNumberDto.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,14 @@ | ||
package br.com.helpdev.output.feign.client.dto; | ||
|
||
import com.fasterxml.jackson.databind.PropertyNamingStrategy; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
import lombok.Data; | ||
|
||
@Data | ||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | ||
public class RandomIdNumberDto { | ||
private String id; | ||
private String uid; | ||
private String validUsSsn; | ||
private String invalidUsSsn; | ||
} |
21 changes: 21 additions & 0 deletions
21
...services/src/main/java/br/com/helpdev/output/feign/config/FeignContractConfiguration.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,21 @@ | ||
package br.com.helpdev.output.feign.config; | ||
|
||
import feign.Contract; | ||
import feign.jaxrs.JAXRSContract; | ||
import org.springframework.cloud.openfeign.EnableFeignClients; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
|
||
@Configuration | ||
@EnableFeignClients( | ||
basePackages = {"br.com.helpdev.output.feign"} | ||
) | ||
public class FeignContractConfiguration { | ||
|
||
@Bean | ||
Contract contract() { | ||
return new JAXRSContract(); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...p-services/src/test/java/br/com/helpdev/output/feign/ProtocolGeneratorClientImplTest.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,37 @@ | ||
package br.com.helpdev.output.feign; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import br.com.helpdev.output.feign.client.RandomDataApiClient; | ||
import br.com.helpdev.output.feign.client.dto.RandomIdNumberDto; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ProtocolGeneratorClientImplTest { | ||
|
||
@Mock | ||
private RandomDataApiClient randomDataApiClient; | ||
|
||
@InjectMocks | ||
private ProtocolGeneratorClientImpl protocolGeneratorClient; | ||
|
||
@Test | ||
void shouldGeneratedProtocolWithSuccess() { | ||
final var randomIdNumberDto = mock(RandomIdNumberDto.class); | ||
final var expectedProtocol = "xpto"; | ||
|
||
when(randomDataApiClient.generate()).thenReturn(randomIdNumberDto); | ||
when(randomIdNumberDto.getValidUsSsn()).thenReturn(expectedProtocol); | ||
|
||
final var result = protocolGeneratorClient.generateNewProtocol(); | ||
|
||
Assertions.assertThat(result).isEqualTo(expectedProtocol); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...ices/src/test/java/br/com/helpdev/output/feign/config/FeignContractConfigurationTest.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,24 @@ | ||
package br.com.helpdev.output.feign.config; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import feign.jaxrs.JAXRSContract; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class FeignContractConfigurationTest { | ||
@InjectMocks | ||
private FeignContractConfiguration feignContractConfiguration; | ||
|
||
@Test | ||
void shouldGeneratedNonNullJaxRsContract() { | ||
final var contract = feignContractConfiguration.contract(); | ||
|
||
assertThat(contract) | ||
.isInstanceOf(JAXRSContract.class) | ||
.isNotNull(); | ||
} | ||
} |
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
16 changes: 0 additions & 16 deletions
16
app/spring-app/src/main/java/br/com/helpdev/protocolgenerator/FakeProtocolGenerator.java
This file was deleted.
Oops, something went wrong.
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