diff --git a/resources/schemas/account.json b/resources/schemas/account.json new file mode 100644 index 0000000..a7b4851 --- /dev/null +++ b/resources/schemas/account.json @@ -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 + } + ] + ] +} \ No newline at end of file diff --git a/resources/schemas/balance.json b/resources/schemas/balance.json new file mode 100644 index 0000000..9163906 --- /dev/null +++ b/resources/schemas/balance.json @@ -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" + } + ] + ] +} \ No newline at end of file diff --git a/resources/schemas/movement.json b/resources/schemas/movement.json new file mode 100644 index 0000000..3e1e370 --- /dev/null +++ b/resources/schemas/movement.json @@ -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 + } + ] + ] +} \ No newline at end of file diff --git a/tests/schema.robot b/tests/schema.robot new file mode 100644 index 0000000..d305918 --- /dev/null +++ b/tests/schema.robot @@ -0,0 +1,22 @@ +*** Settings *** +Documentation JSON Schema Tests + +Resource ../resources/base.resource + +Suite Setup Setup + +*** Test Cases *** +Deve validar o JSON Schema para Contas + ${response} Get All Accounts + + Validate Json By Schema File ${response.json()} ${EXECDIR}/resources/schemas/account.json + +Deve validar o JSON Schema para Saldo + ${response} Get All Balances + + Validate Json By Schema File ${response.json()} ${EXECDIR}/resources/schemas/balance.json + +Deve validar o JSON Schema para Movimentações + ${response} Get All Movements + + Validate Json By Schema File ${response.json()} ${EXECDIR}/resources/schemas/movement.json \ No newline at end of file