Skip to content

Commit 01a9acc

Browse files
committed
Commit Inicial
1 parent e3a1e96 commit 01a9acc

File tree

137 files changed

+5726
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+5726
-17
lines changed

.gitignore

100644100755
+29-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1-
# Compiled class file
2-
*.class
1+
target/
2+
.mvn/
33

4-
# Log file
5-
*.log
4+
application-*.yml
65

7-
# BlueJ files
8-
*.ctxt
6+
### STS ###
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
912

10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
13+
### IntelliJ IDEA ###
14+
.idea
15+
*.iws
16+
*.iml
17+
*.ipr
1218

13-
# Package Files #
14-
*.jar
15-
*.war
16-
*.ear
17-
*.zip
18-
*.tar.gz
19-
*.rar
19+
### NetBeans ###
20+
nbproject/private/
21+
build/
22+
nbbuild/
23+
dist/
24+
nbdist/
25+
.nb-gradle/
2026

21-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22-
hs_err_pid*
27+
gradle
28+
.gradle/
29+
gradlew
30+
31+
### Application ###
32+
backup-temp/
33+
mocks-prod
34+
fake-api-data

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Mock API
2+
3+
App criado para fazer mock com REST utilizando JSON
4+
5+
## Regras
6+
7+
Quando uma request é feita é seguido o seguinte fluxo:
8+
9+
* Existe na pasta do mock (conforme a propriedade `api.fileBase`)? Caso sim, retorna o mock
10+
* A uri se encaixa em algum pattern da lista de `api.uriConfigurations[].pattern`? Caso sim, vai redirecionar conforme a configuração e fazer fazer cache conforme o field `backup`
11+
* Se não entrar nos fluxos anteriores, vai redirecionar para o host padrão `api.host`
12+
13+
## Requisitos
14+
* Java JDK 8
15+
* Maven 3
16+
17+
## Run
18+
19+
## Usando seu arquivo de propriedades
20+
Crie seu arquivo de propriedade `src/main/resources/application-custom.yml` e rode com o argumento `-Dspring.profiles.active=custom`. Exemplo:
21+
```
22+
mvn spring-boot:run -Dspring.profiles.active=custom
23+
```
24+
25+
## TODO
26+
* Mudar para Gradle
27+
* Adicionar a opção de fazer build com Docker
28+
* Quando não existir `api.acceptedHeaders` não precisa validar
29+
* Separar testes unitários dos testes integrados
30+
* Corrigir os testes ignorados
31+
* Corrigir Code Style
32+
* Adcionar plugin do FindBugs

mocks-test/get/guests/132/1.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"response": {
3+
"body": [
4+
{
5+
"cc": "11",
6+
"ca": "12"
7+
},
8+
{
9+
"cc": "21",
10+
"ca": "22"
11+
},
12+
{
13+
"cc": "31",
14+
"ca": "32"
15+
}
16+
]
17+
}
18+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"response": {
3+
"body": [
4+
{
5+
"move": "3"
6+
}
7+
]
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"response": {
3+
"body": {
4+
"tt": "789"
5+
}
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"response": {
3+
"body": {
4+
"tt": "456"
5+
}
6+
}
7+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"request": {
3+
"query": {
4+
"payment": "1",
5+
"value": "10"
6+
}
7+
},
8+
"response": {
9+
"body": [
10+
{
11+
"total": "1700"
12+
},
13+
{
14+
"total": "1800"
15+
}
16+
]
17+
}
18+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"request": {
3+
"query": {
4+
"payment": "2",
5+
"value": "20"
6+
}
7+
},
8+
"response": {
9+
"body": [
10+
{
11+
"total": "1702"
12+
},
13+
{
14+
"total": "1802"
15+
}
16+
]
17+
}
18+
}

mocks-test/get/person/11/1.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"response": {
3+
"body": {
4+
"name": "Paul"
5+
}
6+
}
7+
}

mocks-test/get/users/123/1.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"response": {
3+
"body": {
4+
"name": "Paul"
5+
}
6+
}
7+
}

mocks-test/get/users/123/2.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"request": {
3+
"query": {
4+
"payment": "22"
5+
}
6+
},
7+
"response": {
8+
"body": {
9+
"name": "John"
10+
},
11+
"httpStatus": 202
12+
}
13+
}

mocks-test/patch/users/1456/1.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"request": {
3+
"body": {
4+
"result": "done"
5+
}
6+
},
7+
"response": {
8+
"body": {
9+
"sync": "success"
10+
}
11+
}
12+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"request": {
3+
"body": {
4+
"count": "698"
5+
}
6+
},
7+
"response": {
8+
"body": {
9+
"street": "USA"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"request": {
3+
"body": {
4+
"pi": "123456"
5+
}
6+
},
7+
"response": {
8+
"body": {
9+
"street": "NY"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"request": {
3+
"body": {
4+
"pi": "j12"
5+
}
6+
},
7+
"response": {
8+
"body": {
9+
"codigo": "123",
10+
"mensagem": "Error :("
11+
},
12+
"httpStatus": "422"
13+
}
14+
}

pom.xml

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>br.com.concrete.mock</groupId>
7+
<artifactId>mock-api</artifactId>
8+
<version>3.0.0</version>
9+
<packaging>war</packaging>
10+
11+
<name>mock-api</name>
12+
<description>Mock API</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>1.4.1.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24+
<java.version>1.8</java.version>
25+
<infinispan.version>5.1.7.Final</infinispan.version>
26+
<json-smart.version>1.0.8</json-smart.version>
27+
<javax.ws.rs-api.version>2.0</javax.ws.rs-api.version>
28+
<gson.version>2.3.1</gson.version>
29+
<guava.version>22.0</guava.version>
30+
<fixture-factory.version>3.1.0</fixture-factory.version>
31+
<httpclient.version>4.5.2</httpclient.version>
32+
<modelmapper.version>0.7.5</modelmapper.version>
33+
<commons-io.version>2.5</commons-io.version>
34+
</properties>
35+
36+
<dependencies>
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-web</artifactId>
40+
<exclusions>
41+
<exclusion>
42+
<groupId>org.apache.httpcomponents</groupId>
43+
<artifactId>httpclient</artifactId>
44+
</exclusion>
45+
</exclusions>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-starter-undertow</artifactId>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>spring-boot-starter-hateoas</artifactId>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.springframework.boot</groupId>
57+
<artifactId>spring-boot-starter-undertow</artifactId>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.springframework.boot</groupId>
61+
<artifactId>spring-boot-starter-test</artifactId>
62+
<scope>test</scope>
63+
</dependency>
64+
<dependency>
65+
<groupId>com.google.code.gson</groupId>
66+
<artifactId>gson</artifactId>
67+
</dependency>
68+
<dependency>
69+
<groupId>javax.ws.rs</groupId>
70+
<artifactId>javax.ws.rs-api</artifactId>
71+
<version>${javax.ws.rs-api.version}</version>
72+
</dependency>
73+
<dependency>
74+
<groupId>net.minidev</groupId>
75+
<artifactId>json-smart</artifactId>
76+
<version>${json-smart.version}</version>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.apache.httpcomponents</groupId>
80+
<artifactId>httpclient</artifactId>
81+
</dependency>
82+
<dependency>
83+
<groupId>com.google.guava</groupId>
84+
<artifactId>guava</artifactId>
85+
<version>${guava.version}</version>
86+
</dependency>
87+
<dependency>
88+
<groupId>org.modelmapper</groupId>
89+
<artifactId>modelmapper</artifactId>
90+
<version>${modelmapper.version}</version>
91+
</dependency>
92+
<dependency>
93+
<groupId>br.com.six2six</groupId>
94+
<artifactId>fixture-factory</artifactId>
95+
<version>${fixture-factory.version}</version>
96+
<scope>test</scope>
97+
</dependency>
98+
<dependency>
99+
<groupId>commons-io</groupId>
100+
<artifactId>commons-io</artifactId>
101+
<version>${commons-io.version}</version>
102+
</dependency>
103+
</dependencies>
104+
105+
<build>
106+
<plugins>
107+
<plugin>
108+
<artifactId>maven-compiler-plugin</artifactId>
109+
<version>3.1</version>
110+
<configuration>
111+
<source>${java.version}</source>
112+
<target>${java.version}</target>
113+
</configuration>
114+
</plugin>
115+
<plugin>
116+
<groupId>org.springframework.boot</groupId>
117+
<artifactId>spring-boot-maven-plugin</artifactId>
118+
</plugin>
119+
<plugin>
120+
<groupId>org.apache.maven.plugins</groupId>
121+
<artifactId>maven-release-plugin</artifactId>
122+
<version>2.5.3</version>
123+
</plugin>
124+
</plugins>
125+
</build>
126+
127+
</project>

0 commit comments

Comments
 (0)