-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suíte de testes para validação de JSON Schema
- Loading branch information
1 parent
d4eb659
commit 04d97a5
Showing
5 changed files
with
362 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package br.qa.thinogueiras.tests; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import br.qa.thinogueiras.core.BaseTest; | ||
|
||
@DisplayName("JSON Schema Tests") | ||
public class SchemaTest extends BaseTest { | ||
|
||
@Test | ||
public void shouldValidateAccountJSONSchema() { | ||
given() | ||
.when() | ||
.get("/contas") | ||
.then() | ||
.statusCode(200) | ||
.body(matchesJsonSchemaInClasspath("schemas/account.json")); | ||
} | ||
|
||
@Test | ||
public void shouldValidateBalanceJSONSchema() { | ||
given() | ||
.when() | ||
.get("/saldo") | ||
.then() | ||
.statusCode(200) | ||
.body(matchesJsonSchemaInClasspath("schemas/balance.json")); | ||
} | ||
|
||
@Test | ||
public void shouldValidateMovementJSONSchema() { | ||
given() | ||
.when() | ||
.get("/transacoes") | ||
.then() | ||
.statusCode(200) | ||
.body(matchesJsonSchemaInClasspath("schemas/movement.json")); | ||
} | ||
} |
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,70 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2019-09/schema", | ||
"$id": "http://example.com/example.json", | ||
"type": "array", | ||
"default": [], | ||
"title": "Root Schema", | ||
"items": { | ||
"type": "object", | ||
"title": "A Schema", | ||
"required": [ | ||
"id", | ||
"nome", | ||
"visivel", | ||
"usuario_id" | ||
], | ||
"properties": { | ||
"id": { | ||
"type": "integer", | ||
"title": "The id Schema", | ||
"examples": [ | ||
2054551, | ||
2054552 | ||
] | ||
}, | ||
"nome": { | ||
"type": "string", | ||
"title": "The nome Schema", | ||
"examples": [ | ||
"Conta mesmo nome", | ||
"Conta para movimentacoes", | ||
"Conta com movimentacao", | ||
"Conta para saldo", | ||
"Conta para extrato", | ||
"Conta Alterada com Sucesso", | ||
"Conta de investimentos" | ||
] | ||
}, | ||
"visivel": { | ||
"type": "boolean", | ||
"title": "The visivel Schema", | ||
"examples": [ | ||
true | ||
] | ||
}, | ||
"usuario_id": { | ||
"type": "integer", | ||
"title": "The usuario_id Schema", | ||
"examples": [ | ||
34767 | ||
] | ||
} | ||
} | ||
}, | ||
"examples": [ | ||
[ | ||
{ | ||
"id": 2054551, | ||
"nome": "Conta mesmo nome", | ||
"visivel": true, | ||
"usuario_id": 34767 | ||
}, | ||
{ | ||
"id": 2054552, | ||
"nome": "Conta para movimentacoes", | ||
"visivel": true, | ||
"usuario_id": 34767 | ||
} | ||
] | ||
] | ||
} |
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,59 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2019-09/schema", | ||
"$id": "http://example.com/example.json", | ||
"type": "array", | ||
"default": [], | ||
"title": "Root Schema", | ||
"items": { | ||
"type": "object", | ||
"title": "A Schema", | ||
"required": [ | ||
"conta_id", | ||
"conta", | ||
"saldo" | ||
], | ||
"properties": { | ||
"conta_id": { | ||
"type": "integer", | ||
"title": "The conta_id Schema", | ||
"examples": [ | ||
2054722, | ||
2054723 | ||
] | ||
}, | ||
"conta": { | ||
"type": "string", | ||
"title": "The conta Schema", | ||
"examples": [ | ||
"Conta para movimentacoes", | ||
"Conta com movimentacao", | ||
"Conta para saldo", | ||
"Conta para extrato" | ||
] | ||
}, | ||
"saldo": { | ||
"type": "string", | ||
"title": "The saldo Schema", | ||
"examples": [ | ||
"-1500.00", | ||
"534.00", | ||
"-220.00" | ||
] | ||
} | ||
} | ||
}, | ||
"examples": [ | ||
[ | ||
{ | ||
"conta_id": 2054722, | ||
"conta": "Conta para movimentacoes", | ||
"saldo": "-1500.00" | ||
}, | ||
{ | ||
"conta_id": 2054724, | ||
"conta": "Conta para saldo", | ||
"saldo": "534.00" | ||
} | ||
] | ||
] | ||
} |
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,180 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2019-09/schema", | ||
"$id": "http://example.com/example.json", | ||
"type": "array", | ||
"default": [], | ||
"title": "Root Schema", | ||
"items": { | ||
"type": "object", | ||
"title": "A Schema", | ||
"required": [ | ||
"id", | ||
"descricao", | ||
"envolvido", | ||
"observacao", | ||
"tipo", | ||
"data_transacao", | ||
"data_pagamento", | ||
"valor", | ||
"status", | ||
"conta_id", | ||
"usuario_id", | ||
"transferencia_id", | ||
"parcelamento_id" | ||
], | ||
"properties": { | ||
"id": { | ||
"type": "integer", | ||
"title": "The id Schema", | ||
"examples": [ | ||
1926111, | ||
1926112, | ||
1926113, | ||
1926114, | ||
1926115, | ||
1926116 | ||
] | ||
}, | ||
"descricao": { | ||
"type": "string", | ||
"title": "The descricao Schema", | ||
"examples": [ | ||
"Movimentacao para exclusao", | ||
"Movimentacao de conta", | ||
"Movimentacao 1, calculo saldo", | ||
"Movimentacao 2, calculo saldo", | ||
"Movimentacao 3, calculo saldo", | ||
"Movimentacao para extrato" | ||
] | ||
}, | ||
"envolvido": { | ||
"type": "string", | ||
"title": "The envolvido Schema", | ||
"examples": [ | ||
"AAA", | ||
"BBB", | ||
"CCC", | ||
"DDD", | ||
"EEE", | ||
"FFF" | ||
] | ||
}, | ||
"observacao": { | ||
"type": "null", | ||
"title": "The observacao Schema", | ||
"examples": [ | ||
null | ||
] | ||
}, | ||
"tipo": { | ||
"type": "string", | ||
"title": "The tipo Schema", | ||
"examples": [ | ||
"DESP", | ||
"REC" | ||
] | ||
}, | ||
"data_transacao": { | ||
"type": "string", | ||
"title": "The data_transacao Schema", | ||
"examples": [ | ||
"2024-03-04T03:00:00.000Z" | ||
] | ||
}, | ||
"data_pagamento": { | ||
"type": "string", | ||
"title": "The data_pagamento Schema", | ||
"examples": [ | ||
"2024-03-04T03:00:00.000Z" | ||
] | ||
}, | ||
"valor": { | ||
"type": [ | ||
"integer", | ||
"string" | ||
], | ||
"title": "The valor Schema", | ||
"examples": [ | ||
1500, | ||
"3500.00", | ||
1000, | ||
"1534.00", | ||
220 | ||
] | ||
}, | ||
"status": { | ||
"type": "boolean", | ||
"title": "The status Schema", | ||
"examples": [ | ||
true, | ||
false | ||
] | ||
}, | ||
"conta_id": { | ||
"type": "integer", | ||
"title": "The conta_id Schema", | ||
"examples": [ | ||
2054740, | ||
2054741, | ||
2054742, | ||
2054743 | ||
] | ||
}, | ||
"usuario_id": { | ||
"type": "integer", | ||
"title": "The usuario_id Schema", | ||
"examples": [ | ||
34767 | ||
] | ||
}, | ||
"transferencia_id": { | ||
"type": "null", | ||
"title": "The transferencia_id Schema", | ||
"examples": [ | ||
null | ||
] | ||
}, | ||
"parcelamento_id": { | ||
"type": "null", | ||
"title": "The parcelamento_id Schema", | ||
"examples": [ | ||
null | ||
] | ||
} | ||
} | ||
}, | ||
"examples": [ | ||
[ | ||
{ | ||
"id": 1926111, | ||
"descricao": "Movimentacao para exclusao", | ||
"envolvido": "AAA", | ||
"observacao": null, | ||
"tipo": "DESP", | ||
"data_transacao": "2024-03-04T03:00:00.000Z", | ||
"data_pagamento": "2024-03-04T03:00:00.000Z", | ||
"valor": 1500, | ||
"status": true, | ||
"conta_id": 2054740, | ||
"usuario_id": 34767, | ||
"transferencia_id": null, | ||
"parcelamento_id": null | ||
}, | ||
{ | ||
"id": 1926112, | ||
"descricao": "Movimentacao de conta", | ||
"envolvido": "BBB", | ||
"observacao": null, | ||
"tipo": "DESP", | ||
"data_transacao": "2024-03-04T03:00:00.000Z", | ||
"data_pagamento": "2024-03-04T03:00:00.000Z", | ||
"valor": 1500, | ||
"status": true, | ||
"conta_id": 2054741, | ||
"usuario_id": 34767, | ||
"transferencia_id": null, | ||
"parcelamento_id": null | ||
} | ||
] | ||
] | ||
} |