From 794cf122512a366cca88a7f9a2e3791d0c169799 Mon Sep 17 00:00:00 2001 From: Luis Moro Date: Wed, 5 Jul 2017 15:25:49 -0300 Subject: [PATCH 01/54] Commit Inicial --- .gitignore | 46 ++-- README.md | 32 +++ mocks-test/get/guests/132/1.json | 18 ++ mocks-test/get/guests/132/users/1.json | 9 + mocks-test/get/guests/132/users/21/cc/1.json | 7 + mocks-test/get/guests/132/users/22/cc/1.json | 7 + mocks-test/get/payments/user/detail/1.json | 18 ++ mocks-test/get/payments/user/detail/2.json | 18 ++ mocks-test/get/person/11/1.json | 7 + mocks-test/get/users/123/1.json | 7 + mocks-test/get/users/123/2.json | 13 ++ mocks-test/patch/users/1456/1.json | 12 + mocks-test/post/move/to/country/13/1.json | 12 + mocks-test/post/move/to/country/13/pi/1.json | 12 + mocks-test/post/move/to/country/13/pi/2.json | 14 ++ pom.xml | 127 ++++++++++ .../br/com/concrete/mock/ApiApplication.java | 27 +++ .../v1/controller/CaptureStateController.java | 56 +++++ .../api/v1/mapper/CaptureStateDto.java | 35 +++ .../configuration/model/CaptureState.java | 15 ++ .../repository/CaptureStateRepository.java | 14 ++ .../impl/CaptureStateRepositoryImpl.java | 40 ++++ .../service/CaptureExecutor.java | 11 + .../service/CaptureStateService.java | 14 ++ .../service/impl/CaptureExecutorImpl.java | 26 +++ .../service/impl/CaptureStateServiceImpl.java | 46 ++++ .../v1/controller/GenericApiController.java | 87 +++++++ .../generic/api/v1/mapper/RequestMapper.java | 48 ++++ .../mock/generic/mapper/EndpointDto.java | 55 +++++ .../mock/generic/mapper/EndpointMapper.java | 40 ++++ .../mock/generic/mapper/HeaderMapper.java | 27 +++ .../mock/generic/mapper/QueryMapper.java | 47 ++++ .../mock/generic/mapper/RequestDto.java | 59 +++++ .../mock/generic/mapper/ResponseDto.java | 49 ++++ .../concrete/mock/generic/model/Endpoint.java | 101 ++++++++ .../concrete/mock/generic/model/Error.java | 27 +++ .../mock/generic/model/ExternalApiResult.java | 25 ++ .../concrete/mock/generic/model/Request.java | 147 ++++++++++++ .../concrete/mock/generic/model/Response.java | 25 ++ .../repository/EndpointRepository.java | 16 ++ .../repository/impl/EndpointFileFilter.java | 10 + .../impl/EndpointFileFilterBody.java | 34 +++ .../impl/EndpointFileFilterQuery.java | 34 +++ .../impl/EndpointFileFilterRequest.java | 26 +++ .../impl/EndpointRepositoryBackup.java | 26 +++ .../impl/EndpointRepositoryBase.java | 88 +++++++ .../impl/EndpointRepositoryModel.java | 25 ++ .../service/EndpointBackupService.java | 11 + .../generic/service/GenericApiService.java | 18 ++ .../impl/EndpointBackupServiceFile.java | 95 ++++++++ .../service/impl/GenericApiServiceImpl.java | 90 +++++++ .../mock/infra/component/CompareJson.java | 40 ++++ .../mock/infra/component/CompareMap.java | 26 +++ .../mock/infra/component/ConvertJson.java | 10 + .../mock/infra/component/ExternalApi.java | 90 +++++++ .../FromJsonStringToObjectConverter.java | 10 + .../mock/infra/component/HeaderFilter.java | 44 ++++ .../mock/infra/component/JsonFormatter.java | 7 + .../infra/component/JsonValueCompiler.java | 8 + .../infra/component/QueryStringBuilder.java | 7 + .../infra/component/RequestFormatter.java | 10 + .../component/file/BaseFileNameBuilder.java | 11 + .../file/BaseFileNameBuilderBackup.java | 16 ++ .../file/BaseFileNameBuilderBase.java | 27 +++ .../file/BaseFileNameBuilderModel.java | 16 ++ .../infra/component/file/FileJsonReader.java | 32 +++ .../component/file/FileNameGenerator.java | 7 + .../component/file/FileNameGeneratorImpl.java | 40 ++++ .../infra/component/impl/ConvertJsonImpl.java | 28 +++ .../FromJsonStringToObjectConverterImpl.java | 26 +++ .../component/impl/JsonFormatterPretty.java | 22 ++ .../component/impl/JsonValueCompilerImpl.java | 33 +++ .../impl/QueryStringBuilderImpl.java | 35 +++ .../component/impl/RequestFormatterImpl.java | 21 ++ .../infra/exception/ApplicationException.java | 7 + .../ApplicationExceptionHandler.java | 69 ++++++ .../ApplicationExceptionMessage.java | 9 + .../impl/ApiApplicationException.java | 12 + .../impl/ApplicationExceptionImpl.java | 20 ++ .../impl/ApplicationExceptionMessageImpl.java | 27 +++ .../impl/ErrorApplicationException.java | 11 + .../impl/JsonApiApplicationException.java | 12 + .../mock/infra/model/DefaultHeader.java | 54 +++++ .../mock/infra/model/UriConfiguration.java | 68 ++++++ .../mock/infra/property/ApiProperty.java | 71 ++++++ .../infra/property/FileExtensionProperty.java | 7 + .../mock/infra/property/FileProperty.java | 7 + .../impl/FileExtensionPropertyImpl.java | 20 ++ .../property/impl/FilePropertyBackup.java | 20 ++ .../property/impl/FilePropertyModel.java | 20 ++ src/main/resources/application.yml | 47 ++++ .../concrete/mock/ApiApplicationTests.java | 16 ++ ...CaptureStateControllerIntegrationTest.java | 98 ++++++++ ...cApiControllerExternalIntegrationTest.java | 110 +++++++++ .../GenericApiControllerIntegrationTest.java | 219 ++++++++++++++++++ .../api/v1/mapper/RequestMapperTest.java | 154 ++++++++++++ .../mock/generic/mapper/EndpointDtoTest.java | 162 +++++++++++++ .../generic/mapper/EndpointMapperTest.java | 69 ++++++ .../mock/generic/mapper/HeaderMapperTest.java | 38 +++ .../mock/generic/mapper/QueryMapperTest.java | 77 ++++++ .../mock/generic/mapper/ResponseDtoTest.java | 81 +++++++ .../mock/generic/model/RequestTest.java | 79 +++++++ .../model/template/EndpointTemplate.java | 58 +++++ .../model/template/RequestTemplate.java | 71 ++++++ .../model/template/ResponseTemplate.java | 40 ++++ .../impl/EndpointFileFilterBodyTest.java | 70 ++++++ .../impl/EndpointFileFilterQueryTest.java | 70 ++++++ .../impl/EndpointRepositoryModelTest.java | 128 ++++++++++ ...pointBackupServiceFileIntegrarionTest.java | 124 ++++++++++ .../impl/EndpointBackupServiceFileTest.java | 126 ++++++++++ .../mock/infra/component/ApiPropertyTest.java | 64 +++++ .../mock/infra/component/CompareJsonTest.java | 105 +++++++++ .../mock/infra/component/CompareMapTest.java | 90 +++++++ .../mock/infra/component/ExternalApiTest.java | 95 ++++++++ .../file/BaseFileNameBuilderModelTest.java | 60 +++++ .../component/file/FileJsonReaderTest.java | 62 +++++ .../file/FileNameGeneratorImplTest.java | 120 ++++++++++ .../component/impl/ConvertJsonImplTest.java | 34 +++ ...omJsonStringToObjectConverterImplTest.java | 61 +++++ .../impl/JsonFormatterPrettyTest.java | 47 ++++ .../impl/JsonValueCompilerImplTest.java | 79 +++++++ .../impl/QueryStringBuilderImplTest.java | 64 +++++ src/test/resources/application.yml | 40 ++++ .../mocks-test/get/guests/132/1.json | 18 ++ .../mocks-test/get/guests/132/users/1.json | 9 + .../get/guests/132/users/21/cc/1.json | 7 + .../get/guests/132/users/22/cc/1.json | 7 + .../get/payments/user/detail/1.json | 18 ++ .../get/payments/user/detail/2.json | 18 ++ .../mocks-test/get/person/11/my-mock.json | 8 + .../resources/mocks-test/get/users/123/1.json | 7 + .../resources/mocks-test/get/users/123/2.json | 13 ++ .../mocks-test/patch/users/1456/1.json | 12 + .../patch/v2/57fbd6280f0000ed154fd470/1.json | 12 + .../mocks-test/post/move/to/country/13/1.json | 12 + .../post/move/to/country/13/pi/1.json | 12 + .../post/move/to/country/13/pi/2.json | 14 ++ .../post/v2/57fbd6280f0000ed154fd470/1.json | 12 + 138 files changed, 5773 insertions(+), 17 deletions(-) mode change 100644 => 100755 .gitignore create mode 100644 README.md create mode 100755 mocks-test/get/guests/132/1.json create mode 100755 mocks-test/get/guests/132/users/1.json create mode 100755 mocks-test/get/guests/132/users/21/cc/1.json create mode 100755 mocks-test/get/guests/132/users/22/cc/1.json create mode 100755 mocks-test/get/payments/user/detail/1.json create mode 100755 mocks-test/get/payments/user/detail/2.json create mode 100755 mocks-test/get/person/11/1.json create mode 100755 mocks-test/get/users/123/1.json create mode 100755 mocks-test/get/users/123/2.json create mode 100755 mocks-test/patch/users/1456/1.json create mode 100755 mocks-test/post/move/to/country/13/1.json create mode 100755 mocks-test/post/move/to/country/13/pi/1.json create mode 100755 mocks-test/post/move/to/country/13/pi/2.json create mode 100755 pom.xml create mode 100755 src/main/java/br/com/concrete/mock/ApiApplication.java create mode 100755 src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java create mode 100755 src/main/java/br/com/concrete/mock/configuration/api/v1/mapper/CaptureStateDto.java create mode 100755 src/main/java/br/com/concrete/mock/configuration/model/CaptureState.java create mode 100755 src/main/java/br/com/concrete/mock/configuration/repository/CaptureStateRepository.java create mode 100755 src/main/java/br/com/concrete/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java create mode 100755 src/main/java/br/com/concrete/mock/configuration/service/CaptureExecutor.java create mode 100755 src/main/java/br/com/concrete/mock/configuration/service/CaptureStateService.java create mode 100755 src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureExecutorImpl.java create mode 100755 src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureStateServiceImpl.java create mode 100755 src/main/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiController.java create mode 100755 src/main/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapper.java create mode 100755 src/main/java/br/com/concrete/mock/generic/mapper/EndpointDto.java create mode 100755 src/main/java/br/com/concrete/mock/generic/mapper/EndpointMapper.java create mode 100755 src/main/java/br/com/concrete/mock/generic/mapper/HeaderMapper.java create mode 100755 src/main/java/br/com/concrete/mock/generic/mapper/QueryMapper.java create mode 100755 src/main/java/br/com/concrete/mock/generic/mapper/RequestDto.java create mode 100755 src/main/java/br/com/concrete/mock/generic/mapper/ResponseDto.java create mode 100755 src/main/java/br/com/concrete/mock/generic/model/Endpoint.java create mode 100755 src/main/java/br/com/concrete/mock/generic/model/Error.java create mode 100644 src/main/java/br/com/concrete/mock/generic/model/ExternalApiResult.java create mode 100755 src/main/java/br/com/concrete/mock/generic/model/Request.java create mode 100755 src/main/java/br/com/concrete/mock/generic/model/Response.java create mode 100755 src/main/java/br/com/concrete/mock/generic/repository/EndpointRepository.java create mode 100755 src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilter.java create mode 100755 src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBody.java create mode 100755 src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQuery.java create mode 100755 src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterRequest.java create mode 100755 src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBackup.java create mode 100755 src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBase.java create mode 100755 src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModel.java create mode 100755 src/main/java/br/com/concrete/mock/generic/service/EndpointBackupService.java create mode 100755 src/main/java/br/com/concrete/mock/generic/service/GenericApiService.java create mode 100755 src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java create mode 100755 src/main/java/br/com/concrete/mock/generic/service/impl/GenericApiServiceImpl.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/CompareJson.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/CompareMap.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/ConvertJson.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/FromJsonStringToObjectConverter.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/HeaderFilter.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/JsonFormatter.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/JsonValueCompiler.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/QueryStringBuilder.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/RequestFormatter.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilder.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBackup.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBase.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModel.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/file/FileJsonReader.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/file/FileNameGenerator.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImpl.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImpl.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPretty.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImpl.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImpl.java create mode 100755 src/main/java/br/com/concrete/mock/infra/component/impl/RequestFormatterImpl.java create mode 100755 src/main/java/br/com/concrete/mock/infra/exception/ApplicationException.java create mode 100755 src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionHandler.java create mode 100755 src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionMessage.java create mode 100755 src/main/java/br/com/concrete/mock/infra/exception/impl/ApiApplicationException.java create mode 100755 src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionImpl.java create mode 100755 src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java create mode 100755 src/main/java/br/com/concrete/mock/infra/exception/impl/ErrorApplicationException.java create mode 100755 src/main/java/br/com/concrete/mock/infra/exception/impl/JsonApiApplicationException.java create mode 100644 src/main/java/br/com/concrete/mock/infra/model/DefaultHeader.java create mode 100644 src/main/java/br/com/concrete/mock/infra/model/UriConfiguration.java create mode 100755 src/main/java/br/com/concrete/mock/infra/property/ApiProperty.java create mode 100755 src/main/java/br/com/concrete/mock/infra/property/FileExtensionProperty.java create mode 100755 src/main/java/br/com/concrete/mock/infra/property/FileProperty.java create mode 100755 src/main/java/br/com/concrete/mock/infra/property/impl/FileExtensionPropertyImpl.java create mode 100755 src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyBackup.java create mode 100755 src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyModel.java create mode 100755 src/main/resources/application.yml create mode 100755 src/test/java/br/com/concrete/mock/ApiApplicationTests.java create mode 100755 src/test/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapperTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/mapper/EndpointMapperTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/mapper/HeaderMapperTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/mapper/QueryMapperTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/model/RequestTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/model/template/EndpointTemplate.java create mode 100755 src/test/java/br/com/concrete/mock/generic/model/template/RequestTemplate.java create mode 100755 src/test/java/br/com/concrete/mock/generic/model/template/ResponseTemplate.java create mode 100755 src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBodyTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQueryTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java create mode 100755 src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/ApiPropertyTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/CompareJsonTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/CompareMapTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/ExternalApiTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModelTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImplTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPrettyTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImplTest.java create mode 100755 src/test/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImplTest.java create mode 100755 src/test/resources/application.yml create mode 100755 src/test/resources/mocks-test/get/guests/132/1.json create mode 100755 src/test/resources/mocks-test/get/guests/132/users/1.json create mode 100755 src/test/resources/mocks-test/get/guests/132/users/21/cc/1.json create mode 100755 src/test/resources/mocks-test/get/guests/132/users/22/cc/1.json create mode 100755 src/test/resources/mocks-test/get/payments/user/detail/1.json create mode 100755 src/test/resources/mocks-test/get/payments/user/detail/2.json create mode 100755 src/test/resources/mocks-test/get/person/11/my-mock.json create mode 100755 src/test/resources/mocks-test/get/users/123/1.json create mode 100755 src/test/resources/mocks-test/get/users/123/2.json create mode 100755 src/test/resources/mocks-test/patch/users/1456/1.json create mode 100755 src/test/resources/mocks-test/patch/v2/57fbd6280f0000ed154fd470/1.json create mode 100755 src/test/resources/mocks-test/post/move/to/country/13/1.json create mode 100755 src/test/resources/mocks-test/post/move/to/country/13/pi/1.json create mode 100755 src/test/resources/mocks-test/post/move/to/country/13/pi/2.json create mode 100755 src/test/resources/mocks-test/post/v2/57fbd6280f0000ed154fd470/1.json diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 6143e53..b65bd5f --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,34 @@ -# Compiled class file -*.class +target/ +.mvn/ -# Log file -*.log +application-*.yml -# BlueJ files -*.ctxt +### STS ### +.classpath +.factorypath +.project +.settings +.springBeans -# Mobile Tools for Java (J2ME) -.mtj.tmp/ +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr -# Package Files # -*.jar -*.war -*.ear -*.zip -*.tar.gz -*.rar +### NetBeans ### +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* +gradle +.gradle/ +gradlew + +### Application ### +backup-temp/ +mocks-prod +fake-api-data diff --git a/README.md b/README.md new file mode 100644 index 0000000..b404b8e --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# Mock API + +App criado para fazer mock com REST utilizando JSON + +## Regras + +Quando uma request é feita é seguido o seguinte fluxo: + +* Existe na pasta do mock (conforme a propriedade `api.fileBase`)? Caso sim, retorna o mock +* 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` +* Se não entrar nos fluxos anteriores, vai redirecionar para o host padrão `api.host` + +## Requisitos +* Java JDK 8 +* Maven 3 + +## Run + +## Usando seu arquivo de propriedades +Crie seu arquivo de propriedade `src/main/resources/application-custom.yml` e rode com o argumento `-Dspring.profiles.active=custom`. Exemplo: +``` +mvn spring-boot:run -Dspring.profiles.active=custom +``` + +## TODO +* Mudar para Gradle +* Adicionar a opção de fazer build com Docker +* Quando não existir `api.acceptedHeaders` não precisa validar +* Separar testes unitários dos testes integrados +* Corrigir os testes ignorados +* Corrigir Code Style +* Adcionar plugin do FindBugs diff --git a/mocks-test/get/guests/132/1.json b/mocks-test/get/guests/132/1.json new file mode 100755 index 0000000..dddbac5 --- /dev/null +++ b/mocks-test/get/guests/132/1.json @@ -0,0 +1,18 @@ +{ + "response": { + "body": [ + { + "cc": "11", + "ca": "12" + }, + { + "cc": "21", + "ca": "22" + }, + { + "cc": "31", + "ca": "32" + } + ] + } +} diff --git a/mocks-test/get/guests/132/users/1.json b/mocks-test/get/guests/132/users/1.json new file mode 100755 index 0000000..614b8ce --- /dev/null +++ b/mocks-test/get/guests/132/users/1.json @@ -0,0 +1,9 @@ +{ + "response": { + "body": [ + { + "move": "3" + } + ] + } +} diff --git a/mocks-test/get/guests/132/users/21/cc/1.json b/mocks-test/get/guests/132/users/21/cc/1.json new file mode 100755 index 0000000..3f8c597 --- /dev/null +++ b/mocks-test/get/guests/132/users/21/cc/1.json @@ -0,0 +1,7 @@ +{ + "response": { + "body": { + "tt": "789" + } + } +} diff --git a/mocks-test/get/guests/132/users/22/cc/1.json b/mocks-test/get/guests/132/users/22/cc/1.json new file mode 100755 index 0000000..462294e --- /dev/null +++ b/mocks-test/get/guests/132/users/22/cc/1.json @@ -0,0 +1,7 @@ +{ + "response": { + "body": { + "tt": "456" + } + } +} diff --git a/mocks-test/get/payments/user/detail/1.json b/mocks-test/get/payments/user/detail/1.json new file mode 100755 index 0000000..e5240de --- /dev/null +++ b/mocks-test/get/payments/user/detail/1.json @@ -0,0 +1,18 @@ +{ + "request": { + "query": { + "payment": "1", + "value": "10" + } + }, + "response": { + "body": [ + { + "total": "1700" + }, + { + "total": "1800" + } + ] + } +} diff --git a/mocks-test/get/payments/user/detail/2.json b/mocks-test/get/payments/user/detail/2.json new file mode 100755 index 0000000..3690a07 --- /dev/null +++ b/mocks-test/get/payments/user/detail/2.json @@ -0,0 +1,18 @@ +{ + "request": { + "query": { + "payment": "2", + "value": "20" + } + }, + "response": { + "body": [ + { + "total": "1702" + }, + { + "total": "1802" + } + ] + } +} diff --git a/mocks-test/get/person/11/1.json b/mocks-test/get/person/11/1.json new file mode 100755 index 0000000..a24e97f --- /dev/null +++ b/mocks-test/get/person/11/1.json @@ -0,0 +1,7 @@ +{ + "response": { + "body": { + "name": "Paul" + } + } +} diff --git a/mocks-test/get/users/123/1.json b/mocks-test/get/users/123/1.json new file mode 100755 index 0000000..a24e97f --- /dev/null +++ b/mocks-test/get/users/123/1.json @@ -0,0 +1,7 @@ +{ + "response": { + "body": { + "name": "Paul" + } + } +} diff --git a/mocks-test/get/users/123/2.json b/mocks-test/get/users/123/2.json new file mode 100755 index 0000000..08e23df --- /dev/null +++ b/mocks-test/get/users/123/2.json @@ -0,0 +1,13 @@ +{ + "request": { + "query": { + "payment": "22" + } + }, + "response": { + "body": { + "name": "John" + }, + "httpStatus": 202 + } +} diff --git a/mocks-test/patch/users/1456/1.json b/mocks-test/patch/users/1456/1.json new file mode 100755 index 0000000..75b53ec --- /dev/null +++ b/mocks-test/patch/users/1456/1.json @@ -0,0 +1,12 @@ +{ + "request": { + "body": { + "result": "done" + } + }, + "response": { + "body": { + "sync": "success" + } + } +} diff --git a/mocks-test/post/move/to/country/13/1.json b/mocks-test/post/move/to/country/13/1.json new file mode 100755 index 0000000..b480e59 --- /dev/null +++ b/mocks-test/post/move/to/country/13/1.json @@ -0,0 +1,12 @@ +{ + "request": { + "body": { + "count": "698" + } + }, + "response": { + "body": { + "street": "USA" + } + } +} diff --git a/mocks-test/post/move/to/country/13/pi/1.json b/mocks-test/post/move/to/country/13/pi/1.json new file mode 100755 index 0000000..4595917 --- /dev/null +++ b/mocks-test/post/move/to/country/13/pi/1.json @@ -0,0 +1,12 @@ +{ + "request": { + "body": { + "pi": "123456" + } + }, + "response": { + "body": { + "street": "NY" + } + } +} diff --git a/mocks-test/post/move/to/country/13/pi/2.json b/mocks-test/post/move/to/country/13/pi/2.json new file mode 100755 index 0000000..b8ccfb3 --- /dev/null +++ b/mocks-test/post/move/to/country/13/pi/2.json @@ -0,0 +1,14 @@ +{ + "request": { + "body": { + "pi": "j12" + } + }, + "response": { + "body": { + "codigo": "123", + "mensagem": "Error :(" + }, + "httpStatus": "422" + } +} diff --git a/pom.xml b/pom.xml new file mode 100755 index 0000000..db2c8dc --- /dev/null +++ b/pom.xml @@ -0,0 +1,127 @@ + + + 4.0.0 + + br.com.concrete.mock + mock-api + 3.0.0 + war + + mock-api + Mock API + + + org.springframework.boot + spring-boot-starter-parent + 1.4.1.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + 5.1.7.Final + 1.0.8 + 2.0 + 2.3.1 + 22.0 + 3.1.0 + 4.5.2 + 0.7.5 + 2.5 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.apache.httpcomponents + httpclient + + + + + org.springframework.boot + spring-boot-starter-undertow + + + org.springframework.boot + spring-boot-starter-hateoas + + + org.springframework.boot + spring-boot-starter-undertow + + + org.springframework.boot + spring-boot-starter-test + test + + + com.google.code.gson + gson + + + javax.ws.rs + javax.ws.rs-api + ${javax.ws.rs-api.version} + + + net.minidev + json-smart + ${json-smart.version} + + + org.apache.httpcomponents + httpclient + + + com.google.guava + guava + ${guava.version} + + + org.modelmapper + modelmapper + ${modelmapper.version} + + + br.com.six2six + fixture-factory + ${fixture-factory.version} + test + + + commons-io + commons-io + ${commons-io.version} + + + + + + + maven-compiler-plugin + 3.1 + + ${java.version} + ${java.version} + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + + + + diff --git a/src/main/java/br/com/concrete/mock/ApiApplication.java b/src/main/java/br/com/concrete/mock/ApiApplication.java new file mode 100755 index 0000000..c61d41b --- /dev/null +++ b/src/main/java/br/com/concrete/mock/ApiApplication.java @@ -0,0 +1,27 @@ +package br.com.concrete.mock; + +import org.apache.http.impl.client.HttpClients; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.web.client.RestTemplate; + +@SpringBootApplication +@EnableCaching +public class ApiApplication { + + public static void main(String[] args) { + SpringApplication.run(ApiApplication.class, args); + } + + @Bean + public RestTemplate restTemplate() { + final RestTemplate restTemplate = new RestTemplate(); + restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(HttpClients.createDefault())); + + return restTemplate; + } + +} diff --git a/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java b/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java new file mode 100755 index 0000000..5ff5fad --- /dev/null +++ b/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java @@ -0,0 +1,56 @@ +package br.com.concrete.mock.configuration.api.v1.controller; + +import br.com.concrete.mock.configuration.api.v1.mapper.CaptureStateDto; +import br.com.concrete.mock.configuration.service.CaptureStateService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.PostConstruct; + +@RestController +@RequestMapping("/configuration/capture-state") +public class CaptureStateController { + + private static final Logger LOGGER = LoggerFactory.getLogger(CaptureStateController.class); + + private final CaptureStateService service; + + @Value("${captureState}") + private boolean captureState =true; + + @Autowired + public CaptureStateController(CaptureStateService service) { + this.service = service; + } + + @PostConstruct + public void init (){ + + LOGGER.info("Application capture state: " + captureState); + if(captureState){ + this.service.enable(); + } + } + + @RequestMapping(method = RequestMethod.GET) + public ResponseEntity getCurrent() { + return ResponseEntity.ok().body(new CaptureStateDto(service.getCurrent())); + } + + @RequestMapping(value = "/enable", method = RequestMethod.POST) + public ResponseEntity enable() { + return ResponseEntity.ok().body(new CaptureStateDto(service.enable())); + } + + @RequestMapping(value = "/disable", method = RequestMethod.DELETE) + @ResponseStatus(HttpStatus.NO_CONTENT) + public void disable() { + service.delete(); + } + +} diff --git a/src/main/java/br/com/concrete/mock/configuration/api/v1/mapper/CaptureStateDto.java b/src/main/java/br/com/concrete/mock/configuration/api/v1/mapper/CaptureStateDto.java new file mode 100755 index 0000000..bcd7778 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/configuration/api/v1/mapper/CaptureStateDto.java @@ -0,0 +1,35 @@ +package br.com.concrete.mock.configuration.api.v1.mapper; + +import br.com.concrete.mock.configuration.model.CaptureState; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.Optional; + +public class CaptureStateDto implements Serializable { + + private final Boolean enabled; + + @JsonCreator + public CaptureStateDto(@JsonProperty("enabled") Boolean enabled) { + this.enabled = enabled; + } + + public CaptureStateDto(Optional captureMode) { + this(captureMode.map(o -> o.isEnabled()).orElse(false)); + } + + public CaptureStateDto(CaptureState captureState) { + this(Optional.ofNullable(captureState)); + } + + public Boolean isEnabled() { + return enabled; + } + + public CaptureState toModel() { + return new CaptureState(enabled); + } + +} diff --git a/src/main/java/br/com/concrete/mock/configuration/model/CaptureState.java b/src/main/java/br/com/concrete/mock/configuration/model/CaptureState.java new file mode 100755 index 0000000..3344213 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/configuration/model/CaptureState.java @@ -0,0 +1,15 @@ +package br.com.concrete.mock.configuration.model; + +public class CaptureState { + + private final Boolean enabled; + + public CaptureState(Boolean enabled) { + this.enabled = enabled; + } + + public Boolean isEnabled() { + return enabled; + } + +} diff --git a/src/main/java/br/com/concrete/mock/configuration/repository/CaptureStateRepository.java b/src/main/java/br/com/concrete/mock/configuration/repository/CaptureStateRepository.java new file mode 100755 index 0000000..a01dac1 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/configuration/repository/CaptureStateRepository.java @@ -0,0 +1,14 @@ +package br.com.concrete.mock.configuration.repository; + +import br.com.concrete.mock.configuration.model.CaptureState; + +import java.util.Optional; + +public interface CaptureStateRepository { + + Optional getCurrent(); + + CaptureState save(CaptureState captureState); + + void delete(); +} diff --git a/src/main/java/br/com/concrete/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java b/src/main/java/br/com/concrete/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java new file mode 100755 index 0000000..62634d6 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java @@ -0,0 +1,40 @@ +package br.com.concrete.mock.configuration.repository.impl; + +import br.com.concrete.mock.configuration.model.CaptureState; +import br.com.concrete.mock.configuration.repository.CaptureStateRepository; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Component; + +import java.util.Optional; + +import static java.util.Optional.empty; + +@Component +@CacheConfig(cacheNames = "captureState") +public class CaptureStateRepositoryImpl implements CaptureStateRepository { + + private Optional captureState; + + public CaptureStateRepositoryImpl() { + delete(); + } + + @Cacheable + public Optional getCurrent() { + return captureState; + } + + @CacheEvict(allEntries = true) + public CaptureState save(CaptureState captureState) { + this.captureState = Optional.ofNullable(captureState); + return captureState; + } + + @CacheEvict(allEntries = true) + public void delete() { + this.captureState = empty(); + } + +} diff --git a/src/main/java/br/com/concrete/mock/configuration/service/CaptureExecutor.java b/src/main/java/br/com/concrete/mock/configuration/service/CaptureExecutor.java new file mode 100755 index 0000000..cb2a9f3 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/configuration/service/CaptureExecutor.java @@ -0,0 +1,11 @@ +package br.com.concrete.mock.configuration.service; + +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.ExternalApiResult; + +@FunctionalInterface +public interface CaptureExecutor { + + void execute(ExternalApiResult apiResult, Endpoint endpoint); + +} diff --git a/src/main/java/br/com/concrete/mock/configuration/service/CaptureStateService.java b/src/main/java/br/com/concrete/mock/configuration/service/CaptureStateService.java new file mode 100755 index 0000000..b908a48 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/configuration/service/CaptureStateService.java @@ -0,0 +1,14 @@ +package br.com.concrete.mock.configuration.service; + +import br.com.concrete.mock.configuration.model.CaptureState; + +import java.util.Optional; + +public interface CaptureStateService { + Optional getCurrent(); + + CaptureState enable(); + + void delete(); + +} diff --git a/src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureExecutorImpl.java b/src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureExecutorImpl.java new file mode 100755 index 0000000..7851524 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureExecutorImpl.java @@ -0,0 +1,26 @@ +package br.com.concrete.mock.configuration.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import br.com.concrete.mock.configuration.service.CaptureExecutor; +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.ExternalApiResult; +import br.com.concrete.mock.generic.service.EndpointBackupService; + +@Service +public class CaptureExecutorImpl implements CaptureExecutor { + + private final EndpointBackupService endpointBackupService; + + @Autowired + public CaptureExecutorImpl(EndpointBackupService endpointBackupService) { + this.endpointBackupService = endpointBackupService; + } + + public void execute(ExternalApiResult apiResult, Endpoint endpoint) { + if (apiResult.getUriConfiguration().isActiveBackup()) { + endpointBackupService.doBackup(endpoint); + } + } +} diff --git a/src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureStateServiceImpl.java b/src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureStateServiceImpl.java new file mode 100755 index 0000000..d4f2e77 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureStateServiceImpl.java @@ -0,0 +1,46 @@ +package br.com.concrete.mock.configuration.service.impl; + +import br.com.concrete.mock.configuration.model.CaptureState; +import br.com.concrete.mock.configuration.repository.CaptureStateRepository; +import br.com.concrete.mock.configuration.service.CaptureStateService; +import br.com.concrete.mock.infra.exception.impl.ApiApplicationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Optional; + +@Component +public class CaptureStateServiceImpl implements CaptureStateService { + + private static final Logger LOGGER = LoggerFactory.getLogger(CaptureStateServiceImpl.class); + + private final CaptureStateRepository repository; + + @Autowired + public CaptureStateServiceImpl(CaptureStateRepository repository) { + this.repository = repository; + } + + public Optional getCurrent() { + return repository.getCurrent(); + } + + public CaptureState enable() { + return repository.save(Optional + .of(new CaptureState(true)) + .map(old -> { + LOGGER.info("Backup activated"); + return new CaptureState(true); + }) + .orElseThrow(() -> new ApiApplicationException("cannot have an invalid capture state")) + ); + } + + public void delete() { + LOGGER.info("Backup deactivated"); + repository.delete(); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiController.java b/src/main/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiController.java new file mode 100755 index 0000000..95615c5 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiController.java @@ -0,0 +1,87 @@ +package br.com.concrete.mock.generic.api.v1.controller; + +import br.com.concrete.mock.generic.api.v1.mapper.RequestMapper; +import br.com.concrete.mock.generic.service.GenericApiService; +import br.com.concrete.mock.infra.component.JsonFormatter; +import br.com.concrete.mock.infra.component.RequestFormatter; +import com.google.gson.Gson; +import com.google.gson.JsonParseException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; + +@RestController +public class GenericApiController { + + private static final Logger LOGGER = LoggerFactory.getLogger(GenericApiController.class); + + private final GenericApiService genericApiService; + private final RequestMapper requestMapper; + private final JsonFormatter jsonFormatter; + private final RequestFormatter requestFormatter; + + @Autowired + public GenericApiController(GenericApiService genericApiService, RequestMapper requestMapper, + JsonFormatter jsonFormatter, RequestFormatter requestFormatter) { + this.genericApiService = genericApiService; + this.requestMapper = requestMapper; + this.jsonFormatter = jsonFormatter; + this.requestFormatter = requestFormatter; + } + + private void logRequest(final HttpServletRequest request, final Optional requestBody) { + LOGGER.info(requestFormatter.generateLog(request, requestBody)); + LOGGER.info("Headers: " + genericApiService.getHeaders(request)); + requestBody.ifPresent(body -> logJson(new Gson().toJson(body))); + } + + private void logJson(final String jsonString) { + try { + LOGGER.info(jsonFormatter.format(jsonString)); + } catch (JsonParseException e) { + LOGGER.warn("cannot print json: " + jsonString); + } + } + + private ResponseEntity interceptRequestAnyMedia(final HttpServletRequest request, + final Optional requestBody) { + logRequest(request, requestBody); + + final Optional> responseEntity = genericApiService + .genericResponseEntity(requestMapper.mapper(request, requestBody)); + + final ResponseEntity result = responseEntity + .map(r -> { + logJson(r.getBody()); + return r; + }) + .orElse(null); + + if (result == null) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); + } else { + return result; + } + } + + @RequestMapping(value = "/*/**") + public ResponseEntity interceptRequest(final HttpServletRequest request, + final @RequestBody(required = false) Object requestBodyRaw) { + return interceptRequestAnyMedia(request, Optional.ofNullable(requestBodyRaw)); + } + + @RequestMapping(value = "/*/**", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) + public ResponseEntity interceptRequestForm(final HttpServletRequest request) { + return interceptRequestAnyMedia(request, Optional.empty()); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapper.java b/src/main/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapper.java new file mode 100755 index 0000000..bf36d99 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapper.java @@ -0,0 +1,48 @@ +package br.com.concrete.mock.generic.api.v1.mapper; + +import br.com.concrete.mock.generic.mapper.HeaderMapper; +import br.com.concrete.mock.generic.mapper.QueryMapper; +import br.com.concrete.mock.generic.model.Request; +import com.google.gson.Gson; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMethod; + +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; + +@Component +public class RequestMapper { + + private static final Gson GSON = new Gson(); + + private final QueryMapper queryMapper; + private final HeaderMapper headerMapper; + + @Autowired + public RequestMapper(QueryMapper queryMapper, HeaderMapper headerMapper) { + this.queryMapper = queryMapper; + this.headerMapper = headerMapper; + } + + private Request.Builder mapperBuilder(final HttpServletRequest request) { + return new Request + .Builder(RequestMethod.valueOf(request.getMethod().toUpperCase()), request.getRequestURI()) + .withQuery(queryMapper.mapper(request.getQueryString())) + .withHeader(headerMapper.mapper(request)); + } + + public Request mapper(final HttpServletRequest request) { + return mapperBuilder(request).build(); + } + + public Request mapper(final HttpServletRequest request, final Optional requestBody) { + final Request.Builder requestMockBuilder = mapperBuilder(request); + + return requestBody + .map(requestBodyJson -> requestMockBuilder.withBody(Optional.ofNullable(GSON.toJson(requestBodyJson)))) + .orElse(requestMockBuilder) + .build(); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/EndpointDto.java b/src/main/java/br/com/concrete/mock/generic/mapper/EndpointDto.java new file mode 100755 index 0000000..ad45ce0 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/mapper/EndpointDto.java @@ -0,0 +1,55 @@ +package br.com.concrete.mock.generic.mapper; + +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.generic.model.Response; +import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.concrete.mock.infra.exception.impl.ApiApplicationException; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.io.Serializable; +import java.util.Optional; + +public class EndpointDto implements Serializable { + + private final RequestDto request; + private final ResponseDto response; + + @JsonCreator + public EndpointDto(@JsonProperty("request") RequestDto request, @JsonProperty("response") ResponseDto response) { + this.request = request; + this.response = response; + } + + public EndpointDto(Endpoint endpoint, FromJsonStringToObjectConverter converter) { + this( + endpoint.getRequest() == null || !endpoint.getRequest().isValid() ? null : new RequestDto(endpoint.getRequest(), converter), + endpoint.getResponse() == null ? null : new ResponseDto(endpoint.getResponse(), converter) + ); + } + + public RequestDto getRequest() { + return request; + } + + public ResponseDto getResponse() { + return response; + } + + public Endpoint toModel(RequestMethod method, String uri) { + final Request request = Optional + .ofNullable(this.request) + .map(requestDto -> requestDto.toModel(method, uri)) + .orElse(new Request.Builder(method, uri).build()); + + final Response response = Optional + .ofNullable(this.response) + .map(ResponseDto::toModel) + .orElseThrow(() -> new ApiApplicationException("Cannot deserialize: response is null")); + + return new Endpoint.Builder(request, response).build(); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/EndpointMapper.java b/src/main/java/br/com/concrete/mock/generic/mapper/EndpointMapper.java new file mode 100755 index 0000000..acafc1e --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/mapper/EndpointMapper.java @@ -0,0 +1,40 @@ +package br.com.concrete.mock.generic.mapper; + +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.infra.component.file.FileJsonReader; +import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.io.IOException; +import java.util.Optional; + +@Component +public class EndpointMapper { + + private static final Logger LOGGER = LoggerFactory.getLogger(EndpointMapper.class); + + private final FileJsonReader fileJsonReader; + + @Autowired + public EndpointMapper(FileJsonReader fileJsonReader) { + this.fileJsonReader = fileJsonReader; + } + + public Optional mapper(RequestMethod requestMethod, String requestUrl, String fileName) { + try { + return fileJsonReader + .getJsonByFileName(fileName) + .map(endpointDtoJson -> new Gson().fromJson(endpointDtoJson, EndpointDto.class)) + .map(endpointDto -> endpointDto.toModel(requestMethod, requestUrl)) + .map(endpoint -> new Endpoint.Builder(endpoint).withId(fileName).build()); + } catch (IOException e) { + LOGGER.error("Cannot to map endpoint from file", e); + return Optional.empty(); + } + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/HeaderMapper.java b/src/main/java/br/com/concrete/mock/generic/mapper/HeaderMapper.java new file mode 100755 index 0000000..a12bbef --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/mapper/HeaderMapper.java @@ -0,0 +1,27 @@ +package br.com.concrete.mock.generic.mapper; + +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import java.util.Enumeration; +import java.util.Optional; + +@Component +public class HeaderMapper { + + public Optional mapper(HttpServletRequest request) { + final HttpHeaders httpHeaders = new HttpHeaders(); + + Enumeration headerNames = request.getHeaderNames(); + if (headerNames != null) { + while (headerNames.hasMoreElements()) { + final String name = headerNames.nextElement(); + httpHeaders.add(name, request.getHeader(name)); + } + } + + return Optional.of(httpHeaders); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/QueryMapper.java b/src/main/java/br/com/concrete/mock/generic/mapper/QueryMapper.java new file mode 100755 index 0000000..1f858ff --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/mapper/QueryMapper.java @@ -0,0 +1,47 @@ +package br.com.concrete.mock.generic.mapper; + +import br.com.concrete.mock.infra.exception.impl.ApiApplicationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.util.MultiValueMap; +import org.springframework.web.util.UriComponentsBuilder; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Map; +import java.util.Optional; + +@Component +public class QueryMapper { + + private static final Logger LOGGER = LoggerFactory.getLogger(QueryMapper.class); + + public Optional> mapper(final String queryRequest) { + return Optional + .ofNullable(queryRequest) + .map(query -> { + try { + return UriComponentsBuilder + .fromUri(new URI("localhost?" + query)) + .build() + .getQueryParams(); + } catch (URISyntaxException e) { + final String message = new StringBuilder() + .append("Cannot convert queryString # ") + .append(query) + .append(" # ") + .append(e.getMessage()) + .toString(); + + LOGGER.error(message, e); + + throw new ApiApplicationException(message); + } + + }) + .filter(parameters -> !parameters.isEmpty()) + .map(MultiValueMap::toSingleValueMap); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/RequestDto.java b/src/main/java/br/com/concrete/mock/generic/mapper/RequestDto.java new file mode 100755 index 0000000..2a2b955 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/mapper/RequestDto.java @@ -0,0 +1,59 @@ +package br.com.concrete.mock.generic.mapper; + +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.Gson; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.io.Serializable; +import java.util.Map; +import java.util.Optional; + +public class RequestDto implements Serializable { + + private static final Gson GSON = new Gson(); + + private final HttpHeaders headers; + private final Map query; + private final Object body; + + @JsonCreator + public RequestDto(@JsonProperty("headers") HttpHeaders headers, @JsonProperty("query") Map query, @JsonProperty("body") Object body) { + this.headers = headers; + this.query = query; + this.body = body; + } + + public RequestDto(Request request, FromJsonStringToObjectConverter converter) { + this( + request.getHeaders().orElse(null), + request.getQuery().orElse(null), + converter.apply(request.getBody()) + ); + + } + + public HttpHeaders getHeaders() { + return headers; + } + + public Map getQuery() { + return query; + } + + public Object getBody() { + return body; + } + + public Request toModel(RequestMethod method, String uri) { + return new Request.Builder(method, uri) + .withHeader(headers) + .withQuery(query) + .withBody(Optional.ofNullable(body).map(GSON::toJson)) + .build(); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/ResponseDto.java b/src/main/java/br/com/concrete/mock/generic/mapper/ResponseDto.java new file mode 100755 index 0000000..97a993c --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/mapper/ResponseDto.java @@ -0,0 +1,49 @@ +package br.com.concrete.mock.generic.mapper; + +import br.com.concrete.mock.generic.model.Response; +import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.concrete.mock.infra.exception.impl.ApiApplicationException; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.Gson; +import org.springframework.http.HttpStatus; + +import java.io.Serializable; +import java.util.Optional; + +public class ResponseDto implements Serializable { + + private static final Gson GSON = new Gson(); + + private final Object body; + private final Integer httpStatus; + + @JsonCreator + public ResponseDto(@JsonProperty("body") Object body, @JsonProperty("httpStatus") Integer httpStatus) { + this.body = body; + this.httpStatus = httpStatus; + } + + public ResponseDto(Response response, FromJsonStringToObjectConverter converter) { + this( + converter.apply(Optional.ofNullable(response.getBody())), + response.getHttpStatus().map(HttpStatus::value).orElse(null) + ); + } + + public Object getBody() { + return body; + } + + public Response toModel() { + final String bodyResponse = Optional + .ofNullable(body) + .map(GSON::toJson) + .orElseThrow(() -> new ApiApplicationException("Cannot have a null body on response")); + final Optional httpStatusResponse = Optional + .ofNullable(this.httpStatus) + .map(HttpStatus::valueOf); + return new Response(bodyResponse, httpStatusResponse); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java b/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java new file mode 100755 index 0000000..e206b9e --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java @@ -0,0 +1,101 @@ +package br.com.concrete.mock.generic.model; + +import java.util.Map; +import java.util.Optional; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMethod; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Endpoint implements Comparable { + + private final Optional id; + private final Request request; + private final Response response; + + @JsonCreator + public Endpoint(@JsonProperty("id") Optional id, @JsonProperty("request") Request request, + @JsonProperty("response") Response response) { + this.id = id; + this.request = request; + this.response = response; + } + + @JsonIgnore + public Optional getId() { + return id; + } + + @JsonProperty + public Request getRequest() { + return request; + } + + @JsonProperty + public Response getResponse() { + return response; + } + + @Override + public int compareTo(Endpoint o) { + return this.request.compareTo(o.request); + } + + public static class Builder { + + private Optional id; + private Request request; + private Response response; + + public Builder(Request request, Response response) { + this.request = request; + this.response = response; + } + + public Builder(final Endpoint endpoint) { + this.id = endpoint.id; + this.request = endpoint.request; + this.response = endpoint.response; + } + + public Builder withId(final Optional id) { + this.id = id; + return this; + } + + public Builder withId(final String id) { + return withId(Optional.ofNullable(id)); + } + + public Builder(Request request, ResponseEntity responseEntity) { + this(request, new Response(responseEntity.getBody(), Optional.ofNullable(responseEntity.getStatusCode()))); + } + + public Builder(RequestMethod method, String url, Response response) { + withEmptyRequest(method, url); + this.response = response; + } + + public Builder withRequest(Optional> requestQuery, Optional requestBody) { + return withRequest(new Request.Builder(this.request).withQuery(requestQuery).withBody(requestBody).build()); + } + + public Builder withRequest(Request request) { + this.request = request; + return this; + } + + public Builder withEmptyRequest(RequestMethod method, String url) { + return withRequest(new Request.Builder(method, url).build()); + } + + public Endpoint build() { + return new Endpoint(id, request, response); + } + + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/model/Error.java b/src/main/java/br/com/concrete/mock/generic/model/Error.java new file mode 100755 index 0000000..ba4cff4 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/model/Error.java @@ -0,0 +1,27 @@ +package br.com.concrete.mock.generic.model; + +import java.io.Serializable; + +public class Error implements Serializable { + + private int codigo; + + private String mensagem; + + public Error() { + } + + public Error(int codigo, String mensagem) { + this.codigo = codigo; + this.mensagem = mensagem; + } + + public int getCodigo() { + return codigo; + } + + public String getMensagem() { + return mensagem; + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/model/ExternalApiResult.java b/src/main/java/br/com/concrete/mock/generic/model/ExternalApiResult.java new file mode 100644 index 0000000..3c51e58 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/model/ExternalApiResult.java @@ -0,0 +1,25 @@ +package br.com.concrete.mock.generic.model; + +import org.springframework.http.ResponseEntity; + +import br.com.concrete.mock.infra.model.UriConfiguration; + +public class ExternalApiResult { + + private final ResponseEntity apiResult; + private final UriConfiguration uriConfiguration; + + public ExternalApiResult(ResponseEntity apiResult, UriConfiguration uriConfiguration) { + this.apiResult = apiResult; + this.uriConfiguration = uriConfiguration; + } + + public ResponseEntity getApiResult() { + return apiResult; + } + + public UriConfiguration getUriConfiguration() { + return uriConfiguration; + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/model/Request.java b/src/main/java/br/com/concrete/mock/generic/model/Request.java new file mode 100755 index 0000000..a4f0a7a --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/model/Request.java @@ -0,0 +1,147 @@ +package br.com.concrete.mock.generic.model; + +import br.com.concrete.mock.infra.component.ConvertJson; +import br.com.concrete.mock.infra.component.impl.ConvertJsonImpl; +import br.com.concrete.mock.infra.exception.impl.JsonApiApplicationException; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.util.Map; +import java.util.Optional; + +public class Request implements Comparable { + + private static final ConvertJson CONVERT_JSON = new ConvertJsonImpl(); + + private RequestMethod method; + private String uri; + private Optional headers; + private Optional> query; + private Optional body; + + private Request() { + this.headers = Optional.empty(); + this.query = Optional.empty(); + this.body = Optional.empty(); + } + + public Request(RequestMethod method, String uri) { + this(); + this.method = method; + this.uri = uri; + } + + public RequestMethod getMethod() { + return method; + } + + public String getUri() { + return uri; + } + + public Optional getHeaders() { + return headers; + } + + public Optional> getQuery() { + return query; + } + + public Optional getBody() { + return body; + } + + public Integer countQueryFields() { + return getQuery() + .map(Map::size) + .orElse(0); + } + + public Integer countBodyFields() { + return countFields(getBody()); + } + + private Integer countFields(Optional attr) { + return attr + .map(queryStr -> { + try { + return CONVERT_JSON.apply(queryStr).size(); + } catch (JsonApiApplicationException e) { + return 0; + } + }) + .orElse(0); + } + + public Boolean isValid() { + return + (headers.filter(h -> h.size() > 0).map(h -> true).orElse(false)) + || countBodyFields() > 0 + || countQueryFields() > 0; + } + + @Override + public int compareTo(Request o) { + final Integer resultMethod = this.method.compareTo(o.method); + if (resultMethod == 0) { + final Integer resultUrl = this.uri.compareTo(o.uri); + if (resultUrl == 0) { + final Integer resultQueries = o.countQueryFields().compareTo(this.countQueryFields()); + if (resultQueries == 0) { + return o.countBodyFields().compareTo(this.countBodyFields()); + } else { + return resultQueries; + } + } else { + return resultUrl; + } + } else { + return resultMethod; + } + } + + public static class Builder { + + private final Request instance; + + public Builder(RequestMethod method, String uri) { + this.instance = new Request(method, uri); + } + + public Builder(Request request) { + this(request.getMethod(), request.getUri()); + withHeader(request.getHeaders()); + withQuery(request.getQuery()); + withBody(request.getBody()); + } + + public Builder withHeader(HttpHeaders headers) { + return withHeader(Optional.ofNullable(headers)); + } + + public Builder withHeader(Optional headers) { + instance.headers = headers; + return this; + } + + public Builder withQuery(Map query) { + return withQuery(Optional.ofNullable(query)); + } + + public Builder withQuery(Optional> query) { + instance.query = query; + return this; + } + + public Builder withBody(Optional body) { + instance.body = body; + return this; + } + + public Request build() { + return instance; + } + + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/model/Response.java b/src/main/java/br/com/concrete/mock/generic/model/Response.java new file mode 100755 index 0000000..dc9acf6 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/model/Response.java @@ -0,0 +1,25 @@ +package br.com.concrete.mock.generic.model; + +import org.springframework.http.HttpStatus; + +import java.util.Optional; + +public class Response { + + private final String body; + private final Optional httpStatus; + + public Response(String body, Optional httpStatus) { + this.body = body; + this.httpStatus = httpStatus; + } + + public String getBody() { + return body; + } + + public Optional getHttpStatus() { + return httpStatus; + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/repository/EndpointRepository.java b/src/main/java/br/com/concrete/mock/generic/repository/EndpointRepository.java new file mode 100755 index 0000000..cf510a0 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/repository/EndpointRepository.java @@ -0,0 +1,16 @@ +package br.com.concrete.mock.generic.repository; + +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.Request; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.util.Collection; +import java.util.Optional; + +public interface EndpointRepository { + + Collection getByMethodAndUri(RequestMethod requestMethod, String pathUri); + + Optional getByMethodAndRequest(Request request); + +} diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilter.java b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilter.java new file mode 100755 index 0000000..d29282b --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilter.java @@ -0,0 +1,10 @@ +package br.com.concrete.mock.generic.repository.impl; + +import br.com.concrete.mock.generic.model.Endpoint; + +@FunctionalInterface +interface EndpointFileFilter { + + Boolean apply(Endpoint endpoint, T request); + +} diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBody.java b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBody.java new file mode 100755 index 0000000..c1944c0 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBody.java @@ -0,0 +1,34 @@ +package br.com.concrete.mock.generic.repository.impl; + +import br.com.concrete.mock.infra.component.CompareJson; +import br.com.concrete.mock.generic.model.Endpoint; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Optional; + +@Component +class EndpointFileFilterBody implements EndpointFileFilter> { + + private final CompareJson compareJson; + + @Autowired + public EndpointFileFilterBody(CompareJson compareJson) { + this.compareJson = compareJson; + } + + @Override + public Boolean apply(Endpoint endpoint, Optional request) { + return request + .map(requestBody -> + endpoint + .getRequest() + .getBody() + .map(expetedBody -> compareJson.isEquivalent(expetedBody, requestBody)) + .orElse(true) + ) + .orElse(!endpoint.getRequest().getBody().isPresent()); + } + + +} diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQuery.java b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQuery.java new file mode 100755 index 0000000..acb3d05 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQuery.java @@ -0,0 +1,34 @@ +package br.com.concrete.mock.generic.repository.impl; + +import br.com.concrete.mock.infra.component.CompareMap; +import br.com.concrete.mock.generic.model.Endpoint; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Map; +import java.util.Optional; + +@Component +class EndpointFileFilterQuery implements EndpointFileFilter>> { + + private final CompareMap compareMap; + + @Autowired + public EndpointFileFilterQuery(CompareMap compareMap) { + this.compareMap = compareMap; + } + + @Override + public Boolean apply(Endpoint endpoint, Optional> request) { + return request + .map(requestQuery -> + endpoint + .getRequest() + .getQuery() + .map(expetedQuery -> compareMap.isEquivalent(expetedQuery, requestQuery)) + .orElse(true) + ) + .orElse(endpoint.getRequest() != null && (!endpoint.getRequest().getQuery().isPresent())); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterRequest.java b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterRequest.java new file mode 100755 index 0000000..2f7684d --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterRequest.java @@ -0,0 +1,26 @@ +package br.com.concrete.mock.generic.repository.impl; + +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.Request; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +class EndpointFileFilterRequest implements EndpointFileFilter { + + private final EndpointFileFilterQuery endpointFileFilterQuery; + private final EndpointFileFilterBody endpointMockFileFilterBody; + + @Autowired + public EndpointFileFilterRequest(EndpointFileFilterQuery endpointFileFilterQuery, EndpointFileFilterBody endpointMockFileFilterBody) { + this.endpointFileFilterQuery = endpointFileFilterQuery; + this.endpointMockFileFilterBody = endpointMockFileFilterBody; + } + + @Override + public Boolean apply(Endpoint endpoint, Request request) { + return endpointFileFilterQuery.apply(endpoint, request.getQuery()) && + endpointMockFileFilterBody.apply(endpoint, request.getBody()); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBackup.java b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBackup.java new file mode 100755 index 0000000..10e7e8c --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBackup.java @@ -0,0 +1,26 @@ +package br.com.concrete.mock.generic.repository.impl; + +import br.com.concrete.mock.generic.mapper.EndpointMapper; +import br.com.concrete.mock.generic.repository.EndpointRepository; +import br.com.concrete.mock.infra.component.file.BaseFileNameBuilder; +import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.concrete.mock.infra.property.FileProperty; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +@Repository("EndpointRepositoryBackup") +public class EndpointRepositoryBackup extends EndpointRepositoryBase implements EndpointRepository { + + @Autowired + public EndpointRepositoryBackup(@Qualifier("FilePropertyBackup") FileProperty fileProperty, FileExtensionProperty fileExtensionProperty, EndpointMapper endpointMapper, @Qualifier("BaseFileNameBuilderBackup") BaseFileNameBuilder baseFileNameBuilder, EndpointFileFilterRequest endpointFileFilterRequest) { + super( + fileProperty, + fileExtensionProperty, + endpointMapper, + baseFileNameBuilder, + endpointFileFilterRequest + ); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBase.java b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBase.java new file mode 100755 index 0000000..3453023 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBase.java @@ -0,0 +1,88 @@ +package br.com.concrete.mock.generic.repository.impl; + +import br.com.concrete.mock.generic.mapper.EndpointMapper; +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.generic.repository.EndpointRepository; +import br.com.concrete.mock.infra.component.file.BaseFileNameBuilder; +import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.concrete.mock.infra.property.FileProperty; +import com.google.common.collect.ImmutableList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class EndpointRepositoryBase implements EndpointRepository { + + private static final Logger LOGGER = LoggerFactory.getLogger(EndpointRepositoryBase.class); + + private final FileProperty fileProperty; + private final FileExtensionProperty fileExtensionProperty; + private final EndpointMapper endpointMapper; + private final BaseFileNameBuilder baseFileNameBuilder; + private final EndpointFileFilterRequest endpointFileFilterRequest; + + public EndpointRepositoryBase(FileProperty fileProperty, FileExtensionProperty fileExtensionProperty, EndpointMapper endpointMapper, BaseFileNameBuilder baseFileNameBuilder, EndpointFileFilterRequest endpointFileFilterRequest) { + this.fileProperty = fileProperty; + this.fileExtensionProperty = fileExtensionProperty; + this.endpointMapper = endpointMapper; + this.baseFileNameBuilder = baseFileNameBuilder; + this.endpointFileFilterRequest = endpointFileFilterRequest; + } + + @Override + public Collection getByMethodAndUri(RequestMethod requestMethod, String requestUrl) { + return ImmutableList.copyOf(getByMethodAndUriMutable(requestMethod, requestUrl)); + } + + @Override + public Optional getByMethodAndRequest(Request request) { + return getByMethodAndUri(request.getMethod(), request.getUri()) + .stream() + .sorted() + .filter(endpointMock -> endpointFileFilterRequest.apply(endpointMock, request)) + .findFirst(); + } + + private List getByMethodAndUriMutable(RequestMethod requestMethod, String requestUrl) { + final String basePath = baseFileNameBuilder.buildPath(requestMethod, requestUrl); + + final Path start = Paths.get(basePath); + if (!Files.exists(start)) { + return new ArrayList<>(); + } + + final Integer maxDepth = 1; + + try (Stream stream = Files.walk(start, maxDepth)) { + return stream + .map(String::valueOf) + .filter(path -> path.endsWith(fileExtensionProperty.getFileExtension())) + .map(fileName -> endpointMapper.mapper(requestMethod, requestUrl, fileName)) + .filter(o -> o != null) + .filter(Optional::isPresent) + .filter(a -> a.get() != null) + .map(Optional::get) + .collect(Collectors.toList()); + } catch (IOException e) { + final String message = new StringBuilder() + .append("Cannot read file from repository: ") + .append(basePath) + .toString(); + LOGGER.error(message, e); + return new ArrayList<>(); + } + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModel.java b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModel.java new file mode 100755 index 0000000..60e7771 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModel.java @@ -0,0 +1,25 @@ +package br.com.concrete.mock.generic.repository.impl; + +import br.com.concrete.mock.generic.mapper.EndpointMapper; +import br.com.concrete.mock.generic.repository.EndpointRepository; +import br.com.concrete.mock.infra.component.file.BaseFileNameBuilder; +import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.concrete.mock.infra.property.FileProperty; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +@Repository("EndpointRepositoryModel") +public class EndpointRepositoryModel extends EndpointRepositoryBase implements EndpointRepository { + + @Autowired + public EndpointRepositoryModel(@Qualifier("FilePropertyModel") FileProperty fileProperty, FileExtensionProperty fileExtensionProperty, EndpointMapper endpointMapper, @Qualifier("BaseFileNameBuilderModel") BaseFileNameBuilder baseFileNameBuilder, EndpointFileFilterRequest endpointFileFilterRequest) { + super( + fileProperty, + fileExtensionProperty, endpointMapper, + baseFileNameBuilder, + endpointFileFilterRequest + ); + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/service/EndpointBackupService.java b/src/main/java/br/com/concrete/mock/generic/service/EndpointBackupService.java new file mode 100755 index 0000000..472d51e --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/service/EndpointBackupService.java @@ -0,0 +1,11 @@ +package br.com.concrete.mock.generic.service; + +import br.com.concrete.mock.generic.model.Endpoint; + +public interface EndpointBackupService { + + void doBackup(Endpoint endpoint); + + void cleanAllBackupData(); // dangerous + +} diff --git a/src/main/java/br/com/concrete/mock/generic/service/GenericApiService.java b/src/main/java/br/com/concrete/mock/generic/service/GenericApiService.java new file mode 100755 index 0000000..6817212 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/service/GenericApiService.java @@ -0,0 +1,18 @@ +package br.com.concrete.mock.generic.service; + +import java.util.Map; +import java.util.Optional; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.http.ResponseEntity; + +import br.com.concrete.mock.generic.model.Request; + +public interface GenericApiService { + + Optional> genericResponseEntity(Request request); + + Map getHeaders(final HttpServletRequest request); + +} diff --git a/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java b/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java new file mode 100755 index 0000000..0d17f55 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java @@ -0,0 +1,95 @@ +package br.com.concrete.mock.generic.service.impl; + +import br.com.concrete.mock.generic.mapper.EndpointDto; +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.generic.repository.EndpointRepository; +import br.com.concrete.mock.generic.service.EndpointBackupService; +import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.concrete.mock.infra.component.file.BaseFileNameBuilder; +import br.com.concrete.mock.infra.component.file.FileNameGenerator; +import br.com.concrete.mock.infra.component.impl.JsonFormatterPretty; +import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.concrete.mock.infra.property.FileProperty; +import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; +import org.springframework.util.FileSystemUtils; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +@Service +public class EndpointBackupServiceFile implements EndpointBackupService { + + private static final Logger LOGGER = LoggerFactory.getLogger(EndpointBackupServiceFile.class); + + private final FileProperty fileProperty; + private final FileExtensionProperty fileExtensionProperty; + private final BaseFileNameBuilder baseFileNameBuilder; + private final FileNameGenerator fileNameGenerator; + private final FromJsonStringToObjectConverter fromJsonStringToObjectConverter; + private final JsonFormatterPretty jsonFormatterPretty; + private final EndpointRepository endpointRepository; + + @Autowired + public EndpointBackupServiceFile(@Qualifier("FilePropertyBackup") FileProperty fileProperty, FileExtensionProperty fileExtensionProperty, @Qualifier("BaseFileNameBuilderBackup") BaseFileNameBuilder baseFileNameBuilder, FileNameGenerator fileNameGenerator, FromJsonStringToObjectConverter fromJsonStringToObjectConverter, JsonFormatterPretty jsonFormatterPretty, @Qualifier("EndpointRepositoryBackup") EndpointRepository endpointRepository) { + this.fileProperty = fileProperty; + this.fileExtensionProperty = fileExtensionProperty; + this.baseFileNameBuilder = baseFileNameBuilder; + this.fileNameGenerator = fileNameGenerator; + this.fromJsonStringToObjectConverter = fromJsonStringToObjectConverter; + this.jsonFormatterPretty = jsonFormatterPretty; + this.endpointRepository = endpointRepository; + } + + public void doBackup(Endpoint endpoint) { + final Boolean isNeedToCreateABackup = endpointRepository + .getByMethodAndRequest(endpoint.getRequest()) + .map(e -> { + LOGGER.info("Existent backup not replaced [id=" + e.getId().orElse("no_id") + "]"); + return false; + }) + .orElse(true); + + if (isNeedToCreateABackup) execute(endpoint); + } + + private Boolean execute(final Endpoint endpoint) { + final Request request = endpoint.getRequest(); + + final String pathName = baseFileNameBuilder.buildPath(fileProperty.getFileBase(), request.getMethod().name().toLowerCase(), request.getUri()); + final String fileName = pathName + "/" + fileNameGenerator.fromPath(pathName).concat(fileExtensionProperty.getFileExtension()); + + final EndpointDto endpointDto = new EndpointDto(endpoint, fromJsonStringToObjectConverter); + final String endpointJson = jsonFormatterPretty.format(new Gson().toJson(endpointDto)); + + try { + Files.createDirectories(Paths.get(pathName)); + Files.write(Paths.get(fileName), endpointJson.getBytes()); + + LOGGER.info("Backup into " + fileName); + } catch (IOException e) { + LOGGER.error("Cannot backup endpoint {}", e); + } + return true; + } + + public void cleanAllBackupData() { + try { + final String backupPath = fileProperty.getFileBase(); + Files + .list(Paths.get(backupPath)) + .map(path -> path.getFileName().toFile()) + .filter(file -> !file.getName().startsWith(".")) + .forEach(FileSystemUtils::deleteRecursively); + } catch (IOException e) { + LOGGER.error("Cannot list backup files {}", e); + } + } + +} diff --git a/src/main/java/br/com/concrete/mock/generic/service/impl/GenericApiServiceImpl.java b/src/main/java/br/com/concrete/mock/generic/service/impl/GenericApiServiceImpl.java new file mode 100755 index 0000000..448bd99 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/generic/service/impl/GenericApiServiceImpl.java @@ -0,0 +1,90 @@ +package br.com.concrete.mock.generic.service.impl; + +import br.com.concrete.mock.configuration.service.CaptureExecutor; +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.generic.repository.EndpointRepository; +import br.com.concrete.mock.generic.service.GenericApiService; +import br.com.concrete.mock.infra.component.ExternalApi; +import br.com.concrete.mock.infra.component.JsonValueCompiler; +import br.com.concrete.mock.infra.property.ApiProperty; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +@Service +public class GenericApiServiceImpl implements GenericApiService { + + private final EndpointRepository endpointRepository; + private final ExternalApi externalApi; + private final CaptureExecutor captureExecutor; + private final JsonValueCompiler jsonValueCompiler; + private final ApiProperty apiProperty; + + @Autowired + public GenericApiServiceImpl(@Qualifier("EndpointRepositoryModel") EndpointRepository endpointRepository, + ExternalApi externalApi, CaptureExecutor captureExecutor, JsonValueCompiler jsonValueCompiler, ApiProperty apiProperty) { + this.endpointRepository = endpointRepository; + this.externalApi = externalApi; + this.captureExecutor = captureExecutor; + this.jsonValueCompiler = jsonValueCompiler; + this.apiProperty = apiProperty; + } + + private Optional getEndpoint(Request request) { + return endpointRepository.getByMethodAndRequest(request); + } + + // TODO refatorar esse método + @Override + public Optional> genericResponseEntity(Request request) { + final Endpoint endpointNotSafe = getEndpoint(request).orElse(null); + + final Optional> apiResult; + + // TODO refatorar: esta no if porque estava dando problema ao colocar + // dentro do orElse() + if (endpointNotSafe == null) { + apiResult = externalApi.execute(request).map(r -> { + captureExecutor.execute(r, new Endpoint.Builder(request, r.getApiResult()).build()); + return r.getApiResult(); + }); + } else { + final String body = jsonValueCompiler.compile(endpointNotSafe.getResponse().getBody()); + apiResult = Optional.of( + new ResponseEntity<>(body, endpointNotSafe.getResponse().getHttpStatus().orElse(HttpStatus.OK))); + } + + return apiResult.map(responseEntity -> { + final ResponseEntity.BodyBuilder bodyBuilder = ResponseEntity.status(responseEntity.getStatusCode()); + + apiProperty.getDefaultHeaders().forEach(header -> { + final String headerName = header.getHeaderName(); + final String[] headerValues = header.getHeaderValues().stream().toArray(String[]::new); + bodyBuilder.header(headerName, headerValues); + }); + + return bodyBuilder.body(responseEntity.getBody()); + }); + } + + public Map getHeaders(final HttpServletRequest request) { + Map map = new HashMap<>(); + Enumeration headerNames = request.getHeaderNames(); + while (headerNames.hasMoreElements()) { + String key = headerNames.nextElement(); + String value = request.getHeader(key); + map.put(key, value); + } + return map; + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/CompareJson.java b/src/main/java/br/com/concrete/mock/infra/component/CompareJson.java new file mode 100755 index 0000000..044b899 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/CompareJson.java @@ -0,0 +1,40 @@ +package br.com.concrete.mock.infra.component; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +@Component +public class CompareJson { + + private final ConvertJson convertJson; + + @Autowired + public CompareJson(ConvertJson convertJson) { + this.convertJson = convertJson; + } + + public Boolean isEquivalent(String jsonKey, String jsonToCompare) { + final HashMap keys = convertJson.apply(jsonKey); + final HashMap toCompare = convertJson.apply(jsonToCompare); + + for (Object entrySet : keys.entrySet()) { + Map.Entry entry = (Map.Entry) entrySet; + final Object valueCompare = toCompare.get(entry.getKey()); + + if(valueCompare instanceof LinkedHashMap && entry.getValue() instanceof LinkedHashMap){ + return ((LinkedHashMap)valueCompare).size() == ((LinkedHashMap) entry.getValue()).size(); + } + + if (!entry.getValue().equals(valueCompare)) { + return false; + } + } + + return true; + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/CompareMap.java b/src/main/java/br/com/concrete/mock/infra/component/CompareMap.java new file mode 100755 index 0000000..e64de1b --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/CompareMap.java @@ -0,0 +1,26 @@ +package br.com.concrete.mock.infra.component; + +import org.springframework.stereotype.Component; + +import java.util.Map; + +@Component +public class CompareMap { + + public Boolean isEquivalent(Map value, Map valueToCompare) { + for (Map.Entry entrySet : value.entrySet()) { + final K key = entrySet.getKey(); + if (!valueToCompare.containsKey(key)) { + return false; + } + + final V valueCompare = valueToCompare.get(key); + if (!entrySet.getValue().equals(valueCompare)) { + return false; + } + } + + return true; + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/ConvertJson.java b/src/main/java/br/com/concrete/mock/infra/component/ConvertJson.java new file mode 100755 index 0000000..a1e4484 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/ConvertJson.java @@ -0,0 +1,10 @@ +package br.com.concrete.mock.infra.component; + +import java.util.HashMap; + +@FunctionalInterface +public interface ConvertJson { + + HashMap apply(String jsonKey); + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java b/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java new file mode 100755 index 0000000..a8e6a56 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java @@ -0,0 +1,90 @@ +package br.com.concrete.mock.infra.component; + +import br.com.concrete.mock.configuration.model.CaptureState; +import br.com.concrete.mock.configuration.repository.CaptureStateRepository; +import br.com.concrete.mock.generic.model.ExternalApiResult; +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.infra.model.UriConfiguration; +import br.com.concrete.mock.infra.property.ApiProperty; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import java.util.Optional; +import java.util.regex.Pattern; + +@Component +public class ExternalApi { + + private static final Logger LOGGER = LoggerFactory.getLogger(ExternalApi.class); + + private final ApiProperty apiProperty; + private final QueryStringBuilder queryStringBuilder; + private final RestTemplate restTemplate; + private final HeaderFilter headerFilter; + private final CaptureStateRepository captureStateRepository; + + @Autowired + public ExternalApi(ApiProperty apiProperty, QueryStringBuilder queryStringBuilder, RestTemplate restTemplate, + HeaderFilter headerFilter, CaptureStateRepository captureStateRepository) { + this.apiProperty = apiProperty; + this.queryStringBuilder = queryStringBuilder; + this.restTemplate = restTemplate; + this.headerFilter = headerFilter; + this.captureStateRepository = captureStateRepository; + } + + public Optional execute(final Request request) { + final Boolean state = captureStateRepository + .getCurrent() + .map(CaptureState::isEnabled) + .orElse(true); + + + final UriConfiguration uriConfiguration = apiProperty + .getConfiguration(request.getUri()) + .orElse(new UriConfiguration(apiProperty.getHost(), Pattern.compile(".*"), state)); + final Optional httpHeaders = headerFilter.execute(request.getHeaders()); + + LOGGER.info("### EXTERNAL API ###"); + LOGGER.info("{}", uriConfiguration); + request.getBody().ifPresent(LOGGER::info); + httpHeaders.ifPresent(list -> LOGGER.info(list.toString())); + + final HttpEntity entity = httpHeaders + .map(headers -> request.getBody().map(body -> new HttpEntity<>(body, headers)) + .orElse(new HttpEntity<>(headers))) + .orElse(request.getBody().map(HttpEntity::new).orElse(new HttpEntity<>((String) null))); + + final String parameters = request.getQuery().map(queryStringBuilder::fromMap).orElse(""); + final String url = uriConfiguration + .getHost() + .concat(request.getUri()) + .concat(parameters); + + LOGGER.info("URL => {}", url); + ResponseEntity apiResult = null; + try { + apiResult = restTemplate.exchange(url, HttpMethod.valueOf(request.getMethod().name().toUpperCase()), entity, + String.class); + return Optional.of(new ExternalApiResult(apiResult, uriConfiguration)); + } catch (Exception e) { + LOGGER.error("Erro chamada API " + HttpMethod.valueOf(request.getMethod().name().toUpperCase()) + " " + url, + e); + + LOGGER.error("Tentando mais uma vez " + HttpMethod.valueOf(request.getMethod().name().toUpperCase()) + " " + + url); + } + // } + + return Optional.empty(); + + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/FromJsonStringToObjectConverter.java b/src/main/java/br/com/concrete/mock/infra/component/FromJsonStringToObjectConverter.java new file mode 100755 index 0000000..d5fe862 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/FromJsonStringToObjectConverter.java @@ -0,0 +1,10 @@ +package br.com.concrete.mock.infra.component; + +import java.util.Optional; + +@FunctionalInterface +public interface FromJsonStringToObjectConverter { + + Object apply(final Optional json); + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/HeaderFilter.java b/src/main/java/br/com/concrete/mock/infra/component/HeaderFilter.java new file mode 100755 index 0000000..baeb783 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/HeaderFilter.java @@ -0,0 +1,44 @@ +package br.com.concrete.mock.infra.component; + +import br.com.concrete.mock.infra.property.ApiProperty; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Component; + +import java.util.Objects; +import java.util.Optional; + +@Component +public class HeaderFilter { + private final ApiProperty apiProperty; + + @Autowired + public HeaderFilter(ApiProperty apiProperty) { + this.apiProperty = apiProperty; + } + + public Optional execute(Optional headers) { + return headers + .map(h -> { + final HttpHeaders httpHeaders = new HttpHeaders(); + + h + .entrySet() + .stream() + .filter(value -> apiProperty.isAcceptedHeader(value.getKey())) + .forEach(entry -> { + Optional + .ofNullable(entry.getValue()) + .filter(Objects::nonNull) + .filter(value -> !value.isEmpty()) + .map(value -> value.stream().findFirst().get()) + .ifPresent(value -> httpHeaders.add(entry.getKey(), value)); + }); + + return httpHeaders; + } + ); + } + + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/JsonFormatter.java b/src/main/java/br/com/concrete/mock/infra/component/JsonFormatter.java new file mode 100755 index 0000000..252e830 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/JsonFormatter.java @@ -0,0 +1,7 @@ +package br.com.concrete.mock.infra.component; + +public interface JsonFormatter { + + String format(final String jsonString); + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/JsonValueCompiler.java b/src/main/java/br/com/concrete/mock/infra/component/JsonValueCompiler.java new file mode 100755 index 0000000..887e53d --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/JsonValueCompiler.java @@ -0,0 +1,8 @@ +package br.com.concrete.mock.infra.component; + +@FunctionalInterface +public interface JsonValueCompiler { + + String compile(final String json); + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/QueryStringBuilder.java b/src/main/java/br/com/concrete/mock/infra/component/QueryStringBuilder.java new file mode 100755 index 0000000..be9a651 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/QueryStringBuilder.java @@ -0,0 +1,7 @@ +package br.com.concrete.mock.infra.component; + +import java.util.Map; + +public interface QueryStringBuilder { + String fromMap(Map queryMap); +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/RequestFormatter.java b/src/main/java/br/com/concrete/mock/infra/component/RequestFormatter.java new file mode 100755 index 0000000..431302d --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/RequestFormatter.java @@ -0,0 +1,10 @@ +package br.com.concrete.mock.infra.component; + +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; + +public interface RequestFormatter { + + String generateLog(final HttpServletRequest request, final Optional requestBody); + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilder.java b/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilder.java new file mode 100755 index 0000000..ab5952f --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilder.java @@ -0,0 +1,11 @@ +package br.com.concrete.mock.infra.component.file; + +import org.springframework.web.bind.annotation.RequestMethod; + +public interface BaseFileNameBuilder { + + String buildPath(RequestMethod requestMethod, String pathUri); + + String buildPath(String fileBaseName, String methodName, String pathUri); + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBackup.java b/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBackup.java new file mode 100755 index 0000000..ae5d127 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBackup.java @@ -0,0 +1,16 @@ +package br.com.concrete.mock.infra.component.file; + +import br.com.concrete.mock.infra.property.FileProperty; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +@Component("BaseFileNameBuilderBackup") +public class BaseFileNameBuilderBackup extends BaseFileNameBuilderBase implements BaseFileNameBuilder { + + @Autowired + public BaseFileNameBuilderBackup(@Qualifier("FilePropertyBackup") FileProperty fileProperty) { + super(fileProperty); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBase.java b/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBase.java new file mode 100755 index 0000000..e03f227 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBase.java @@ -0,0 +1,27 @@ +package br.com.concrete.mock.infra.component.file; + +import br.com.concrete.mock.infra.property.FileProperty; +import org.springframework.web.bind.annotation.RequestMethod; + +public class BaseFileNameBuilderBase implements BaseFileNameBuilder { + + private final FileProperty fileProperty; + + public BaseFileNameBuilderBase(FileProperty fileProperty) { + this.fileProperty = fileProperty; + } + + public String buildPath(RequestMethod requestMethod, String pathUri) { + return buildPath(fileProperty.getFileBase(), requestMethod.name().toLowerCase(), pathUri); + } + + public String buildPath(String fileBaseName, String methodName, String pathUri) { + return new StringBuilder() + .append(fileBaseName) + .append("/") + .append(methodName) + .append(pathUri) + .toString(); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModel.java b/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModel.java new file mode 100755 index 0000000..eb6114e --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModel.java @@ -0,0 +1,16 @@ +package br.com.concrete.mock.infra.component.file; + +import br.com.concrete.mock.infra.property.FileProperty; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +@Component("BaseFileNameBuilderModel") +public class BaseFileNameBuilderModel extends BaseFileNameBuilderBase implements BaseFileNameBuilder { + + @Autowired + public BaseFileNameBuilderModel(@Qualifier("FilePropertyModel") FileProperty fileProperty) { + super(fileProperty); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/FileJsonReader.java b/src/main/java/br/com/concrete/mock/infra/component/file/FileJsonReader.java new file mode 100755 index 0000000..edf7c78 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/file/FileJsonReader.java @@ -0,0 +1,32 @@ +package br.com.concrete.mock.infra.component.file; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; + +@Component +public class FileJsonReader { + + private static final Logger LOGGER = LoggerFactory.getLogger(FileJsonReader.class); + + public Optional getJsonByFileName(String fileName) throws IOException { + return Optional + .of(Paths.get(fileName)) + .filter(path -> Files.exists(path)) + .map(path -> { + try { + return new String(Files.readAllBytes(path)); + } catch (IOException e) { + LOGGER.error("Cannot to read json from file", e); + return null; + } + }) + .filter(json -> json != null); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/FileNameGenerator.java b/src/main/java/br/com/concrete/mock/infra/component/file/FileNameGenerator.java new file mode 100755 index 0000000..80c511c --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/file/FileNameGenerator.java @@ -0,0 +1,7 @@ +package br.com.concrete.mock.infra.component.file; + +public interface FileNameGenerator { + + String fromPath(final String path); + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImpl.java b/src/main/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImpl.java new file mode 100755 index 0000000..2bd46cd --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImpl.java @@ -0,0 +1,40 @@ +package br.com.concrete.mock.infra.component.file; + +import br.com.concrete.mock.infra.property.FileExtensionProperty; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +@Component +public class FileNameGeneratorImpl implements FileNameGenerator { + + private final FileExtensionProperty fileExtensionProperty; + + @Autowired + public FileNameGeneratorImpl(FileExtensionProperty fileExtensionProperty) { + this.fileExtensionProperty = fileExtensionProperty; + } + + public String fromPath(final String pathName) { + try { + final Long count = Files.list(Paths.get(pathName)).count(); + return getNewFileName(pathName, count); + } catch (IOException e) { + return "1"; + } + } + + private String getNewFileName(final String pathName, final Long fileCount) { + final long newFileCount = fileCount + 1; + final String newFileName = getFileName(pathName, newFileCount); + return Files.exists(Paths.get(newFileName)) ? getNewFileName(pathName, newFileCount) : String.valueOf(newFileCount); + } + + private String getFileName(final String pathName, final Long count) { + return Paths.get(pathName, String.valueOf(count) + fileExtensionProperty.getFileExtension()).toFile().getAbsolutePath(); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImpl.java b/src/main/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImpl.java new file mode 100755 index 0000000..9c82e90 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImpl.java @@ -0,0 +1,28 @@ +package br.com.concrete.mock.infra.component.impl; + +import br.com.concrete.mock.infra.component.ConvertJson; +import br.com.concrete.mock.infra.exception.impl.JsonApiApplicationException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.HashMap; + +@Component +public class ConvertJsonImpl implements ConvertJson { + + private static final Logger LOGGER = LoggerFactory.getLogger(ConvertJson.class); + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + public HashMap apply(String jsonKey) { + try { + return OBJECT_MAPPER.readValue(jsonKey, HashMap.class); + } catch (IOException e) { + LOGGER.error("Cannot to convert json to HashMap", e); + throw new JsonApiApplicationException(e.getMessage()); + } + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java b/src/main/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java new file mode 100755 index 0000000..33ff502 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java @@ -0,0 +1,26 @@ +package br.com.concrete.mock.infra.component.impl; + +import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; +import com.google.gson.JsonParser; +import org.springframework.stereotype.Component; + +import java.util.Optional; + +@Component +public class FromJsonStringToObjectConverterImpl implements FromJsonStringToObjectConverter { + + private static final JsonParser JSON_PARSER = new JsonParser(); + + @Override + public Object apply(final Optional json) { + return json + .map(JSON_PARSER::parse) + .filter(jsonElement -> !jsonElement.isJsonNull()) + .map(jsonElement -> jsonElement.isJsonObject() ? + jsonElement.getAsJsonObject() : + jsonElement.getAsJsonArray() + ) + .orElse(JSON_PARSER.parse("").getAsJsonNull()); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPretty.java b/src/main/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPretty.java new file mode 100755 index 0000000..79c5553 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPretty.java @@ -0,0 +1,22 @@ +package br.com.concrete.mock.infra.component.impl; + +import br.com.concrete.mock.infra.component.JsonFormatter; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import org.springframework.stereotype.Component; + +@Component +public class JsonFormatterPretty implements JsonFormatter { + + @Override + public String format(final String jsonString) { + final JsonParser parser = new JsonParser(); + final Gson gson = new GsonBuilder().setPrettyPrinting().create(); + + final JsonElement el = parser.parse(jsonString); + return gson.toJson(el).concat("\n"); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImpl.java b/src/main/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImpl.java new file mode 100755 index 0000000..ca6620d --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImpl.java @@ -0,0 +1,33 @@ +package br.com.concrete.mock.infra.component.impl; + +import br.com.concrete.mock.infra.component.JsonValueCompiler; +import org.springframework.stereotype.Component; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@Component +public class JsonValueCompilerImpl implements JsonValueCompiler { + + @Override + public String compile(String json) { + // http://regexr.com/3f7lq + final Pattern p = Pattern.compile("\\#\\{\\{(\\d)+daysAgo:([a-z]+?.*?[a-z]+?)\\}\\}", Pattern.CASE_INSENSITIVE); + final Matcher m = p.matcher(json); + + final StringBuffer sb = new StringBuffer(); + while (m.find()) { + final Integer daysAgo = Integer.valueOf(m.group(1)); + final String format = m.group(2); + + final String dateFormatted = LocalDate.now().minusDays(daysAgo).format(DateTimeFormatter.ofPattern(format)); + + m.appendReplacement(sb, dateFormatted); + } + m.appendTail(sb); + return sb.toString(); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImpl.java b/src/main/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImpl.java new file mode 100755 index 0000000..1e6edc4 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImpl.java @@ -0,0 +1,35 @@ +package br.com.concrete.mock.infra.component.impl; + +import br.com.concrete.mock.infra.component.ConvertJson; +import br.com.concrete.mock.infra.component.QueryStringBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Map; + +@Component +public class QueryStringBuilderImpl implements QueryStringBuilder { + + private static final Logger LOGGER = LoggerFactory.getLogger(QueryStringBuilderImpl.class); + + private final ConvertJson convertJson; + + @Autowired + public QueryStringBuilderImpl(ConvertJson convertJson) { + this.convertJson = convertJson; + } + + @Override + public String fromMap(Map queryMap) { + return queryMap + .entrySet() + .stream() + .map(entry -> "&".concat(entry.getKey()).concat("=").concat(entry.getValue())) + .reduce(String::concat) + .map(s -> "?" + s.substring(1, s.length())) + .orElse(""); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/RequestFormatterImpl.java b/src/main/java/br/com/concrete/mock/infra/component/impl/RequestFormatterImpl.java new file mode 100755 index 0000000..ee6f421 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/component/impl/RequestFormatterImpl.java @@ -0,0 +1,21 @@ +package br.com.concrete.mock.infra.component.impl; + +import br.com.concrete.mock.infra.component.RequestFormatter; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import java.util.Optional; + +@Component +public class RequestFormatterImpl implements RequestFormatter { + + public String generateLog(HttpServletRequest request, Optional requestBody) { + return new StringBuilder() + .append(request.getMethod()) + .append(": ") + .append(request.getRequestURL()) + .append(request.getQueryString() == null ? "" : "?" + request.getQueryString()) + .toString(); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/exception/ApplicationException.java b/src/main/java/br/com/concrete/mock/infra/exception/ApplicationException.java new file mode 100755 index 0000000..197418d --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/exception/ApplicationException.java @@ -0,0 +1,7 @@ +package br.com.concrete.mock.infra.exception; + +public interface ApplicationException { + + ApplicationExceptionMessage buildApplicationExceptionMessage(); + +} diff --git a/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionHandler.java b/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionHandler.java new file mode 100755 index 0000000..3cf7b21 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionHandler.java @@ -0,0 +1,69 @@ +package br.com.concrete.mock.infra.exception; + +import br.com.concrete.mock.infra.exception.impl.ApiApplicationException; +import br.com.concrete.mock.infra.exception.impl.ApplicationExceptionImpl; +import br.com.concrete.mock.infra.exception.impl.ApplicationExceptionMessageImpl; +import br.com.concrete.mock.infra.exception.impl.ErrorApplicationException; +import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.ResourceAccessException; + +@ControllerAdvice +public class ApplicationExceptionHandler { + + private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationExceptionHandler.class); + private static final Gson GSON = new Gson(); + + @ResponseStatus(HttpStatus.BAD_REQUEST) + @ExceptionHandler(ApplicationExceptionImpl.class) + @ResponseBody + public ApplicationExceptionMessage handleBadRequest(ApplicationException e) { + final ApplicationExceptionMessage applicationExceptionMessage = e.buildApplicationExceptionMessage(); + LOGGER.error("handleBadRequest", e); + return applicationExceptionMessage; + } + + @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) + @ExceptionHandler(ErrorApplicationException.class) + @ResponseBody + public ApplicationExceptionMessage handleMockError(ErrorApplicationException e) { + final ApplicationExceptionMessage applicationExceptionMessage = e.buildApplicationExceptionMessage(); + LOGGER.error("handleMockApiError", e); + return e.buildApplicationExceptionMessage(); + } + + @ResponseStatus(HttpStatus.EXPECTATION_FAILED) + @ExceptionHandler(ApiApplicationException.class) + @ResponseBody + public ApplicationExceptionMessage handleApiException(ApiApplicationException e) { + final ApplicationExceptionMessage applicationExceptionMessage = e.buildApplicationExceptionMessage(); + LOGGER.error("handleApiException", e); + return e.buildApplicationExceptionMessage(); + } + + @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) + @ExceptionHandler(ResourceAccessException.class) + @ResponseBody + public ApplicationExceptionMessage handleResourceAccessException(ResourceAccessException e) { + final ApplicationExceptionMessage applicationExceptionMessage = new ApplicationExceptionMessageImpl(String.valueOf(HttpStatus.UNPROCESSABLE_ENTITY.value()), e.getMessage()); + LOGGER.error("handleResourceAccessException", e); + return applicationExceptionMessage; + } + + @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) + @ExceptionHandler(HttpClientErrorException.class) + @ResponseBody + public ApplicationExceptionMessage handleHttpClientErrorException(HttpClientErrorException e) { + final ApplicationExceptionMessageImpl applicationExceptionMessage = GSON.fromJson(e.getResponseBodyAsString(), ApplicationExceptionMessageImpl.class); + LOGGER.error("handleHttpClientErrorException", e); + return applicationExceptionMessage; + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionMessage.java b/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionMessage.java new file mode 100755 index 0000000..4a5d7d9 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionMessage.java @@ -0,0 +1,9 @@ +package br.com.concrete.mock.infra.exception; + +public interface ApplicationExceptionMessage { + + String getCodigo(); + + String getMensagem(); + +} diff --git a/src/main/java/br/com/concrete/mock/infra/exception/impl/ApiApplicationException.java b/src/main/java/br/com/concrete/mock/infra/exception/impl/ApiApplicationException.java new file mode 100755 index 0000000..ff25bb0 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/exception/impl/ApiApplicationException.java @@ -0,0 +1,12 @@ +package br.com.concrete.mock.infra.exception.impl; + +import br.com.concrete.mock.infra.exception.ApplicationException; +import org.springframework.http.HttpStatus; + +public class ApiApplicationException extends ApplicationExceptionImpl implements ApplicationException { + + public ApiApplicationException(String mensagem) { + super(String.valueOf(HttpStatus.EXPECTATION_FAILED.value()), "Internal Mock API exception: ".concat(mensagem)); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionImpl.java b/src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionImpl.java new file mode 100755 index 0000000..c7c7e16 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionImpl.java @@ -0,0 +1,20 @@ +package br.com.concrete.mock.infra.exception.impl; + +import br.com.concrete.mock.infra.exception.ApplicationException; +import br.com.concrete.mock.infra.exception.ApplicationExceptionMessage; + +public class ApplicationExceptionImpl extends RuntimeException implements ApplicationException { + + private final String codigo; + + public ApplicationExceptionImpl(String codigo, String mensagem) { + super(mensagem); + this.codigo = codigo; + } + + @Override + public ApplicationExceptionMessage buildApplicationExceptionMessage() { + return new ApplicationExceptionMessageImpl(codigo, getMessage()); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java b/src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java new file mode 100755 index 0000000..cf7fbe2 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java @@ -0,0 +1,27 @@ +package br.com.concrete.mock.infra.exception.impl; + +import br.com.concrete.mock.infra.exception.ApplicationExceptionMessage; + +import java.io.Serializable; + +public class ApplicationExceptionMessageImpl implements ApplicationExceptionMessage, Serializable { + + private final String codigo; + private final String mensagem; + + public ApplicationExceptionMessageImpl(String codigo, String mensagem) { + this.codigo = codigo; + this.mensagem = mensagem; + } + + @Override + public String getCodigo() { + return codigo; + } + + @Override + public String getMensagem() { + return mensagem; + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/exception/impl/ErrorApplicationException.java b/src/main/java/br/com/concrete/mock/infra/exception/impl/ErrorApplicationException.java new file mode 100755 index 0000000..060e6d9 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/exception/impl/ErrorApplicationException.java @@ -0,0 +1,11 @@ +package br.com.concrete.mock.infra.exception.impl; + +import br.com.concrete.mock.infra.exception.ApplicationException; + +public class ErrorApplicationException extends ApplicationExceptionImpl implements ApplicationException { + + public ErrorApplicationException(String codigo, String mensagem) { + super(codigo, mensagem); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/exception/impl/JsonApiApplicationException.java b/src/main/java/br/com/concrete/mock/infra/exception/impl/JsonApiApplicationException.java new file mode 100755 index 0000000..3c355c5 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/exception/impl/JsonApiApplicationException.java @@ -0,0 +1,12 @@ +package br.com.concrete.mock.infra.exception.impl; + +import br.com.concrete.mock.infra.exception.ApplicationException; +import org.springframework.http.HttpStatus; + +public class JsonApiApplicationException extends ApplicationExceptionImpl implements ApplicationException { + + public JsonApiApplicationException(String mensagem) { + super(String.valueOf(HttpStatus.EXPECTATION_FAILED.value()), "Internal Mock API exception on convert json: ".concat(mensagem)); + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/model/DefaultHeader.java b/src/main/java/br/com/concrete/mock/infra/model/DefaultHeader.java new file mode 100644 index 0000000..3d33c31 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/model/DefaultHeader.java @@ -0,0 +1,54 @@ +package br.com.concrete.mock.infra.model; + +import java.io.Serializable; +import java.util.List; +import java.util.Objects; + +public class DefaultHeader implements Serializable { + + private static final long serialVersionUID = 6319619000946506689L; + + private String headerName; + private List headerValues; + + public DefaultHeader(String headerName, List headerValues) { + this.headerName = headerName; + this.headerValues = headerValues; + } + + public DefaultHeader() { + + } + // String headerName + // String... headerValues; + + public void setHeaderName(String headerName) { + this.headerName = headerName; + } + + public void setHeaderValues(List headerValues) { + this.headerValues = headerValues; + } + + public String getHeaderName() { + return headerName; + } + + public List getHeaderValues() { + return headerValues; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DefaultHeader that = (DefaultHeader) o; + return Objects.equals(headerName, that.headerName) && + Objects.equals(headerValues, that.headerValues); + } + + @Override + public int hashCode() { + return Objects.hash(headerName, headerValues); + } +} diff --git a/src/main/java/br/com/concrete/mock/infra/model/UriConfiguration.java b/src/main/java/br/com/concrete/mock/infra/model/UriConfiguration.java new file mode 100644 index 0000000..dca3278 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/model/UriConfiguration.java @@ -0,0 +1,68 @@ +package br.com.concrete.mock.infra.model; + +import java.io.Serializable; +import java.util.Objects; +import java.util.Optional; +import java.util.regex.Pattern; + +public class UriConfiguration implements Serializable { + + private String host; + private Pattern pattern; + private Boolean backup; + + public UriConfiguration(String host, Pattern pattern, Boolean backup) { + this.host = host; + this.pattern = pattern; + this.backup = backup; + } + + public UriConfiguration() { + this.backup = true; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public Pattern getPattern() { + return pattern; + } + + public void setPattern(String pattern) { + this.pattern = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); + } + + public Boolean isActiveBackup() { + return Optional.ofNullable(backup).orElse(true); + } + + public void setBackup(Boolean backup) { + this.backup = backup; + } + + @Override + public String toString() { + return "UriConfiguration [host=" + host + ", pattern=" + pattern + ", backup=" + backup + "]"; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UriConfiguration that = (UriConfiguration) o; + return Objects.equals(host, that.host) && + Objects.equals(pattern.pattern(), that.pattern.pattern()) && + Objects.equals(pattern.flags(), that.pattern.flags()) && + Objects.equals(backup, that.backup); + } + + @Override + public int hashCode() { + return Objects.hash(host, pattern, backup); + } +} diff --git a/src/main/java/br/com/concrete/mock/infra/property/ApiProperty.java b/src/main/java/br/com/concrete/mock/infra/property/ApiProperty.java new file mode 100755 index 0000000..563be5a --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/property/ApiProperty.java @@ -0,0 +1,71 @@ +package br.com.concrete.mock.infra.property; + +import br.com.concrete.mock.infra.model.DefaultHeader; +import br.com.concrete.mock.infra.model.UriConfiguration; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import static java.util.Collections.emptyList; + +@Component +@ConfigurationProperties(prefix = "api") +public class ApiProperty { + + private List acceptedHeaders; + private String host; + private List uriConfigurations; + private List defaultHeaders; + + public List getAcceptedHeaders() { + return acceptedHeaders; + } + + public void setAcceptedHeaders(List acceptedHeaders) { + this.acceptedHeaders = acceptedHeaders.stream().map(String::toLowerCase).collect(Collectors.toList()); + } + + public Boolean isAcceptedHeader(final String headerValue) { + return acceptedHeaders.contains(headerValue.toLowerCase()); + } + + public void setUriConfigurations(List uriConfigurations) { + this.uriConfigurations = uriConfigurations; + } + + public List getUriConfigurations() { + return this.uriConfigurations; + } + + public Optional getConfiguration(String uri) { + return Optional + .ofNullable(uriConfigurations) + .orElse(emptyList()) + .stream() + .filter(config -> config.getPattern().matcher(uri).find()).findAny(); + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public List getDefaultHeaders() { + if (defaultHeaders == null) { + defaultHeaders = new ArrayList<>(); + } + return defaultHeaders; + } + + public void setDefaultHeaders(List defaultHeaders) { + this.defaultHeaders = defaultHeaders; + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/property/FileExtensionProperty.java b/src/main/java/br/com/concrete/mock/infra/property/FileExtensionProperty.java new file mode 100755 index 0000000..ed753d8 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/property/FileExtensionProperty.java @@ -0,0 +1,7 @@ +package br.com.concrete.mock.infra.property; + +public interface FileExtensionProperty { + + String getFileExtension(); + +} diff --git a/src/main/java/br/com/concrete/mock/infra/property/FileProperty.java b/src/main/java/br/com/concrete/mock/infra/property/FileProperty.java new file mode 100755 index 0000000..ffe10e5 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/property/FileProperty.java @@ -0,0 +1,7 @@ +package br.com.concrete.mock.infra.property; + +public interface FileProperty { + + String getFileBase(); + +} diff --git a/src/main/java/br/com/concrete/mock/infra/property/impl/FileExtensionPropertyImpl.java b/src/main/java/br/com/concrete/mock/infra/property/impl/FileExtensionPropertyImpl.java new file mode 100755 index 0000000..47f6dd0 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/property/impl/FileExtensionPropertyImpl.java @@ -0,0 +1,20 @@ +package br.com.concrete.mock.infra.property.impl; + +import br.com.concrete.mock.infra.property.FileExtensionProperty; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +public class FileExtensionPropertyImpl implements FileExtensionProperty { + + private final String fileExtension; + + public FileExtensionPropertyImpl(@Value("${file.extension}") String fileExtension) { + this.fileExtension = fileExtension; + } + + public String getFileExtension() { + return fileExtension; + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyBackup.java b/src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyBackup.java new file mode 100755 index 0000000..b4542c9 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyBackup.java @@ -0,0 +1,20 @@ +package br.com.concrete.mock.infra.property.impl; + +import br.com.concrete.mock.infra.property.FileProperty; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component("FilePropertyBackup") +public class FilePropertyBackup implements FileProperty { + + private final String fileBase; + + public FilePropertyBackup(@Value("${file.backup.path}") String fileBase) { + this.fileBase = fileBase; + } + + public String getFileBase() { + return fileBase; + } + +} diff --git a/src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyModel.java b/src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyModel.java new file mode 100755 index 0000000..de4ee0b --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyModel.java @@ -0,0 +1,20 @@ +package br.com.concrete.mock.infra.property.impl; + +import br.com.concrete.mock.infra.property.FileProperty; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component("FilePropertyModel") +public class FilePropertyModel implements FileProperty { + + private final String fileBase; + + public FilePropertyModel(@Value("${file.base}") String fileBase) { + this.fileBase = fileBase; + } + + public String getFileBase() { + return fileBase; + } + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100755 index 0000000..9047193 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,47 @@ +# vmoptions: -Dspring.profiles.active=test + +server.port: 9090 + +api: + acceptedHeaders: + - "accept" + - "Content-Type" + + # When is not find in repository, then will try to do a request in this host + host: "http://www.mocky.io" + + # Default headers to do a request + defaultHeaders: + - + headerName: "Access-Control-Allow-Origin" + headerValues: + - "Connection" + - "Keep-Alive" + - + headerName: "Content-Type" + headerValues: + - "application/json;charset=UTF-8" + + # Alternative hosts + # When a request uri match with some pattern, than this host will be used + uriConfigurations: + - + host: "http://www.mocky2.io" + pattern: "begin-of-uri/|another-pattern/" + backup: false + - + host: "http://www.mocky3.io" + pattern: "teste/|test/" + +# Paths of json +file: + # Look for this path to find json with a request + base: "${MOCK_API_FILE_BASE}" + extension: ".json" + # Save request (cache) in this path + backup.path: "${MOCK_BACKUP_FILE_BASE}" + +# Initialize app in capture mode. All requests will be saved +captureState: true + +debug: true diff --git a/src/test/java/br/com/concrete/mock/ApiApplicationTests.java b/src/test/java/br/com/concrete/mock/ApiApplicationTests.java new file mode 100755 index 0000000..c29a56b --- /dev/null +++ b/src/test/java/br/com/concrete/mock/ApiApplicationTests.java @@ -0,0 +1,16 @@ +package br.com.concrete.mock; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ApiApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/src/test/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java b/src/test/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java new file mode 100755 index 0000000..4085d82 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java @@ -0,0 +1,98 @@ +package br.com.concrete.mock.configuration.api.v1.controller; + +import br.com.concrete.mock.configuration.api.v1.mapper.CaptureStateDto; +import br.com.concrete.mock.configuration.model.CaptureState; +import br.com.concrete.mock.configuration.service.CaptureStateService; +import com.google.gson.Gson; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.ResultActions; + +import java.util.Optional; + +import static org.mockito.BDDMockito.given; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@WebMvcTest(CaptureStateController.class) +public class CaptureStateControllerIntegrationTest { + + @Autowired + private MockMvc mvc; + + @MockBean + private CaptureStateService captureStateService; + + @Test + public void shouldRequestStateDisabledOfCaptureMode() throws Exception { + // given + given(captureStateService.getCurrent()) + .willReturn(Optional.empty()); + + // when + final ResultActions result = this.mvc.perform(get("/configuration/capture-state").accept(MediaType.APPLICATION_JSON_UTF8)); + + // then + result.andExpect(status().isOk()) + .andExpect(content().json("{\"enabled\": false}", false)); + } + + @Test + public void shouldRequestStateEnabledOfCaptureMode() throws Exception { + // given + given(captureStateService.getCurrent()) + .willReturn(Optional.of(new CaptureState(true))); + + // when + final ResultActions result = this.mvc.perform(get("/configuration/capture-state").accept(MediaType.APPLICATION_JSON_UTF8)); + + // then + result.andExpect(status().isOk()) + .andExpect(content().json("{\"enabled\": true}", false)); + } + + @Test + public void shouldBeEnableCaptureMode() throws Exception { + // given + final CaptureState captureState = new CaptureState(true); + final String requestBody = new Gson().toJson(new CaptureStateDto(captureState)); + + given(captureStateService.enable()) + .willReturn(captureState); + + // when + final ResultActions result = this.mvc.perform( + post("/configuration/capture-state/enable") + .content(requestBody) + .contentType(MediaType.APPLICATION_JSON_UTF8) + .accept(MediaType.APPLICATION_JSON_UTF8) + ); + + // then + result.andExpect(status() + .isOk()) + .andExpect(content().json("{\"enabled\": true}", false)); + } + + @Test + public void shouldBeDisableCaptureMode() throws Exception { + // given + given(captureStateService.getCurrent()) + .willReturn(Optional.of(new CaptureState(true))); + + // when + final ResultActions result = this.mvc.perform(delete("/configuration/capture-state/disable").accept(MediaType.APPLICATION_JSON_UTF8)); + + // then + result.andExpect(status().isNoContent()); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java new file mode 100755 index 0000000..c869972 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java @@ -0,0 +1,110 @@ +package br.com.concrete.mock.generic.api.v1.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Map; +import java.util.Optional; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.skyscreamer.jsonassert.JSONAssert; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; + +import com.google.common.collect.ImmutableMap; +import com.google.gson.Gson; + +import br.com.concrete.mock.generic.mapper.EndpointDto; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class GenericApiControllerExternalIntegrationTest { + + @Autowired + private TestRestTemplate restTemplate; + + @Value("${file.base}") + private String fileBase; + @Value("${file.extension}") + private String fileExtension; + + private URL resource; + + @Before + public void init() { + this.resource = getClass().getClassLoader().getResource(fileBase); + } + + @Test + public void shouldFileExistsInTest() { + assertNotNull(resource); + assertNotNull(resource.getFile()); + } + + private String getJson(String fileNameExpected) throws IOException { + return new String(Files.readAllBytes(Paths.get(fileNameExpected))); + } + + @Test(timeout = 10000) + public void shouldResolvePostWithExternalMock() throws IOException { + shouldResolveWithExternalMock(HttpMethod.POST); + } + + @Test(timeout = 5000) + public void shouldResolvePathWithExternalMock() throws IOException { + shouldResolveWithExternalMock(HttpMethod.PATCH); + } + + private void shouldResolveWithExternalMock(final HttpMethod httpMethod) throws IOException { + final ImmutableMap headers = ImmutableMap.builder() + .put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).build(); + + shouldResolveWithExternalMock(httpMethod, Optional.of(headers)); + } + + private void shouldResolveWithExternalMock(final HttpMethod httpMethod, final Optional> headers) + throws IOException { + // given + final String url = "/v2/57fbd6280f0000ed154fd470"; + + final HttpStatus httpStatus = HttpStatus.OK; + final String fileName = resource.getFile().concat("/").concat(httpMethod.name().toLowerCase()).concat(url) + .concat("/1").concat(fileExtension); + + final EndpointDto endpointDto = new Gson().fromJson(getJson(fileName), EndpointDto.class); + final String requestJson = new Gson().toJson(endpointDto.getRequest().getBody()); + final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); + + final HttpHeaders httpHeaders = headers.filter(mapHeaders -> !mapHeaders.isEmpty()).map(map -> { + final HttpHeaders result = new HttpHeaders(); + result.setContentType(MediaType.APPLICATION_JSON); + return result; + }).orElse(null); + + final HttpEntity httpEntity = new HttpEntity<>(requestJson, httpHeaders); + + // when + final ResponseEntity response = restTemplate.exchange(url, httpMethod, httpEntity, String.class); + + // then + assertEquals(httpStatus, response.getStatusCode()); + JSONAssert.assertEquals(responseJson, response.getBody(), false); + assertNotNull(response.getHeaders().get("Access-Control-Allow-Origin")); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java new file mode 100755 index 0000000..97bb5bc --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java @@ -0,0 +1,219 @@ +package br.com.concrete.mock.generic.api.v1.controller; + +import br.com.concrete.mock.infra.component.QueryStringBuilder; +import br.com.concrete.mock.generic.mapper.EndpointDto; +import br.com.concrete.mock.generic.model.Endpoint; +import com.google.gson.Gson; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.skyscreamer.jsonassert.JSONAssert; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.*; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.io.IOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class GenericApiControllerIntegrationTest { + + @Autowired + private TestRestTemplate restTemplate; + + @Autowired + private QueryStringBuilder queryStringBuilder; + + @Value("${file.extension}") + private String fileExtension; + @Value("${file.base}") + private String fileBase; + + private URL resource; + + @Before + public void init() { + this.resource = getClass().getClassLoader().getResource(fileBase.concat("/")); + } + + @Test + public void shouldFileExistsInTest() { + assertNotNull(resource); + assertNotNull(resource.getFile()); + } + + private String getJson(String fileNameExpected) throws IOException { + final Path path = Paths.get(fileNameExpected); + return Files.exists(path) ? new String(Files.readAllBytes(path)) : "{}"; + } + + private void shouldResolveGetWithLocalMockMatchQueryCaseX(String uri, String caseX) throws IOException { + // given + final String fileName = resource.getFile().concat("get").concat(uri).concat("/").concat(caseX).concat(fileExtension); + + final String endpointJson = getJson(fileName); + + final EndpointDto endpointDto = new Gson().fromJson(endpointJson, EndpointDto.class); + final Endpoint endpoint = endpointDto.toModel(RequestMethod.GET, uri); + final String parameters = endpoint + .getRequest() + .getQuery() + .filter(queryMap -> !queryMap.isEmpty()) + .map(queryMap -> queryStringBuilder.fromMap(queryMap)) + .map(""::concat) + .orElse(""); + + final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); + + // when + final ResponseEntity response = restTemplate.getForEntity(uri.concat(parameters), String.class); + + // then + assertEquals(HttpStatus.OK, response.getStatusCode()); + JSONAssert.assertEquals(responseJson, response.getBody(), false); + } + + @Test(timeout = 2000) + public void shouldResolveGetWithSimpleResponseWithoutRequest() throws IOException { + // given + final String uri = "/guests/132/users/21/cc"; + final String fileName = resource.getFile().concat("get" + uri + "/1" + fileExtension); + final String endpointJson = getJson(fileName); + final EndpointDto endpointDto = new Gson().fromJson(endpointJson, EndpointDto.class); + final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); + + // when + final ResponseEntity response = restTemplate.getForEntity(uri, String.class); + + // then + assertNotNull(response); + assertEquals(HttpStatus.OK, response.getStatusCode()); + JSONAssert.assertEquals(responseJson, response.getBody(), false); + } + + @Test(timeout = 2000) + public void shouldResolveGetWithSimpleResponseWithRequest() throws IOException { + // given + final String uri = "/guests/132/users/22/cc"; + final String fileName = resource.getFile().concat("get" + uri + "/1" + fileExtension); + final String endpointJson = getJson(fileName); + final EndpointDto endpointDto = new Gson().fromJson(endpointJson, EndpointDto.class); + final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); + + // when + final ResponseEntity response = restTemplate.getForEntity(uri, String.class); + + // then + assertNotNull(response); + assertEquals(HttpStatus.OK, response.getStatusCode()); + JSONAssert.assertEquals(responseJson, response.getBody(), false); + } + + @Test(timeout = 2000) + public void shouldResolveGetWithLocalMock() throws IOException { + // given + final String uri = "/users/123"; + + final String fileName = resource.getFile().concat("get").concat(uri).concat("/1").concat(fileExtension); + final EndpointDto endpointDto = new Gson().fromJson(getJson(fileName), EndpointDto.class); + final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); + + // when + final ResponseEntity response = restTemplate.getForEntity(uri, String.class); + + // then + assertEquals(HttpStatus.OK, response.getStatusCode()); + JSONAssert.assertEquals(responseJson, response.getBody(), false); + } + + @Test(timeout = 2000) + public void shouldResolveWithHttpStatusCreated() throws IOException { + // given + final String uri = "/users/123"; + + final String fileName = resource.getFile().concat("get").concat(uri).concat("/2").concat(fileExtension); + final EndpointDto endpointDto = new Gson().fromJson(getJson(fileName), EndpointDto.class); + final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); + final String query = queryStringBuilder.fromMap(endpointDto.getRequest().getQuery()); + + // when + final ResponseEntity response = restTemplate.getForEntity(uri + query, String.class); + + // then + assertEquals(HttpStatus.ACCEPTED, response.getStatusCode()); + JSONAssert.assertEquals(responseJson, response.getBody(), false); + } + + @Test(timeout = 2000) + public void shouldResolvePatchWithLocalMock() throws IOException { + shouldResolveWithLocalMockMatcheRequest("/users/1456", "1", HttpStatus.OK, HttpMethod.PATCH); + } + + @Test(timeout = 2000) + public void shouldResolveGetWithLocalMockMatchQueryCase1() throws IOException { + shouldResolveGetWithLocalMockMatchQueryCaseX("/payments/user/detail", "1"); + } + + @Test(timeout = 2000) + public void shouldResolveGetWithLocalMockMatchQueryCase2() throws IOException { + shouldResolveGetWithLocalMockMatchQueryCaseX("/payments/user/detail", "2"); + } + + // fail + @Test(timeout = 2000) + public void shouldResolveGetWithLocalMockWithSubDirectory() throws IOException { + shouldResolveGetWithLocalMockMatchQueryCaseX("/guests/132", "1"); + } + + private void shouldResolvePostWithLocalMockMatcheRequest(final String url, final String caseX, final HttpStatus httpStatus) throws IOException { + shouldResolveWithLocalMockMatcheRequest(url, caseX, httpStatus, HttpMethod.POST); + } + + private void shouldResolveWithLocalMockMatcheRequest(final String uri, final String caseX, final HttpStatus httpStatus, HttpMethod httpMethod) throws IOException { + // given + final String fileName = resource.getFile().concat(httpMethod.name().toLowerCase()).concat(uri).concat("/").concat(caseX).concat(fileExtension); + + final EndpointDto endpointDto = new Gson().fromJson(getJson(fileName), EndpointDto.class); + final String requestJson = new Gson().toJson(endpointDto.getRequest().getBody()); + final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + + final HttpEntity request = new HttpEntity<>(requestJson, headers); + + // when + final ResponseEntity response = restTemplate.exchange(uri, httpMethod, request, String.class); + + // then + assertEquals(httpStatus, response.getStatusCode()); + JSONAssert.assertEquals(responseJson, response.getBody(), false); + } + + @Test(timeout = 2000) + public void shouldResolvePostWithLocalMockMatcheRequest() throws IOException { + shouldResolvePostWithLocalMockMatcheRequest("/move/to/country/13", "1", HttpStatus.OK); + } + + @Test//(timeout = 2000) + public void shouldResolvePostWithLocalMockMatcheRequestCase1() throws IOException { + shouldResolvePostWithLocalMockMatcheRequest("/move/to/country/13/pi", "1", HttpStatus.OK); + } + + @Test(timeout = 2000) + public void shouldResolvePostWithLocalMockMatcheRequestCase2() throws IOException { + shouldResolvePostWithLocalMockMatcheRequest("/move/to/country/13/pi", "2", HttpStatus.UNPROCESSABLE_ENTITY); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapperTest.java b/src/test/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapperTest.java new file mode 100755 index 0000000..5333621 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapperTest.java @@ -0,0 +1,154 @@ +package br.com.concrete.mock.generic.api.v1.mapper; + +import br.com.concrete.mock.generic.mapper.HeaderMapper; +import br.com.concrete.mock.generic.mapper.QueryMapper; +import br.com.concrete.mock.generic.model.Request; +import com.google.common.collect.ImmutableMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Answers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.skyscreamer.jsonassert.JSONAssert; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.io.Serializable; +import java.net.URISyntaxException; +import java.util.Map; +import java.util.Optional; + +import static org.junit.Assert.*; + +@RunWith(MockitoJUnitRunner.class) +public class RequestMapperTest { + + @InjectMocks + private RequestMapper requestMapper; + + @Mock(answer = Answers.CALLS_REAL_METHODS) + private QueryMapper queryMapper; + @Mock(answer = Answers.CALLS_REAL_METHODS) + private HeaderMapper headerMapper; + + @Test + public void shouldMapRequest() throws URISyntaxException { + // given + final MockHttpServletRequest httpServletRequest = new MockHttpServletRequest(); + + final RequestMethod requestMethod = RequestMethod.GET; + httpServletRequest.setMethod(requestMethod.name().toUpperCase()); + + final String uri = "http://localhost/my-request"; + httpServletRequest.setRequestURI(uri); + + // when + final Request request = requestMapper.mapper(httpServletRequest); + + // then + assertNotNull(request); + assertEquals(requestMethod, request.getMethod()); + assertEquals(uri, request.getUri()); + assertTrue(request.getHeaders().isPresent()); + assertTrue(request.getHeaders().get().isEmpty()); + assertFalse(request.getQuery().isPresent()); + assertFalse(request.getBody().isPresent()); + } + + @Test + public void shouldMapRequestWithHeaders() throws URISyntaxException { + // given + final MockHttpServletRequest httpServletRequest = new MockHttpServletRequest(); + + final String key = "keyHeader"; + final String value = "valueHeader"; + httpServletRequest.addHeader(key, value); + + final RequestMethod requestMethod = RequestMethod.GET; + httpServletRequest.setMethod(requestMethod.name().toUpperCase()); + + final String uri = "localhost://my-request"; + httpServletRequest.setRequestURI(uri); + + // whenvalue + final Request request = requestMapper.mapper(httpServletRequest); + + // then + assertNotNull(request); + assertEquals(requestMethod, request.getMethod()); + assertEquals(uri, request.getUri()); + assertTrue(request.getHeaders().isPresent()); + assertTrue(request.getHeaders().get().containsKey(key)); + assertFalse(request.getHeaders().get().get(key).isEmpty()); + assertEquals(value, request.getHeaders().get().get(key).get(0)); + } + + @Test + public void shouldMapRequestWithQueryString() throws URISyntaxException { + // given + final MockHttpServletRequest httpServletRequest = new MockHttpServletRequest(); + + final RequestMethod requestMethod = RequestMethod.GET; + httpServletRequest.setMethod(requestMethod.name().toUpperCase()); + + final String uri = "localhost://my-request"; + httpServletRequest.setRequestURI(uri); + + httpServletRequest.setQueryString("name=Paul&age=10"); + + final Map expectedQuery = ImmutableMap.builder() + .put("name", "Paul") + .put("age", "10") + .build(); + + // when + final Request request = requestMapper.mapper(httpServletRequest); + + // then + assertNotNull(request); + assertEquals(requestMethod, request.getMethod()); + assertEquals(uri, request.getUri()); + assertTrue(request.getQuery().isPresent()); + assertEquals(expectedQuery, request.getQuery().get()); + } + + @Test + public void shouldMapRequestWithBody() throws URISyntaxException { + // given + final MockHttpServletRequest httpServletRequest = new MockHttpServletRequest(); + + final RequestMethod requestMethod = RequestMethod.POST; + httpServletRequest.setMethod(requestMethod.name().toUpperCase()); + + final String uri = "localhost://my-request"; + httpServletRequest.setRequestURI(uri); + + final Optional body = Optional.of(new Person("black")); + + // when + final Request request = requestMapper.mapper(httpServletRequest, body); + + // then + assertNotNull(request); + assertEquals(requestMethod, request.getMethod()); + assertEquals(uri, request.getUri()); + assertTrue(request.getBody().isPresent()); + assertNotNull(request.getBody().get()); + JSONAssert.assertEquals("{\"color\": \"black\"}", request.getBody().get(), false); + } + + private static class Person implements Serializable { + + private final String color; + + public Person(String color) { + this.color = color; + } + + public String getColor() { + return color; + } + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java new file mode 100755 index 0000000..86c22e6 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java @@ -0,0 +1,162 @@ +package br.com.concrete.mock.generic.mapper; + +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.template.EndpointTemplate; +import br.com.concrete.mock.infra.component.impl.FromJsonStringToObjectConverterImpl; +import br.com.six2six.fixturefactory.Fixture; +import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; +import com.google.gson.Gson; +import org.junit.BeforeClass; +import org.junit.Test; +import org.skyscreamer.jsonassert.JSONAssert; +import org.springframework.web.bind.annotation.RequestMethod; + +import static org.junit.Assert.*; + +public class EndpointDtoTest { + + @BeforeClass + public static void initClass() { + FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + } + + @Test + public void shouldConvertRequest() { + // given + final String json = "{\"request\":{\"body\":[{\"run\":\"7\"}]},\"response\":{\"body\":[{\"age\":8}]}}"; + + // when + final EndpointDto endpointDto = new Gson().fromJson(json, EndpointDto.class); + final Endpoint endpoint = endpointDto.toModel(RequestMethod.GET, "/product"); + + // then + assertNotNull(endpoint); + assertNotNull(endpoint.getRequest()); + assertNotNull(endpoint.getRequest().getBody()); + assertTrue(endpoint.getRequest().getBody().isPresent()); + assertEquals("[{\"run\":\"7\"}]", endpoint.getRequest().getBody().get()); + } + + @Test + public void shouldConvertResponse() { + // given + final String json = "{\"request\":{\"body\":[{\"run\":\"7\"}]},\"response\":{\"body\":[{\"age\":8}]}}"; + + // when + final EndpointDto endpointDto = new Gson().fromJson(json, EndpointDto.class); + final Endpoint endpoint = endpointDto.toModel(RequestMethod.GET, "/product"); + + // then + assertNotNull(endpoint); + assertNotNull(endpoint.getResponse()); + assertNotNull(endpoint.getResponse().getBody()); + assertEquals("[{\"age\":8.0}]", endpoint.getResponse().getBody()); + } + + @Test + public void shouldConvertFromModel() { + // given + final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID_FULL); + final String expectedJson = "{\n" + + " \"request\": {\n" + + " \"headers\": {\n" + + " \"Accept\": [\"application/json\"]\n" + + " },\n" + + " \"query\": {\n" + + " \"age\": 10,\n" + + " \"text\": \"abc\"\n" + + " },\n" + + " \"body\": {\n" + + " \"id\": 7,\n" + + " \"name\": \"Paul\"\n" + + " }\n" + + " },\n" + + " \"response\": {\n" + + " \"body\": {\n" + + " \"name\": \"Paul\"\n" + + " },\n" + + " \"httpStatus\": 201\n" + + " }\n" + + "}"; + + // when + final EndpointDto endpointDto = new EndpointDto(endpoint, new FromJsonStringToObjectConverterImpl()); + final String json = new Gson().toJson(endpointDto); + + // then + JSONAssert.assertEquals(expectedJson, json, false); + } + + @Test + public void shouldConvertFromModelWithoutHttpStatus() { + // given + final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID_FULL); + final String expectedJson = "{\n" + + " \"request\": {\n" + + " \"headers\": {\n" + + " \"Accept\": [\"application/json\"]\n" + + " },\n" + + " \"query\": {\n" + + " \"age\": 10,\n" + + " \"text\": \"abc\"\n" + + " },\n" + + " \"body\": {\n" + + " \"name\": \"Paul\"\n" + + " }\n" + + " },\n" + + " \"response\": {\n" + + " \"body\": {\n" + + " \"name\": \"Paul\"\n" + + " }\n" + + " }\n" + + "}"; + + // when + final EndpointDto endpointDto = new EndpointDto(endpoint, new FromJsonStringToObjectConverterImpl()); + final String json = new Gson().toJson(endpointDto); + + // then + JSONAssert.assertEquals(expectedJson, json, false); + } + + @Test + public void shouldConvertFromModelWithList() { + // given + final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID_WITH_LIST); + final String expectedJson = "{\n" + + " \"request\": {\n" + + " \"headers\": {\n" + + " \"Accept\": [\n" + + " \"application/json\"\n" + + " ]\n" + + " },\n" + + " \"query\": {\n" + + " \"age\": 10,\n" + + " \"text\": \"abc\"\n" + + " },\n" + + " \"body\": [{\n" + + " \"id\": 7,\n" + + " \"name\": \"Paul\"\n" + + " }, {\n" + + " \"id\": 8,\n" + + " \"name\": \"Peter\"\n" + + " }]\n" + + " },\n" + + " \"response\": {\n" + + " \"body\": [{\n" + + " \"name\": \"Paul\"\n" + + " }, {\n" + + " \"name\": \"Peter\"\n" + + " }]\n" + + " }\n" + + "}"; + + // when + final EndpointDto endpointDto = new EndpointDto(endpoint, new FromJsonStringToObjectConverterImpl()); + final String json = new Gson().toJson(endpointDto); + + // then + JSONAssert.assertEquals(expectedJson, json, false); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointMapperTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointMapperTest.java new file mode 100755 index 0000000..7447bcc --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointMapperTest.java @@ -0,0 +1,69 @@ +package br.com.concrete.mock.generic.mapper; + +import br.com.concrete.mock.infra.component.file.FileJsonReader; +import br.com.concrete.mock.generic.model.Endpoint; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.io.IOException; +import java.net.URL; +import java.util.Optional; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class EndpointMapperTest { + + @Value("${file.base}") + private String fileBase; + @Value("${file.extension}") + private String fileExtension; + + @InjectMocks + private EndpointMapper endpointMapper; + + @Mock + private FileJsonReader fileJsonReader; + + private URL resource; + + @Before + public void init() { + this.resource = getClass().getClassLoader().getResource(fileBase.concat("/get/")); + } + + @Test + public void shouldFileExistsInTest() { + assertNotNull(resource); + assertNotNull(resource.getFile()); + } + + @Test + public void shouldMapFromResponse() throws IOException { + // given + final RequestMethod requestMethod = RequestMethod.GET; + final String requestUrl = "person/11"; + final String basePath = resource.getFile() + requestUrl; + final String fileNameResponse = basePath + "/my-mock" + fileExtension; + + // when + when(fileJsonReader.getJsonByFileName(fileNameResponse)).thenReturn(Optional.of("{\"response\":{\"body\":{\"age\": 10}}}")); + + final Optional endpointMock = endpointMapper.mapper(requestMethod, requestUrl, fileNameResponse); + + // then + assertNotNull(endpointMock); + assertTrue(endpointMock.isPresent()); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/HeaderMapperTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/HeaderMapperTest.java new file mode 100755 index 0000000..3ee0c9a --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/mapper/HeaderMapperTest.java @@ -0,0 +1,38 @@ +package br.com.concrete.mock.generic.mapper; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.http.HttpHeaders; +import org.springframework.mock.web.MockHttpServletRequest; + +import java.util.Optional; + +import static org.junit.Assert.*; + +@RunWith(MockitoJUnitRunner.class) +public class HeaderMapperTest { + + @InjectMocks + private HeaderMapper headerMapper; + + @Test + public void shouldConvertHeader() { + // given + final String key = "keyHeader"; + final String value = "valueHeader"; + final MockHttpServletRequest httpServletRequest = new MockHttpServletRequest(); + httpServletRequest.addHeader(key, value); + + // when + final Optional result = headerMapper.mapper(httpServletRequest); + + // then + assertTrue(result.isPresent()); + assertTrue(result.get().containsKey(key)); + assertFalse(result.get().get(key).isEmpty()); + assertEquals(value, result.get().get(key).get(0)); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/QueryMapperTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/QueryMapperTest.java new file mode 100755 index 0000000..6a59266 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/mapper/QueryMapperTest.java @@ -0,0 +1,77 @@ +package br.com.concrete.mock.generic.mapper; + +import com.google.common.collect.ImmutableMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.runners.MockitoJUnitRunner; + +import java.util.Map; +import java.util.Optional; + +import static org.junit.Assert.*; + +@RunWith(MockitoJUnitRunner.class) +public class QueryMapperTest { + + @InjectMocks + private QueryMapper queryMapper; + + @Test + public void shouldConvertNullQuery() { + // given + final String queryRequest = null; + + // when + final Optional> result = queryMapper.mapper(queryRequest); + + // then + assertFalse(result.isPresent()); + } + + @Test + public void shouldConvertEmptyQuery() { + // given + final String queryRequest = ""; + + // when + final Optional> result = queryMapper.mapper(queryRequest); + + // then + assertFalse(result.isPresent()); + } + + @Test + public void shouldConvertQueryWith1Parameter() { + // given + final String queryRequest = "name=Paul"; + final Map expectedMap = ImmutableMap.builder() + .put("name", "Paul") + .build(); + + // when + final Optional> result = queryMapper.mapper(queryRequest); + + // then + assertTrue(result.isPresent()); + assertEquals(expectedMap, result.get()); + } + + @Test + public void shouldConvertQueryWith2Parameter() { + // given + final String queryRequest = "name=Paul&age=10"; + final Map expectedMap = ImmutableMap.builder() + .put("name", "Paul") + .put("age", "10") + .build(); + + // when + final Optional> result = queryMapper.mapper(queryRequest); + + // then + assertTrue(result.isPresent()); + assertEquals(expectedMap, result.get()); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java new file mode 100755 index 0000000..a21a6ce --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java @@ -0,0 +1,81 @@ +package br.com.concrete.mock.generic.mapper; + +import br.com.concrete.mock.generic.model.Response; +import br.com.concrete.mock.generic.model.template.ResponseTemplate; +import br.com.concrete.mock.infra.component.impl.FromJsonStringToObjectConverterImpl; +import br.com.six2six.fixturefactory.Fixture; +import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; +import com.google.gson.Gson; +import org.junit.BeforeClass; +import org.junit.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class ResponseDtoTest { + + @BeforeClass + public static void initClass() { + FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + } + + @Test + public void shouldConvertFromJsonAnObject() { + // given + final String json = "{ \"body\": { \"tt\": \"789\" } }"; + + // when + final ResponseDto responseDto = new Gson().fromJson(json, ResponseDto.class); + final Response response = responseDto.toModel(); + + // then + assertNotNull(response); + assertNotNull(response.getBody()); + JSONAssert.assertEquals("{ \"tt\": \"789\" }", response.getBody(), false); + } + + @Test + public void shouldConvertFromJsonAListOfObjects() { + // given + final String json = "{ \"body\": [{ \"age\": 10 }, { \"age\": 11 }] }"; + + // when + final ResponseDto responseDto = new Gson().fromJson(json, ResponseDto.class); + final Response response = responseDto.toModel(); + + // then + assertNotNull(response); + assertNotNull(response.getBody()); + assertEquals("[{\"age\":10.0},{\"age\":11.0}]", response.getBody()); + } + + @Test + public void shouldBeSerializableWhenIsObject() { + // given + final Response model = Fixture.from(Response.class).gimme(ResponseTemplate.VALID_FULL); + final String expectedJson = "{ \"body\": {\"name\": \"Paul\"} }"; + + // when + final ResponseDto modelDto = new ResponseDto(model, new FromJsonStringToObjectConverterImpl()); + final String json = new Gson().toJson(modelDto); + + // then + JSONAssert.assertEquals(expectedJson, json, false); + } + + @Test + public void shouldBeSerializableWhenIsArray() { + // given + final Response model = Fixture.from(Response.class).gimme(ResponseTemplate.VALID_WITH_LIST); + final String expectedJson = "{ \"body\": [ {\"name\": \"Paul\"}, {\"name\": \"Peter\"} ] }"; + + // when + final ResponseDto modelDto = new ResponseDto(model, new FromJsonStringToObjectConverterImpl()); + final String json = new Gson().toJson(modelDto); + + // then + JSONAssert.assertEquals(expectedJson, json, false); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/model/RequestTest.java b/src/test/java/br/com/concrete/mock/generic/model/RequestTest.java new file mode 100755 index 0000000..b039b0b --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/model/RequestTest.java @@ -0,0 +1,79 @@ +package br.com.concrete.mock.generic.model; + +import br.com.concrete.mock.generic.model.template.RequestTemplate; +import br.com.six2six.fixturefactory.Fixture; +import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class RequestTest { + + @BeforeClass + public static void initClass() { + FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + } + + @Test + public void shouldBeValidWhenAllFieldsAreFilled() { + // given + final Request request = Fixture.from(Request.class).gimme(RequestTemplate.VALID_FULL); + + // when + final Boolean valid = request.isValid(); + + // then + assertTrue(valid); + } + + @Test + public void shouldBeValidWhenAllFieldsAreBody() { + // given + final Request request = Fixture.from(Request.class).gimme(RequestTemplate.VALID_WITH_LIST); + + // when + final Boolean valid = request.isValid(); + + // then + assertTrue(valid); + } + + @Test + public void shouldBeValidWhenAllFieldsAreQuery() { + // given + final Request request = Fixture.from(Request.class).gimme(RequestTemplate.VALID_QUERY_AGE25); + + // when + final Boolean valid = request.isValid(); + + // then + assertTrue(valid); + } + + @Test + public void shouldBeValidWhenAllFieldsAreHeaders() { + // given + final Request request = Fixture.from(Request.class).gimme(RequestTemplate.VALID_WITH_HEADERS); + + // when + final Boolean valid = request.isValid(); + + // then + assertTrue(valid); + } + + @Test + public void shouldNotValid() { + // given + final Request request = Fixture.from(Request.class).gimme(RequestTemplate.VALID_EMPTY); + + // when + final Boolean valid = request.isValid(); + + // then + assertFalse(valid); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/model/template/EndpointTemplate.java b/src/test/java/br/com/concrete/mock/generic/model/template/EndpointTemplate.java new file mode 100755 index 0000000..eaa62e1 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/model/template/EndpointTemplate.java @@ -0,0 +1,58 @@ +package br.com.concrete.mock.generic.model.template; + +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.generic.model.Response; +import br.com.six2six.fixturefactory.Fixture; +import br.com.six2six.fixturefactory.Rule; +import br.com.six2six.fixturefactory.loader.TemplateLoader; + +import java.util.Optional; + +public class EndpointTemplate implements TemplateLoader { + + public static final String VALID = "valid"; + public static final String VALID_FULL = "validFull"; + public static final String VALID_WITHOUT_HTTPSTATUS = "validFull"; + public static final String VALID_WITH_LIST = "validWithList"; + public static final String VALID_WITH_REQUEST_QUERY_AGE10 = "validWithRequestQueryAge10"; + public static final String VALID_WITH_REQUEST_BODY_ID6 = "validWithRequestBodyId6"; + public static final String NOT_VALID = "notValid"; + + @Override + public void load() { + Fixture.of(Endpoint.class) + .addTemplate(VALID, new Rule() {{ + add("id", Optional.empty()); + add("request", one(Request.class, RequestTemplate.VALID_EMPTY)); + add("response", one(Response.class, ResponseTemplate.VALID)); + }}) + .addTemplate(VALID_FULL) + .inherits(VALID, new Rule() {{ + add("request", one(Request.class, RequestTemplate.VALID_FULL)); + add("response", one(Response.class, ResponseTemplate.VALID_FULL)); + }}) + .addTemplate(VALID_WITHOUT_HTTPSTATUS) + .inherits(VALID_FULL, new Rule() {{ + add("response", one(Response.class, ResponseTemplate.VALID)); + }}) + .addTemplate(VALID_WITH_LIST) + .inherits(VALID_FULL, new Rule() {{ + add("request", one(Request.class, RequestTemplate.VALID_WITH_LIST)); + add("response", one(Response.class, ResponseTemplate.VALID_WITH_LIST)); + }}) + .addTemplate(VALID_WITH_REQUEST_QUERY_AGE10) + .inherits(VALID, new Rule() {{ + add("request", one(Request.class, RequestTemplate.VALID_QUERY_AGE10)); + }}) + .addTemplate(VALID_WITH_REQUEST_BODY_ID6) + .inherits(VALID, new Rule() {{ + add("request", one(Request.class, RequestTemplate.VALID_BODY_ID6)); + }}) + .addTemplate(NOT_VALID) + .inherits(VALID, new Rule() {{ + add("response", one(Response.class, ResponseTemplate.NOT_VALID)); + }}); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/model/template/RequestTemplate.java b/src/test/java/br/com/concrete/mock/generic/model/template/RequestTemplate.java new file mode 100755 index 0000000..6dbbfa9 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/model/template/RequestTemplate.java @@ -0,0 +1,71 @@ +package br.com.concrete.mock.generic.model.template; + +import br.com.concrete.mock.generic.model.Request; +import br.com.six2six.fixturefactory.Fixture; +import br.com.six2six.fixturefactory.Rule; +import br.com.six2six.fixturefactory.loader.TemplateLoader; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.util.Optional; + +public class RequestTemplate implements TemplateLoader { + + public static final String VALID_EMPTY = "validEmpty"; + public static final String VALID_WITH_HEADERS = "validWithHeaders"; + public static final String VALID_FULL = "validFull"; + public static final String VALID_WITH_LIST = "validWithList"; + public static final String VALID_QUERY_AGE10 = "validQueryAge10"; + public static final String VALID_QUERY_AGE25 = "validQueryAge25"; + public static final String VALID_BODY_ID6 = "validBodyId6"; + public static final String VALID_BODY_ID7 = "validBodyId7"; + + @Override + public void load() { + Fixture.of(Request.class) + .addTemplate(VALID_EMPTY, new Rule() {{ + add("method", RequestMethod.GET); + add("uri", "/person/11"); + add("headers", Optional.empty()); + add("query", Optional.empty()); + add("body", Optional.empty()); + }}) + .addTemplate(VALID_WITH_HEADERS, new Rule() {{ + final HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.setAccept(ImmutableList.builder().add(MediaType.APPLICATION_JSON).build()); + + add("headers", Optional.of(httpHeaders)); + }}) + .addTemplate(VALID_FULL) + .inherits(VALID_WITH_HEADERS, new Rule() {{ + add("method", RequestMethod.POST); + add("uri", "/person/11"); + add("query", Optional.of(ImmutableMap.builder().put("text", "abc").put("age", 10).build())); + add("body", Optional.of("{\"id\": 7, \"name\": \"Paul\" }")); + }}) + .addTemplate(VALID_WITH_LIST) + .inherits(VALID_FULL, new Rule() {{ + add("body", Optional.of(" [{\"id\": 7, \"name\": \"Paul\" },{\"id\": 8, \"name\": \"Peter\" }] ")); + }}) + .addTemplate(VALID_QUERY_AGE10) + .inherits(VALID_EMPTY, new Rule() {{ + add("query", Optional.of(ImmutableMap.builder().put("age", "10").build())); + }}) + .addTemplate(VALID_QUERY_AGE25) + .inherits(VALID_EMPTY, new Rule() {{ + add("query", Optional.of(ImmutableMap.builder().put("age", "25").build())); + }}) + .addTemplate(VALID_BODY_ID6) + .inherits(VALID_EMPTY, new Rule() {{ + add("body", Optional.of("{\"id\": 6 }")); + }}) + .addTemplate(VALID_BODY_ID7) + .inherits(VALID_EMPTY, new Rule() {{ + add("body", Optional.of("{\"id\": 7 }")); + }}); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/model/template/ResponseTemplate.java b/src/test/java/br/com/concrete/mock/generic/model/template/ResponseTemplate.java new file mode 100755 index 0000000..b31a8e7 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/model/template/ResponseTemplate.java @@ -0,0 +1,40 @@ +package br.com.concrete.mock.generic.model.template; + +import br.com.concrete.mock.generic.model.Response; +import br.com.six2six.fixturefactory.Fixture; +import br.com.six2six.fixturefactory.Rule; +import br.com.six2six.fixturefactory.loader.TemplateLoader; +import org.springframework.http.HttpStatus; + +import java.util.Optional; + +public class ResponseTemplate implements TemplateLoader { + + public static final String VALID = "valid"; + public static final String VALID_FULL = "valid"; + public static final String VALID_WITH_LIST = "validWithList"; + public static final String NOT_VALID = "notValid"; + + @Override + public void load() { + Fixture.of(Response.class) + .addTemplate(VALID, new Rule() {{ + add("body", "{\"name\": \"Paul\"}"); + add("httpStatus", Optional.empty()); + }}) + .addTemplate(VALID_FULL) + .inherits(VALID, new Rule() {{ + add("body", "{\"name\": \"Paul\"}"); + add("httpStatus", Optional.of(HttpStatus.CREATED)); + }}) + .addTemplate(VALID_WITH_LIST) + .inherits(VALID_FULL, new Rule() {{ + add("body", " [ {\"name\": \"Paul\"}, {\"name\": \"Peter\"} ] "); + add("httpStatus", Optional.empty()); + }}) + .addTemplate(NOT_VALID, new Rule() {{ + add("body", "{\"codigo\": \"422\", \"mensagem\": \"Erro :(\"}"); + add("httpStatus", Optional.empty()); + }}); + } +} diff --git a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBodyTest.java b/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBodyTest.java new file mode 100755 index 0000000..0a98b87 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBodyTest.java @@ -0,0 +1,70 @@ +package br.com.concrete.mock.generic.repository.impl; + +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.generic.model.template.EndpointTemplate; +import br.com.concrete.mock.generic.model.template.RequestTemplate; +import br.com.six2six.fixturefactory.Fixture; +import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class EndpointFileFilterBodyTest { + + @Autowired + private EndpointFileFilterBody endpointFileFilter; + + @BeforeClass + public static void initClass() { + FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + } + + @Test + public void shouldBeEquivalentWhenThereIsNoFields() { + // given + final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID); + final Request request = Fixture.from(Request.class).gimme(RequestTemplate.VALID_EMPTY); + + // when + final Boolean result = endpointFileFilter.apply(endpoint, request.getBody()); + + // then + assertTrue(result); + } + + @Test + public void shouldBeEquivalentWhenFieldsAreEqual() { + // given + final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID_WITH_REQUEST_BODY_ID6); + final Request request = Fixture.from(Request.class).gimme(RequestTemplate.VALID_BODY_ID6); + + // when + final Boolean result = endpointFileFilter.apply(endpoint, request.getBody()); + + // then + assertTrue(result); + } + + @Test + public void shouldNotBeEquivalentWhenOneFieldIsNotEqual() { + // given + final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID_WITH_REQUEST_BODY_ID6); + final Request request = Fixture.from(Request.class).gimme(RequestTemplate.VALID_BODY_ID7); + + // when + final Boolean result = endpointFileFilter.apply(endpoint, request.getBody()); + + // then + assertFalse(result); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQueryTest.java b/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQueryTest.java new file mode 100755 index 0000000..06f0fbc --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQueryTest.java @@ -0,0 +1,70 @@ +package br.com.concrete.mock.generic.repository.impl; + +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.generic.model.template.EndpointTemplate; +import br.com.concrete.mock.generic.model.template.RequestTemplate; +import br.com.six2six.fixturefactory.Fixture; +import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class EndpointFileFilterQueryTest { + + @Autowired + private EndpointFileFilterQuery endpointMockFileFilter; + + @BeforeClass + public static void initClass() { + FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + } + + @Test + public void shouldBeEquivalentWhenThereIsNoFields() { + // given + final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID); + final Request request = Fixture.from(Request.class).gimme(RequestTemplate.VALID_EMPTY); + + // when + final Boolean result = endpointMockFileFilter.apply(endpoint, request.getQuery()); + + // then + assertTrue(result); + } + + @Test + public void shouldBeEquivalentWhenFieldsAreEqual() { + // given + final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID_WITH_REQUEST_QUERY_AGE10); + final Request request = Fixture.from(Request.class).gimme(RequestTemplate.VALID_QUERY_AGE10); + + // when + final Boolean result = endpointMockFileFilter.apply(endpoint, request.getQuery()); + + // then + assertTrue(result); + } + + @Test + public void shouldNotBeEquivalentWhenOneFieldIsNotEqual() { + // given + final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID_WITH_REQUEST_QUERY_AGE10); + final Request request = Fixture.from(Request.class).gimme(RequestTemplate.VALID_QUERY_AGE25); + + // when + final Boolean result = endpointMockFileFilter.apply(endpoint, request.getQuery()); + + // then + assertFalse(result); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java b/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java new file mode 100755 index 0000000..0d9cb05 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java @@ -0,0 +1,128 @@ +package br.com.concrete.mock.generic.repository.impl; + +import br.com.concrete.mock.generic.mapper.EndpointMapper; +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.generic.model.template.EndpointTemplate; +import br.com.concrete.mock.infra.component.file.BaseFileNameBuilderModel; +import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.concrete.mock.infra.property.FileProperty; +import br.com.six2six.fixturefactory.Fixture; +import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.io.IOException; +import java.net.URL; +import java.util.Collection; +import java.util.Optional; + +import static org.junit.Assert.*; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class EndpointRepositoryModelTest { + + private static final String NAME = "/get/"; + @InjectMocks + private EndpointRepositoryModel endpointRepositoryModel; + @Mock + private FileProperty fileProperty; + @Mock + private FileExtensionProperty fileExtensionProperty; + @Mock + private EndpointMapper endpointMapper; + @Mock + private BaseFileNameBuilderModel baseFileNameBuilder; + @Mock + private EndpointFileFilterRequest endpointMockFileFilterRequest; + private URL resource; + @Value("${file.base}") + private String fileBase; + @Value("${file.extension}") + private String fileExtension; + + @BeforeClass + public static void initClass() { + FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + } + + @Before + public void init() { + this.resource = getClass().getClassLoader().getResource(fileBase.concat(NAME)); + } + + @Test + public void shouldFileExistsInTest() { + assertNotNull(resource); + assertNotNull(resource.getFile()); + } + + @Test + public void shouldFindSomeResponse() throws IOException { + // given + final RequestMethod requestMethod = RequestMethod.GET; + final String requestUrl = "person/11"; + final String basePath = resource.getFile() + requestUrl; + final Optional endpoint = Optional.of(Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID)); + + // when + when(endpointMapper.mapper(any(), any(), any())).thenReturn(endpoint); + when(fileExtensionProperty.getFileExtension()).thenReturn(fileExtension); + when(baseFileNameBuilder.buildPath(any(), any())).thenReturn(basePath); + + final Collection mocks = endpointRepositoryModel.getByMethodAndUri(requestMethod, requestUrl); + + // then + assertNotNull(mocks); + assertFalse(mocks.isEmpty()); + } + + @Test + public void shouldNotFindResponseWhenDoNotExists() throws IOException { + // given + final RequestMethod requestMethod = RequestMethod.GET; + final String requestUrl = "/person/66"; + final String basePath = resource.getFile() + requestUrl; + + // when + when(baseFileNameBuilder.buildPath(any(), any())).thenReturn(basePath); + + final Collection mocks = endpointRepositoryModel.getByMethodAndUri(requestMethod, requestUrl); + + // then + assertNotNull(mocks); + assertTrue(mocks.isEmpty()); + } + + @Test + public void shouldFilterByMethodAndUriAndQuery() { + // given + final String requestUrl = "person/11"; + final String basePath = resource.getFile() + requestUrl; + final Optional result = Optional.empty(); + + // when + when(endpointMapper.mapper(any(), any(), any())).thenReturn(result); + when(fileExtensionProperty.getFileExtension()).thenReturn(fileExtension); + when(baseFileNameBuilder.buildPath(any(), any())).thenReturn(basePath); + when(endpointMockFileFilterRequest.apply(any(), any())).thenReturn(true); + + final Optional endpointMock = endpointRepositoryModel.getByMethodAndRequest(mock(Request.class)); + + // then + assertEquals(result, endpointMock); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java b/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java new file mode 100755 index 0000000..eea7f77 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java @@ -0,0 +1,124 @@ +package br.com.concrete.mock.generic.service.impl; + +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.template.EndpointTemplate; +import br.com.concrete.mock.generic.service.EndpointBackupService; +import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.concrete.mock.infra.property.FileProperty; +import br.com.six2six.fixturefactory.Fixture; +import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; +import org.junit.*; +import org.junit.runner.RunWith; +import org.skyscreamer.jsonassert.JSONAssert; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.junit.Assert.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class EndpointBackupServiceFileIntegrarionTest { + + private static final String CONFIGURATION_CAPTURE_STATE = "/configuration/capture-state"; + + @BeforeClass + public static void initClass() { + FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + } + + @Autowired + private TestRestTemplate restTemplate; + + @Autowired + @Qualifier("FilePropertyBackup") + private FileProperty fileProperty; + + @Autowired + private FileExtensionProperty fileExtensionProperty; + + @Autowired + private EndpointBackupService endpointBackupService; + + @Value("${file.base}") + private String fileBase; + + private String responseJson; + private String uri; + private String baseName; + private String fileName; + private URL resource; + + @Before + public void init() throws IOException { + final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID); + responseJson = endpoint.getResponse().getBody(); + + uri = endpoint.getRequest().getUri(); + String backupPathName = new File("").getAbsolutePath() + "/" + fileProperty.getFileBase(); + this.baseName = backupPathName + "/"; + fileName = baseName + endpoint.getRequest().getMethod().name().toLowerCase() + uri + "/1" + fileExtensionProperty.getFileExtension(); + + deleteBackupFolder(); + this.resource = getClass().getClassLoader().getResource(fileBase); + } + + @Test + public void shouldFileExistsInTest() { + assertNotNull(resource); + assertNotNull(resource.getFile()); + } + + public void deleteBackupFolder() throws IOException { + endpointBackupService.cleanAllBackupData(); + } + + @After + public void setupRestore() throws IOException { + restTemplate.delete(CONFIGURATION_CAPTURE_STATE + "/disable"); // change setup + deleteBackupFolder(); + } + + @Test(timeout = 2000) + @Ignore + public void shouldDoARequestAndDoNotCaptureBackupWhenIsNotConfigured() throws IOException { + // when + final ResponseEntity response = restTemplate.getForEntity(uri, String.class); + + // then + assertNotNull(response); + assertEquals(HttpStatus.OK, response.getStatusCode()); + JSONAssert.assertEquals(responseJson, response.getBody(), false); + assertFalse("File shouldn't exists in: " + fileName, Files.exists(Paths.get(fileName))); + } + + @Test//(timeout = 2000) + public void shouldDoARequestAndCaptureBackupWhenIsConfigured() throws IOException { + // given + final String path = "/v2/5928a3aa0f0000140538834a"; + final String name = baseName + "get" + path; + + // when + restTemplate.postForEntity(CONFIGURATION_CAPTURE_STATE + "/enable", null, Object.class); // change setup + + final ResponseEntity response = restTemplate.getForEntity(path, String.class); + + // then + assertNotNull(response); + assertEquals(HttpStatus.OK, response.getStatusCode()); + JSONAssert.assertEquals("{ \"response\": { \"httpStatus\": 204 }}", response.getBody(), false); + assertTrue("File not exists in: " + name, Files.exists(Paths.get(name))); + } + +} diff --git a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileTest.java b/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileTest.java new file mode 100755 index 0000000..8661a15 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileTest.java @@ -0,0 +1,126 @@ +package br.com.concrete.mock.generic.service.impl; + +import br.com.concrete.mock.generic.model.Endpoint; +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.generic.model.template.EndpointTemplate; +import br.com.concrete.mock.generic.repository.EndpointRepository; +import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.concrete.mock.infra.component.file.BaseFileNameBuilderModel; +import br.com.concrete.mock.infra.component.file.FileNameGenerator; +import br.com.concrete.mock.infra.component.impl.JsonFormatterPretty; +import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.concrete.mock.infra.property.FileProperty; +import br.com.six2six.fixturefactory.Fixture; +import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Answers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.util.FileSystemUtils; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class EndpointBackupServiceFileTest { + private static final String BACKUP_TEMP = "backup-temp/"; + + @BeforeClass + public static void initClass() { + FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + } + + @InjectMocks + private EndpointBackupServiceFile endpointBackupServiceFile; + + @Mock + private FileProperty fileProperty; + @Mock + private FileExtensionProperty fileExtensionProperty; + @Mock + private BaseFileNameBuilderModel baseFileNameBuilder; + @Mock + private FileNameGenerator fileNameGenerator; + @Mock(answer = Answers.CALLS_REAL_METHODS) + private FromJsonStringToObjectConverter fromJsonStringToObjectConverter; + @Mock(answer = Answers.CALLS_REAL_METHODS) + private JsonFormatterPretty jsonFormatterPretty; + @Mock + private EndpointRepository endpointRepository; + + @Test + public void shouldDoBackup() throws IOException { + // given + final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID); + final String pathName = BACKUP_TEMP + endpoint.getRequest().getUri().concat("/"); + final String fileName = "1"; + final String fileExtension = ".json"; + final Path path = Paths.get(pathName.concat("/").concat(fileName).concat(fileExtension)); + + // when + if (Files.exists(path)) Files.delete(path); + when(endpointRepository.getByMethodAndRequest(any(Request.class))).thenReturn(Optional.empty()); + when(baseFileNameBuilder.buildPath(anyString(), anyString(), anyString())).thenReturn(pathName); + when(fileExtensionProperty.getFileExtension()).thenReturn(fileExtension); + when(fileNameGenerator.fromPath(anyString())).thenReturn(fileName); + + endpointBackupServiceFile.doBackup(endpoint); + + // then + assertTrue(Files.exists(path)); + } + + @Test + @Ignore + public void shouldRemoveEverithingImportantInsidePath() throws IOException { + // given + final String baseNameFilesToRemove = BACKUP_TEMP + "data/files"; + final Path pathsToRemove = Paths.get(baseNameFilesToRemove + "/file1.json"); + + final String baseNameFilesToNotRemove = BACKUP_TEMP + ".keep-folder"; + final Path pathsDoNotRemove = Paths.get(baseNameFilesToNotRemove + "/fileDotNotRemove1.json"); + + final Path keepFilePath = Paths.get(baseNameFilesToNotRemove + ".keep-file"); + + // before + if (Files.exists(pathsToRemove)) Files.delete(pathsToRemove); + if (Files.exists(pathsDoNotRemove)) Files.delete(pathsDoNotRemove); + Files.deleteIfExists(keepFilePath); + + // when + when(fileProperty.getFileBase()).thenReturn(BACKUP_TEMP); + + Files.createDirectories(Paths.get(baseNameFilesToRemove)); + Files.createFile(pathsToRemove); + + Files.createDirectories(Paths.get(baseNameFilesToNotRemove)); + Files.createFile(pathsDoNotRemove); + + assertTrue(Files.exists(pathsToRemove)); + assertTrue(Files.exists(pathsDoNotRemove)); + + endpointBackupServiceFile.cleanAllBackupData(); + + // then + assertFalse(Files.exists(pathsToRemove)); + assertTrue(Files.exists(pathsDoNotRemove)); + + // after + FileSystemUtils.deleteRecursively(new File(baseNameFilesToNotRemove)); // dangerous + } + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/ApiPropertyTest.java b/src/test/java/br/com/concrete/mock/infra/component/ApiPropertyTest.java new file mode 100755 index 0000000..c381d1e --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/ApiPropertyTest.java @@ -0,0 +1,64 @@ +package br.com.concrete.mock.infra.component; + +import br.com.concrete.mock.infra.model.DefaultHeader; +import br.com.concrete.mock.infra.model.UriConfiguration; +import br.com.concrete.mock.infra.property.ApiProperty; +import com.google.common.collect.ImmutableList; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.List; +import java.util.regex.Pattern; + +import static org.junit.Assert.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class ApiPropertyTest { + + @Autowired + private ApiProperty apiProperty; + + @Test + public void shouldLoadAcceptHeaders() { + // when + final List acceptedHeaders = apiProperty.getAcceptedHeaders(); + + // then + assertNotNull(acceptedHeaders); + assertFalse(acceptedHeaders.isEmpty()); + } + + @Test + public void shouldLoadDefaultHeaders() { + // given + final ImmutableList headers = ImmutableList.builder().add("Connection", "Keep-Alive").build(); + final DefaultHeader defaultHeader = new DefaultHeader("Access-Control-Allow-Origin", headers); + + // when + final List defaultHeaders = apiProperty.getDefaultHeaders(); + + // then + assertNotNull(defaultHeaders); + assertFalse(defaultHeaders.isEmpty()); + assertEquals(defaultHeader, defaultHeaders.get(0)); + } + + @Test + public void shouldLoadUriConfigurations() { + // given + final UriConfiguration uriConfiguration = new UriConfiguration("http://www.mocky.io", Pattern.compile("/v2/57fbd6280f0000ed154fd470", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE), false); + + // when + final List uriConfigurations = apiProperty.getUriConfigurations(); + + // then + assertNotNull(uriConfigurations); + assertFalse(uriConfigurations.isEmpty()); + assertEquals(uriConfiguration, uriConfigurations.get(0)); + } + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/CompareJsonTest.java b/src/test/java/br/com/concrete/mock/infra/component/CompareJsonTest.java new file mode 100755 index 0000000..edb8ca7 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/CompareJsonTest.java @@ -0,0 +1,105 @@ +package br.com.concrete.mock.infra.component; + +import br.com.concrete.mock.infra.component.impl.ConvertJsonImpl; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Answers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +import java.io.IOException; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +@RunWith(MockitoJUnitRunner.class) +public class CompareJsonTest { + + @InjectMocks + private CompareJson compareJson; + + @Mock(answer = Answers.CALLS_REAL_METHODS) + private ConvertJsonImpl convertJson; + + @Test + public void shouldBeEquivalentWhenIsEqual() throws IOException { + // given + final String jsonKey = "{\"id\": 10}"; + final String jsonToCompare = "{ \"id\" : 10 } "; + + // when + final Boolean equivalent = compareJson.isEquivalent(jsonKey, jsonToCompare); + + // then + assertTrue(equivalent); + } + + @Test + public void shouldBeEquivalentWhenExistsFieldsIgnoreds() throws IOException { + // given + final String jsonKey = "{\"id\": 10}"; + final String jsonToCompare = "{ \"id\" : 10, \"age\" : 19 } "; + + // when + final Boolean equivalent = compareJson.isEquivalent(jsonKey, jsonToCompare); + + // then + assertTrue(equivalent); + } + + @Test + public void shouldBeEquivalentWhenExistsSubObjects() throws IOException { + // given + final String jsonKey = "{\"id\": 10, \"anotherObject\": { \"number\" : 2}}"; + final String jsonToCompare = "{\"id\": 10, \"anotherObject\": { \"number\" : 2}}"; + + // when + final Boolean equivalent = compareJson.isEquivalent(jsonKey, jsonToCompare); + + // then + assertTrue(equivalent); + } + + @Test + public void shouldNotBeEquivalentWhenValuesAreDifferents() throws IOException { + // given + final String jsonKey = "{ \"id\" : 10, \"age\" : 19 } "; + final String jsonToCompare = "{\"id\": 10}"; + + // when + final Boolean equivalent = compareJson.isEquivalent(jsonKey, jsonToCompare); + + // then + assertFalse(equivalent); + } + + @Test + public void shouldNotBeEquivalentWhenThereIsNoAllFields() throws IOException { + // given + final String jsonKey = "{\"id\": 10}"; + final String jsonToCompare = "{ \"id\" : 12 } "; + + // when + final Boolean equivalent = compareJson.isEquivalent(jsonKey, jsonToCompare); + + // then + assertFalse(equivalent); + } + + @Ignore + @Test + public void shouldNotBeEquivalentWhenExistsDifferentSubObjects() throws IOException { + // given + final String jsonKey = "{\"id\": 10, \"anotherObject\": { \"number\" : 2}}"; + final String jsonToCompare = "{\"id\": 10, \"anotherObject\": { \"number\" : 3}}"; + + // when + final Boolean equivalent = compareJson.isEquivalent(jsonKey, jsonToCompare); + + // then + assertFalse(equivalent); + } + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/CompareMapTest.java b/src/test/java/br/com/concrete/mock/infra/component/CompareMapTest.java new file mode 100755 index 0000000..db70515 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/CompareMapTest.java @@ -0,0 +1,90 @@ +package br.com.concrete.mock.infra.component; + +import com.google.common.collect.ImmutableMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.runners.MockitoJUnitRunner; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +@RunWith(MockitoJUnitRunner.class) +public class CompareMapTest { + + @InjectMocks + private CompareMap compareMap; + + @Test + public void shouldBeEqualsWhenCompareValueMaps() { + // given + final ImmutableMap map = ImmutableMap.builder() + .put("name", "Paul") + .build(); + final ImmutableMap mapToCompare = ImmutableMap.builder() + .put("name", "Paul") + .build(); + + // when + final Boolean isEquivalent = compareMap.isEquivalent(map, mapToCompare); + + // then + assertTrue(isEquivalent); + } + + @Test + public void shouldBeEqualsWhenCompareValueMapsWhereHaveMoreAttributesInComparation() { + // given + final ImmutableMap map = ImmutableMap.builder() + .put("name", "Paul") + .build(); + final ImmutableMap mapToCompare = ImmutableMap.builder() + .put("name", "Paul") + .put("age", "15") + .build(); + + // when + final Boolean isEquivalent = compareMap.isEquivalent(map, mapToCompare); + + // then + assertTrue(isEquivalent); + } + + @Test + public void shouldNotBeEqualsWhenCompareValueMapsWhereHaveLessAttributesInComparation() { + // given + final ImmutableMap map = ImmutableMap.builder() + .put("name", "Paul") + .put("age", "15") + .build(); + final ImmutableMap mapToCompare = ImmutableMap.builder() + .put("name", "Paul") + .build(); + + // when + final Boolean isEquivalent = compareMap.isEquivalent(map, mapToCompare); + + // then + assertFalse(isEquivalent); + } + + @Test + public void shouldNotBeEqualsWhenThereDifferentValues() { + // given + final ImmutableMap map = ImmutableMap.builder() + .put("name", "Paul") + .put("age", "15") + .build(); + final ImmutableMap mapToCompare = ImmutableMap.builder() + .put("name", "Paul") + .put("age", "25") + .build(); + + // when + final Boolean isEquivalent = compareMap.isEquivalent(map, mapToCompare); + + // then + assertFalse(isEquivalent); + } + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/ExternalApiTest.java b/src/test/java/br/com/concrete/mock/infra/component/ExternalApiTest.java new file mode 100755 index 0000000..b501d05 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/ExternalApiTest.java @@ -0,0 +1,95 @@ +package br.com.concrete.mock.infra.component; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.when; + +import java.util.Optional; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.bind.annotation.RequestMethod; + +import br.com.concrete.mock.generic.model.ExternalApiResult; +import br.com.concrete.mock.generic.model.Request; +import br.com.concrete.mock.infra.property.ApiProperty; +import br.com.concrete.mock.infra.model.UriConfiguration; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class ExternalApiTest { + + private static final String EXTERNAL_HOST = "http://www.mocky.io"; + private static final String URI = "/v2/57fbd6280f0000ed154fd470"; + // private static final String EXTERNAL_URL = "http://localhost:8080" + URI; + + @Autowired + private ExternalApi externalApi; + + @MockBean + private ApiProperty apiProperty; + + @Test(timeout = 5000) + public void shouldDoExternalGet() { + // given + final Request request = new Request.Builder(RequestMethod.GET, URI).build(); + + final UriConfiguration configuration = new UriConfiguration(); + configuration.setHost(EXTERNAL_HOST); + configuration.setBackup(false); + configuration.setPattern(URI); + + // when + when(apiProperty.getConfiguration(anyString())).thenReturn(Optional.of(configuration)); + final Optional responseEntity = externalApi.execute(request); + + // then + assertTrue(responseEntity.isPresent()); + assertTrue(responseEntity.get().getApiResult().getStatusCode().is2xxSuccessful()); + } + + @Test(timeout = 5000) + public void shouldDoExternalPost() { + // given + final Request request = new Request.Builder(RequestMethod.POST, URI) + .withBody(Optional.of("{\"name\": \"Paul\"}")).build(); + + final UriConfiguration configuration = new UriConfiguration(); + configuration.setHost(EXTERNAL_HOST); + configuration.setBackup(false); + configuration.setPattern(URI); + + // when + when(apiProperty.getConfiguration(anyString())).thenReturn(Optional.of(configuration)); + final Optional responseEntity = externalApi.execute(request); + + // then + assertTrue(responseEntity.isPresent()); + assertTrue(responseEntity.get().getApiResult().getStatusCode().is2xxSuccessful()); + } + + @Test(timeout = 8000) + public void shouldDoExternalPatch() { + // given + final Request request = new Request.Builder(RequestMethod.PATCH, URI) + .withBody(Optional.of("{\"name\": \"Paul\"}")).build(); + + final UriConfiguration configuration = new UriConfiguration(); + configuration.setHost(EXTERNAL_HOST); + configuration.setBackup(false); + configuration.setPattern(URI); + + // when + when(apiProperty.getConfiguration(anyString())).thenReturn(Optional.of(configuration)); + final Optional responseEntity = externalApi.execute(request); + + // then + assertTrue(responseEntity.isPresent()); + assertTrue(responseEntity.get().getApiResult().getStatusCode().is2xxSuccessful()); + } + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModelTest.java b/src/test/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModelTest.java new file mode 100755 index 0000000..0af8195 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModelTest.java @@ -0,0 +1,60 @@ +package br.com.concrete.mock.infra.component.file; + +import br.com.concrete.mock.infra.property.FileProperty; +import org.hamcrest.CoreMatchers; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.net.URL; + +import static org.junit.Assert.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class BaseFileNameBuilderModelTest { + + private URL resource; + + @Autowired + @Qualifier("FilePropertyModel") + private FileProperty fileProperty; + + @Autowired + @Qualifier("BaseFileNameBuilderModel") + private BaseFileNameBuilder baseFileNameBuilder; + + @Before + public void init() { + this.resource = getClass().getClassLoader().getResource(fileProperty.getFileBase()); + } + + @Test + public void shouldHavePathToTest() { + assertNotNull(baseFileNameBuilder); + assertNotNull(fileProperty.getFileBase()); + assertFalse(fileProperty.getFileBase().isEmpty()); + assertNotNull(resource); + assertNotNull(resource.getFile()); + } + + @Test + public void shouldBuildPath() { + // given + final RequestMethod requestMethod = RequestMethod.GET; + final String pathUri = "/person"; + + // when + final String path = baseFileNameBuilder.buildPath(requestMethod, pathUri); + + // then + assertNotNull(path); + assertThat(path, CoreMatchers.endsWith(fileProperty.getFileBase() + "/get/person")); + } + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java b/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java new file mode 100755 index 0000000..e629adb --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java @@ -0,0 +1,62 @@ +package br.com.concrete.mock.infra.component.file; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.IOException; +import java.net.URL; +import java.util.Optional; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class FileJsonReaderTest { + + private static final String NAME = "/get/person/11/my-mock.json"; + + @InjectMocks + private FileJsonReader fileJsonReader; + + private URL resource; + + @Value("${file.base}") + private String fileBase; + + @Before + public void init() { + this.resource = getClass().getClassLoader().getResource(fileBase.concat(NAME)); + } + + @Test + public void shouldFileExistsInTest() { + assertNotNull(resource); + assertNotNull(resource.getFile()); + } + + @Test + public void shouldReadFile() throws IOException { + // when + final Optional jsonFile = fileJsonReader.getJsonByFileName(resource.getFile()); + + // then + assertTrue(jsonFile.isPresent()); + assertThat(jsonFile.get(), containsString("name")); + } + + @Test + public void shouldReturnEmptyWhenFileNotFound() throws IOException { + // when + final Optional jsonFile = fileJsonReader.getJsonByFileName(resource.getFile() + "-file-not-found"); + + // then + assertFalse(jsonFile.isPresent()); + } + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java b/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java new file mode 100755 index 0000000..a63b628 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java @@ -0,0 +1,120 @@ +package br.com.concrete.mock.infra.component.file; + +import br.com.concrete.mock.infra.property.FileExtensionProperty; +import org.apache.tomcat.util.http.fileupload.FileUtils; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class FileNameGeneratorImplTest { + + private static final String EXTENSION = ".json"; + + @InjectMocks + private FileNameGeneratorImpl fileNameGenerator; + + @Mock + private FileExtensionProperty fileExtensionProperty; + + private Path path; + + @Before + public void init() throws IOException { + path = Optional + .ofNullable(getClass().getClassLoader().getResource("mocks-test")) + .map(URL::getFile) + .map(f -> new File(f, "filenametest")) + .map(file -> { + try { + final Path p = Paths.get(file.getAbsolutePath()); + FileUtils.deleteDirectory(file); + + return Files.createDirectories(p); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + }) + .orElse(null); + } + + @Test + public void shouldHavePathToTest() { + assertNotNull("Something is wrong with base path", path); + } + + @Test + public void shouldGenerateFileWhenFolderIsEmpty() { + // given + // empty folder + + // when + when(fileExtensionProperty.getFileExtension()).thenReturn(EXTENSION); + final String fileName = fileNameGenerator.fromPath(path.toFile().getAbsolutePath()); + + // then + assertEquals("1", fileName); + } + + @Test + public void shouldGenerateFileWhenFolderHave1File() throws IOException { + // given + createFileWithName("1"); + + // when + when(fileExtensionProperty.getFileExtension()).thenReturn(EXTENSION); + final String fileName = fileNameGenerator.fromPath(path.toFile().getAbsolutePath()); + + // then + assertEquals("2", fileName); + } + + @Test + public void shouldGenerateFileWhenFolderHave2File() throws IOException { + // given + createFileWithName("1"); + createFileWithName("2"); + + // when + when(fileExtensionProperty.getFileExtension()).thenReturn(EXTENSION); + final String fileName = fileNameGenerator.fromPath(path.toFile().getAbsolutePath()); + + // then + assertEquals("3", fileName); + } + + @Test + public void shouldGenerateFileWhenFolderHaveFileNameEqualSizeFilesIntoFolder() throws IOException { + // given + createFileWithName("2"); + createFileWithName("3"); + + // when + when(fileExtensionProperty.getFileExtension()).thenReturn(EXTENSION); + final String fileName = fileNameGenerator.fromPath(path.toFile().getAbsolutePath()); + + // then + assertEquals("4", fileName); + } + + private void createFileWithName(final String name) throws IOException { + Files.createFile(Paths.get(path.toFile().getAbsolutePath(), name + EXTENSION)); + } + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImplTest.java b/src/test/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImplTest.java new file mode 100755 index 0000000..f1f7ce8 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImplTest.java @@ -0,0 +1,34 @@ +package br.com.concrete.mock.infra.component.impl; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.runners.MockitoJUnitRunner; + +import java.util.HashMap; + +import static org.junit.Assert.assertEquals; + +@RunWith(MockitoJUnitRunner.class) +public class ConvertJsonImplTest { + + @InjectMocks + private ConvertJsonImpl convertJsonImpl; + + @Test + public void shouldConvertJsonObject() { + // given + final String json = "{\"name\": \"Paul\"}"; + + final HashMap hashMap = new HashMap<>(); + hashMap.put("name", "Paul"); + + // when + final HashMap result = convertJsonImpl.apply(json); + + // then + assertEquals(hashMap, result); + } + + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java b/src/test/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java new file mode 100755 index 0000000..c73b870 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java @@ -0,0 +1,61 @@ +package br.com.concrete.mock.infra.component.impl; + + +import com.google.gson.Gson; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.runners.MockitoJUnitRunner; +import org.skyscreamer.jsonassert.JSONAssert; + +import java.util.Optional; + +@RunWith(MockitoJUnitRunner.class) +public class FromJsonStringToObjectConverterImplTest { + + @InjectMocks + private FromJsonStringToObjectConverterImpl converter; + + @Test + public void shouldConvertObject() { + // given + final String expectedJson = "{ \"name\": \"Peter\", \"age\": 99}"; + final Optional jsonString = Optional.of(expectedJson); + + // when + final Object jsonObject = converter.apply(jsonString); + final String json = new Gson().toJson(jsonObject); + + // then + JSONAssert.assertEquals(expectedJson, json, false); + } + + @Test + public void shouldConvertArray() { + // given + final String expectedJson = " [ { \"name\": \"Peter\", \"age\": 99}, { \"name\": \"Paul\", \"age\": 98} ]"; + final Optional jsonString = Optional.of(expectedJson); + + // when + final Object jsonObject = converter.apply(jsonString); + final String json = new Gson().toJson(jsonObject); + + // then + JSONAssert.assertEquals(expectedJson, json, false); + } + + @Test + public void shouldConvertNull() { + // given + final String expectedJson = "{ }"; + final Optional jsonString = Optional.of(expectedJson); + + // when + final Object jsonObject = converter.apply(jsonString); + final String json = new Gson().toJson(jsonObject); + + // then + JSONAssert.assertEquals(expectedJson, json, false); + } + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPrettyTest.java b/src/test/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPrettyTest.java new file mode 100755 index 0000000..7a166e4 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPrettyTest.java @@ -0,0 +1,47 @@ +package br.com.concrete.mock.infra.component.impl; + +import com.google.gson.JsonParseException; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.runners.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class JsonFormatterPrettyTest { + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + @InjectMocks + private JsonFormatterPretty jsonFormatterPretty; + + @Test + public void shouldFormatValidJson() { + // given + final String jsonRaw = "{\"age\":10}"; + final String jsonExpected = "{\n" + + " \"age\": 10\n" + + "}\n"; + + // when + final String jsonPretty = jsonFormatterPretty.format(jsonRaw); + + // then + Assert.assertEquals(jsonExpected, jsonPretty); + } + + @Test + public void shouldThrowExceptionWhenIsInvalidJsonFormat() { + // given + final String jsonRaw = "invalid json format"; + + // excpected exception + expectedException.expect(JsonParseException.class); + + // when + jsonFormatterPretty.format(jsonRaw); + } + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImplTest.java b/src/test/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImplTest.java new file mode 100755 index 0000000..521356e --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImplTest.java @@ -0,0 +1,79 @@ +package br.com.concrete.mock.infra.component.impl; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.runners.MockitoJUnitRunner; +import org.skyscreamer.jsonassert.JSONAssert; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +@RunWith(MockitoJUnitRunner.class) +public class JsonValueCompilerImplTest { + + @InjectMocks + private JsonValueCompilerImpl jsonValueCompiler; + + @Test + public void shouldBeEqualWhenNotExistVariables() { + // given + final String jsonWithValue = "{ \"id\": \"first\", \"name\": \"Paul\" }"; + + // when + final String jsonCompiled = jsonValueCompiler.compile(jsonWithValue); + + // then + JSONAssert.assertEquals(jsonWithValue, jsonCompiled, false); + } + + @Test + public void shouldCompileVariable3daysAgo() { + // given + final String format = "YYYY/MM/dd"; + final String jsonWithValue = "{ \"date1\": \"#{{3daysAgo:" + format + "}}\", \"name\": \"Paul\" }"; + final String date = LocalDate.now().minusDays(3).format(DateTimeFormatter.ofPattern(format)); + final String expectedJson = "{ \"date1\": \"" + date + "\", \"name\": \"Paul\" }"; + + // when + final String jsonCompiled = jsonValueCompiler.compile(jsonWithValue); + + // then + JSONAssert.assertEquals(expectedJson, jsonCompiled, false); + } + + @Test + public void shouldCompileVariable3daysAgoRepeated() { + // given + final String format = "YYYY/MM/dd"; + final String jsonWithValue = "{ \"date1\": \"#{{3daysAgo:" + format + "}}\", \"date2\": \"#{{3daysAgo:" + format + "}}\", \"name\": \"Paul\" }"; + final String date = LocalDate.now().minusDays(3).format(DateTimeFormatter.ofPattern(format)); + final String expectedJson = "{ \"date1\": \"" + date + "\", \"date2\": \"" + date + "\", \"name\": \"Paul\" }"; + + // when + final String jsonCompiled = jsonValueCompiler.compile(jsonWithValue); + + // then + JSONAssert.assertEquals(expectedJson, jsonCompiled, false); + } + + @Test + public void shouldCompileVariableNdaysAgo() { + // given + final String format = "YYYY/MM/dd"; + final String jsonWithValue = "{ \"date1\": \"#{{3daysAgo:" + format + "}}\", \"date2\": \"#{{3daysAgo:" + format + "}}\", \"date3\": \"#{{7daysAgo:" + format + "}}\", \"date4\": \"#{{8daysAgo:" + format + "}}\", \"name\": \"Paul\" }"; + final String date3daysAgo = LocalDate.now().minusDays(3).format(DateTimeFormatter.ofPattern(format)); + final String date7daysAgo = LocalDate.now().minusDays(7).format(DateTimeFormatter.ofPattern(format)); + final String date8daysAgo = LocalDate.now().minusDays(8).format(DateTimeFormatter.ofPattern(format)); + final String expectedJson = "{ \"date1\": \"" + date3daysAgo + "\", \"date2\": \"" + date3daysAgo + "\", \"date3\": \"" + date7daysAgo + "\", \"date4\": \"" + date8daysAgo + "\", \"name\": \"Paul\" }"; + + // when + final String jsonCompiled = jsonValueCompiler.compile(jsonWithValue); + + // then + JSONAssert.assertEquals(expectedJson, jsonCompiled, false); + } + + // format error + +} diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImplTest.java b/src/test/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImplTest.java new file mode 100755 index 0000000..c8223c5 --- /dev/null +++ b/src/test/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImplTest.java @@ -0,0 +1,64 @@ +package br.com.concrete.mock.infra.component.impl; + +import br.com.concrete.mock.infra.component.ConvertJson; +import com.google.common.collect.ImmutableMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Answers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +import static org.junit.Assert.*; + +@RunWith(MockitoJUnitRunner.class) +public class QueryStringBuilderImplTest { + + @InjectMocks + private QueryStringBuilderImpl queryStringBuilder; + + @Mock(answer = Answers.CALLS_REAL_METHODS) + private ConvertJson convertJson; + + @Test + public void shouldBeEmpty() { + // given + final ImmutableMap queryMap = ImmutableMap.builder().build(); + + // when + final String queryString = queryStringBuilder.fromMap(queryMap); + + // then + assertNotNull(queryString); + assertTrue(queryString.isEmpty()); + } + + @Test + public void shouldHaveOneParameter() { + // given + final ImmutableMap queryMap = ImmutableMap.builder().put("name", "Paul").build(); + + // when + final String queryString = queryStringBuilder.fromMap(queryMap); + + // then + assertNotNull(queryString); + assertFalse(queryString.isEmpty()); + assertEquals("?name=Paul", queryString); + } + + @Test + public void shouldHaveTwoParameters() { + // given + final ImmutableMap queryMap = ImmutableMap.builder().put("name", "Paul").put("age", "10").build(); + + // when + final String queryString = queryStringBuilder.fromMap(queryMap); + + // then + assertNotNull(queryString); + assertFalse(queryString.isEmpty()); + assertEquals("?name=Paul&age=10", queryString); + } + +} diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml new file mode 100755 index 0000000..e95c4f7 --- /dev/null +++ b/src/test/resources/application.yml @@ -0,0 +1,40 @@ +# vmoptions: -Dspring.profiles.active=test + +server.port: 9090 + +api: + acceptedHeaders: + - "execute" + - "Content-Type" + host: "http://www.mocky.io" + defaultHeaders: + - + headerName: "Access-Control-Allow-Origin" + headerValues: + - "Connection" + - "Keep-Alive" + - + headerName: "Content-Type" + headerValues: + - "application/json;charset=UTF-8" + uriConfigurations: + - + host: "http://www.mocky.io" + pattern: "/v2/57fbd6280f0000ed154fd470" + backup: false + - + host: "http://www.mocky.io" + pattern: "/v2/5928a3aa0f0000140538834a" + backup: true + - + host: "/teste.html" + pattern: "teste/|test/" + +file: + base: "mocks-test" + extension: ".json" + backup.path: "backup-temp" + +captureState: false + +debug: true diff --git a/src/test/resources/mocks-test/get/guests/132/1.json b/src/test/resources/mocks-test/get/guests/132/1.json new file mode 100755 index 0000000..dddbac5 --- /dev/null +++ b/src/test/resources/mocks-test/get/guests/132/1.json @@ -0,0 +1,18 @@ +{ + "response": { + "body": [ + { + "cc": "11", + "ca": "12" + }, + { + "cc": "21", + "ca": "22" + }, + { + "cc": "31", + "ca": "32" + } + ] + } +} diff --git a/src/test/resources/mocks-test/get/guests/132/users/1.json b/src/test/resources/mocks-test/get/guests/132/users/1.json new file mode 100755 index 0000000..614b8ce --- /dev/null +++ b/src/test/resources/mocks-test/get/guests/132/users/1.json @@ -0,0 +1,9 @@ +{ + "response": { + "body": [ + { + "move": "3" + } + ] + } +} diff --git a/src/test/resources/mocks-test/get/guests/132/users/21/cc/1.json b/src/test/resources/mocks-test/get/guests/132/users/21/cc/1.json new file mode 100755 index 0000000..3f8c597 --- /dev/null +++ b/src/test/resources/mocks-test/get/guests/132/users/21/cc/1.json @@ -0,0 +1,7 @@ +{ + "response": { + "body": { + "tt": "789" + } + } +} diff --git a/src/test/resources/mocks-test/get/guests/132/users/22/cc/1.json b/src/test/resources/mocks-test/get/guests/132/users/22/cc/1.json new file mode 100755 index 0000000..462294e --- /dev/null +++ b/src/test/resources/mocks-test/get/guests/132/users/22/cc/1.json @@ -0,0 +1,7 @@ +{ + "response": { + "body": { + "tt": "456" + } + } +} diff --git a/src/test/resources/mocks-test/get/payments/user/detail/1.json b/src/test/resources/mocks-test/get/payments/user/detail/1.json new file mode 100755 index 0000000..e5240de --- /dev/null +++ b/src/test/resources/mocks-test/get/payments/user/detail/1.json @@ -0,0 +1,18 @@ +{ + "request": { + "query": { + "payment": "1", + "value": "10" + } + }, + "response": { + "body": [ + { + "total": "1700" + }, + { + "total": "1800" + } + ] + } +} diff --git a/src/test/resources/mocks-test/get/payments/user/detail/2.json b/src/test/resources/mocks-test/get/payments/user/detail/2.json new file mode 100755 index 0000000..3690a07 --- /dev/null +++ b/src/test/resources/mocks-test/get/payments/user/detail/2.json @@ -0,0 +1,18 @@ +{ + "request": { + "query": { + "payment": "2", + "value": "20" + } + }, + "response": { + "body": [ + { + "total": "1702" + }, + { + "total": "1802" + } + ] + } +} diff --git a/src/test/resources/mocks-test/get/person/11/my-mock.json b/src/test/resources/mocks-test/get/person/11/my-mock.json new file mode 100755 index 0000000..49fb393 --- /dev/null +++ b/src/test/resources/mocks-test/get/person/11/my-mock.json @@ -0,0 +1,8 @@ +{ + "response": { + "body": { + "name": "Paul", + "age": 10 + } + } +} diff --git a/src/test/resources/mocks-test/get/users/123/1.json b/src/test/resources/mocks-test/get/users/123/1.json new file mode 100755 index 0000000..a24e97f --- /dev/null +++ b/src/test/resources/mocks-test/get/users/123/1.json @@ -0,0 +1,7 @@ +{ + "response": { + "body": { + "name": "Paul" + } + } +} diff --git a/src/test/resources/mocks-test/get/users/123/2.json b/src/test/resources/mocks-test/get/users/123/2.json new file mode 100755 index 0000000..08e23df --- /dev/null +++ b/src/test/resources/mocks-test/get/users/123/2.json @@ -0,0 +1,13 @@ +{ + "request": { + "query": { + "payment": "22" + } + }, + "response": { + "body": { + "name": "John" + }, + "httpStatus": 202 + } +} diff --git a/src/test/resources/mocks-test/patch/users/1456/1.json b/src/test/resources/mocks-test/patch/users/1456/1.json new file mode 100755 index 0000000..75b53ec --- /dev/null +++ b/src/test/resources/mocks-test/patch/users/1456/1.json @@ -0,0 +1,12 @@ +{ + "request": { + "body": { + "result": "done" + } + }, + "response": { + "body": { + "sync": "success" + } + } +} diff --git a/src/test/resources/mocks-test/patch/v2/57fbd6280f0000ed154fd470/1.json b/src/test/resources/mocks-test/patch/v2/57fbd6280f0000ed154fd470/1.json new file mode 100755 index 0000000..12ec53e --- /dev/null +++ b/src/test/resources/mocks-test/patch/v2/57fbd6280f0000ed154fd470/1.json @@ -0,0 +1,12 @@ +{ + "request": { + "body": { + "result": "done" + } + }, + "response": { + "body": { + "message": "success" + } + } +} diff --git a/src/test/resources/mocks-test/post/move/to/country/13/1.json b/src/test/resources/mocks-test/post/move/to/country/13/1.json new file mode 100755 index 0000000..b480e59 --- /dev/null +++ b/src/test/resources/mocks-test/post/move/to/country/13/1.json @@ -0,0 +1,12 @@ +{ + "request": { + "body": { + "count": "698" + } + }, + "response": { + "body": { + "street": "USA" + } + } +} diff --git a/src/test/resources/mocks-test/post/move/to/country/13/pi/1.json b/src/test/resources/mocks-test/post/move/to/country/13/pi/1.json new file mode 100755 index 0000000..4595917 --- /dev/null +++ b/src/test/resources/mocks-test/post/move/to/country/13/pi/1.json @@ -0,0 +1,12 @@ +{ + "request": { + "body": { + "pi": "123456" + } + }, + "response": { + "body": { + "street": "NY" + } + } +} diff --git a/src/test/resources/mocks-test/post/move/to/country/13/pi/2.json b/src/test/resources/mocks-test/post/move/to/country/13/pi/2.json new file mode 100755 index 0000000..b8ccfb3 --- /dev/null +++ b/src/test/resources/mocks-test/post/move/to/country/13/pi/2.json @@ -0,0 +1,14 @@ +{ + "request": { + "body": { + "pi": "j12" + } + }, + "response": { + "body": { + "codigo": "123", + "mensagem": "Error :(" + }, + "httpStatus": "422" + } +} diff --git a/src/test/resources/mocks-test/post/v2/57fbd6280f0000ed154fd470/1.json b/src/test/resources/mocks-test/post/v2/57fbd6280f0000ed154fd470/1.json new file mode 100755 index 0000000..12ec53e --- /dev/null +++ b/src/test/resources/mocks-test/post/v2/57fbd6280f0000ed154fd470/1.json @@ -0,0 +1,12 @@ +{ + "request": { + "body": { + "result": "done" + } + }, + "response": { + "body": { + "message": "success" + } + } +} From b547c8ae98884c63007f3386f134dfbce9cc0aa6 Mon Sep 17 00:00:00 2001 From: "andre.formento" Date: Wed, 5 Jul 2017 16:13:53 -0300 Subject: [PATCH 02/54] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b404b8e..78f33b2 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ mvn spring-boot:run -Dspring.profiles.active=custom ## TODO * Mudar para Gradle * Adicionar a opção de fazer build com Docker -* Quando não existir `api.acceptedHeaders` não precisa validar +* -Quando não existir `api.acceptedHeaders` não precisa validar * Separar testes unitários dos testes integrados * Corrigir os testes ignorados * Corrigir Code Style From 16621f41278c57869d14761e30f7f27751194f8b Mon Sep 17 00:00:00 2001 From: "andre.formento" Date: Wed, 5 Jul 2017 16:50:48 -0300 Subject: [PATCH 03/54] Deixar acceptedheaders opcionais --- .../br/com/concrete/mock/infra/property/ApiProperty.java | 6 +++--- src/main/resources/application.yml | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/br/com/concrete/mock/infra/property/ApiProperty.java b/src/main/java/br/com/concrete/mock/infra/property/ApiProperty.java index 563be5a..c15ee95 100755 --- a/src/main/java/br/com/concrete/mock/infra/property/ApiProperty.java +++ b/src/main/java/br/com/concrete/mock/infra/property/ApiProperty.java @@ -16,7 +16,7 @@ @ConfigurationProperties(prefix = "api") public class ApiProperty { - private List acceptedHeaders; + private List acceptedHeaders = new ArrayList<>(); private String host; private List uriConfigurations; private List defaultHeaders; @@ -26,11 +26,11 @@ public List getAcceptedHeaders() { } public void setAcceptedHeaders(List acceptedHeaders) { - this.acceptedHeaders = acceptedHeaders.stream().map(String::toLowerCase).collect(Collectors.toList()); + this.acceptedHeaders = getAcceptedHeaders().stream().map(String::toLowerCase).collect(Collectors.toList()); } public Boolean isAcceptedHeader(final String headerValue) { - return acceptedHeaders.contains(headerValue.toLowerCase()); + return getAcceptedHeaders().isEmpty() || getAcceptedHeaders().contains(headerValue.toLowerCase()); } public void setUriConfigurations(List uriConfigurations) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9047193..f110dbd 100755 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,9 +3,10 @@ server.port: 9090 api: - acceptedHeaders: - - "accept" - - "Content-Type" + # Requests accept just this headers (optinal property). If property not exists, all headers are accepted +# acceptedHeaders: +# - "accept" +# - "Content-Type" # When is not find in repository, then will try to do a request in this host host: "http://www.mocky.io" From 3d381c9e68a56b09bc2b1c2b46febb2fcb259059 Mon Sep 17 00:00:00 2001 From: andreformentoc Date: Wed, 5 Jul 2017 17:09:14 -0300 Subject: [PATCH 04/54] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 78f33b2..d24f100 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ mvn spring-boot:run -Dspring.profiles.active=custom ## TODO * Mudar para Gradle * Adicionar a opção de fazer build com Docker -* -Quando não existir `api.acceptedHeaders` não precisa validar * Separar testes unitários dos testes integrados * Corrigir os testes ignorados * Corrigir Code Style From a78aae4a076bab1c688b55c8f981b13fc1c4ae3a Mon Sep 17 00:00:00 2001 From: andreformentoc Date: Wed, 5 Jul 2017 17:09:20 -0300 Subject: [PATCH 05/54] Update README.md From 437ce29cda1436a0fb32a3f6b184cce4cea527ce Mon Sep 17 00:00:00 2001 From: "andre.formento" Date: Mon, 10 Jul 2017 15:23:50 -0300 Subject: [PATCH 06/54] Altera para gradle --- .gitignore | 2 - README.md | 5 +- build.gradle | 41 ++++++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54711 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 172 +++++++++++++++++++++++ gradlew.bat | 84 +++++++++++ pom.xml | 127 ----------------- 8 files changed, 307 insertions(+), 130 deletions(-) create mode 100644 build.gradle create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat delete mode 100755 pom.xml diff --git a/.gitignore b/.gitignore index b65bd5f..6817c31 100755 --- a/.gitignore +++ b/.gitignore @@ -24,9 +24,7 @@ dist/ nbdist/ .nb-gradle/ -gradle .gradle/ -gradlew ### Application ### backup-temp/ diff --git a/README.md b/README.md index d24f100..644eccb 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,12 @@ mvn spring-boot:run -Dspring.profiles.active=custom ``` ## TODO -* Mudar para Gradle +* -Mudar para Gradle * Adicionar a opção de fazer build com Docker * Separar testes unitários dos testes integrados * Corrigir os testes ignorados * Corrigir Code Style * Adcionar plugin do FindBugs +* Revisar dependências (ver, por exemplo, se é mesmo necessário ter o GSON ou modelmapper) +* Usar objectmapper como component: `compile('com.fasterxml.jackson.datatype:jackson-datatype-jdk8')` +* Atualizar versão do Spring Boot diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..e17f5e7 --- /dev/null +++ b/build.gradle @@ -0,0 +1,41 @@ +buildscript { + ext { + springBootVersion = '1.4.7.RELEASE' + } + repositories { + mavenCentral() + } + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") + } +} + +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'org.springframework.boot' + +version = '4.0.0-SNAPSHOT' +sourceCompatibility = 1.8 + +repositories { + mavenCentral() +} + + +dependencies { + compile('org.springframework.boot:spring-boot-starter', { + exclude module: 'org.apache.httpcomponents:httpclient' + }) + compile 'org.springframework.boot:spring-boot-starter-undertow' + compile 'org.springframework.boot:spring-boot-starter-hateoas' + compile 'com.google.code.gson:gson' + compile 'javax.ws.rs:javax.ws.rs-api:2.0' + compile 'net.minidev:json-smart:1.0.8' + compile 'org.apache.httpcomponents:httpclient' + compile 'com.google.guava:guava:22.0' + compile 'org.modelmapper:modelmapper:0.7.5' + compile 'commons-io:commons-io:2.5' + + testCompile 'org.springframework.boot:spring-boot-starter-test' + testCompile 'br.com.six2six:fixture-factory:3.1.0' +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..1a958be6420a4dd04b588fe4b31eb5d7ff8748c2 GIT binary patch literal 54711 zcmafaV|Zr4wq|#1+qUg=Y}>Y-FYKg~FSc!4U!3l^W81ckPNrwhy)$#poO|cT+I#J{+5|g zn4p(o_zHIlG*8_x)}?L3rYzkrHvQe#f_Ij2ihJvNZtN&+O z|2GEyKQLCVCg%1Q|1A{#pP^o^CeF?luK$n9m5*-P)!(5P{{9-qf3G6yc6tR5hR1)xa5HQGTsPG$-fGY`3(PpBen*pMTz; ztiBlbDzS-r>kXNV%W20uiwu!4jcN~2;-)3+jwK=xr&{RuYV>rW55Scb|7fGy=?J04 z-Ox^P78~mPE#1}*{YN{=nLhlft$oc8kjLy5tZY$DPEU#ru{YcmEk+}~jDo^bgqtZy z{R=y$1`Z|3G8Xn&(FRJ7341BSL&0Dv0!=nUN5e>iF=oq7d}ec67R;1(j*bE@HFHj9 zH>kwXk&WJElj9;$A&pXleHLW9GMl@Ia4CCq)J8STiIB5u`Y)HB8NT5g4&}+T{gou7M1nf7H3>h z-$-Vmq0Kd+&{G=B=gg0v;xh9tExp_15CUNVR-2)&sXE6QK*775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!#C%f8W3Ow_otW%k`6|tK)AxFQ=V \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save ( ) { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..e95643d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/pom.xml b/pom.xml deleted file mode 100755 index db2c8dc..0000000 --- a/pom.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - 4.0.0 - - br.com.concrete.mock - mock-api - 3.0.0 - war - - mock-api - Mock API - - - org.springframework.boot - spring-boot-starter-parent - 1.4.1.RELEASE - - - - - UTF-8 - UTF-8 - 1.8 - 5.1.7.Final - 1.0.8 - 2.0 - 2.3.1 - 22.0 - 3.1.0 - 4.5.2 - 0.7.5 - 2.5 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.apache.httpcomponents - httpclient - - - - - org.springframework.boot - spring-boot-starter-undertow - - - org.springframework.boot - spring-boot-starter-hateoas - - - org.springframework.boot - spring-boot-starter-undertow - - - org.springframework.boot - spring-boot-starter-test - test - - - com.google.code.gson - gson - - - javax.ws.rs - javax.ws.rs-api - ${javax.ws.rs-api.version} - - - net.minidev - json-smart - ${json-smart.version} - - - org.apache.httpcomponents - httpclient - - - com.google.guava - guava - ${guava.version} - - - org.modelmapper - modelmapper - ${modelmapper.version} - - - br.com.six2six - fixture-factory - ${fixture-factory.version} - test - - - commons-io - commons-io - ${commons-io.version} - - - - - - - maven-compiler-plugin - 3.1 - - ${java.version} - ${java.version} - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-release-plugin - 2.5.3 - - - - - From 3a36b96ff96c729c9f1bb45c992bf2f600764e49 Mon Sep 17 00:00:00 2001 From: "andre.formento" Date: Mon, 10 Jul 2017 15:25:14 -0300 Subject: [PATCH 07/54] Update readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 644eccb..4eda9fc 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ mvn spring-boot:run -Dspring.profiles.active=custom ``` ## TODO -* -Mudar para Gradle * Adicionar a opção de fazer build com Docker * Separar testes unitários dos testes integrados * Corrigir os testes ignorados From 22724b4ffa900a33d85ddde63503b1b3b1d96a3f Mon Sep 17 00:00:00 2001 From: "andre.formento" Date: Mon, 10 Jul 2017 17:16:42 -0300 Subject: [PATCH 08/54] Ignora pasta out --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6817c31..b22d2cd 100755 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ nbdist/ backup-temp/ mocks-prod fake-api-data +out From c4eed6c263bc734f7d4ddd42156af6c445db3b3f Mon Sep 17 00:00:00 2001 From: "andre.formento" Date: Mon, 10 Jul 2017 17:17:27 -0300 Subject: [PATCH 09/54] Permite usar comando do gradle para run e atualiza readme --- README.md | 4 ++-- build.gradle | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4eda9fc..f3dc0a9 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,14 @@ Quando uma request é feita é seguido o seguinte fluxo: ## Requisitos * Java JDK 8 -* Maven 3 +* Gradle 4 ## Run ## Usando seu arquivo de propriedades Crie seu arquivo de propriedade `src/main/resources/application-custom.yml` e rode com o argumento `-Dspring.profiles.active=custom`. Exemplo: ``` -mvn spring-boot:run -Dspring.profiles.active=custom +gradle bootRun -Dspring.profiles.active=custom ``` ## TODO diff --git a/build.gradle b/build.gradle index e17f5e7..e84e685 100644 --- a/build.gradle +++ b/build.gradle @@ -39,3 +39,8 @@ dependencies { testCompile 'org.springframework.boot:spring-boot-starter-test' testCompile 'br.com.six2six:fixture-factory:3.1.0' } + +bootRun { + String activeProfile = System.properties['spring.profiles.active'] + systemProperty "spring.profiles.active", activeProfile +} From 792aa9c5433a4c30ee6e87a8efa3d5c062de7919 Mon Sep 17 00:00:00 2001 From: "andre.formento" Date: Mon, 10 Jul 2017 17:19:01 -0300 Subject: [PATCH 10/54] =?UTF-8?q?Atualiza=20vers=C3=A3o=20do=20Spring=20Bo?= =?UTF-8?q?ot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - build.gradle | 2 +- ...cApiControllerExternalIntegrationTest.java | 40 ++++++++----------- .../GenericApiControllerIntegrationTest.java | 29 +++++++------- .../api/v1/mapper/RequestMapperTest.java | 3 +- .../mock/generic/mapper/EndpointDtoTest.java | 7 ++-- .../mock/generic/mapper/ResponseDtoTest.java | 7 ++-- ...pointBackupServiceFileIntegrarionTest.java | 5 ++- ...omJsonStringToObjectConverterImplTest.java | 7 ++-- .../impl/JsonValueCompilerImplTest.java | 9 +++-- 10 files changed, 55 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index f3dc0a9..be5d763 100644 --- a/README.md +++ b/README.md @@ -30,4 +30,3 @@ gradle bootRun -Dspring.profiles.active=custom * Adcionar plugin do FindBugs * Revisar dependências (ver, por exemplo, se é mesmo necessário ter o GSON ou modelmapper) * Usar objectmapper como component: `compile('com.fasterxml.jackson.datatype:jackson-datatype-jdk8')` -* Atualizar versão do Spring Boot diff --git a/build.gradle b/build.gradle index e84e685..2e14593 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ buildscript { ext { - springBootVersion = '1.4.7.RELEASE' + springBootVersion = '1.5.4.RELEASE' } repositories { mavenCentral() diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java index c869972..089c27e 100755 --- a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java +++ b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java @@ -1,15 +1,9 @@ package br.com.concrete.mock.generic.api.v1.controller; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Map; -import java.util.Optional; - +import br.com.concrete.mock.generic.mapper.EndpointDto; +import com.google.common.collect.ImmutableMap; +import com.google.gson.Gson; +import org.json.JSONException; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -18,18 +12,18 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; +import org.springframework.http.*; import org.springframework.test.context.junit4.SpringRunner; -import com.google.common.collect.ImmutableMap; -import com.google.gson.Gson; +import java.io.IOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Map; +import java.util.Optional; -import br.com.concrete.mock.generic.mapper.EndpointDto; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -61,16 +55,16 @@ private String getJson(String fileNameExpected) throws IOException { } @Test(timeout = 10000) - public void shouldResolvePostWithExternalMock() throws IOException { + public void shouldResolvePostWithExternalMock() throws IOException, JSONException { shouldResolveWithExternalMock(HttpMethod.POST); } @Test(timeout = 5000) - public void shouldResolvePathWithExternalMock() throws IOException { + public void shouldResolvePathWithExternalMock() throws IOException, JSONException { shouldResolveWithExternalMock(HttpMethod.PATCH); } - private void shouldResolveWithExternalMock(final HttpMethod httpMethod) throws IOException { + private void shouldResolveWithExternalMock(final HttpMethod httpMethod) throws IOException, JSONException { final ImmutableMap headers = ImmutableMap.builder() .put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).build(); @@ -78,7 +72,7 @@ private void shouldResolveWithExternalMock(final HttpMethod httpMethod) throws I } private void shouldResolveWithExternalMock(final HttpMethod httpMethod, final Optional> headers) - throws IOException { + throws IOException, JSONException { // given final String url = "/v2/57fbd6280f0000ed154fd470"; diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java index 97bb5bc..58f110e 100755 --- a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java +++ b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java @@ -4,6 +4,7 @@ import br.com.concrete.mock.generic.mapper.EndpointDto; import br.com.concrete.mock.generic.model.Endpoint; import com.google.gson.Gson; +import org.json.JSONException; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -58,7 +59,7 @@ private String getJson(String fileNameExpected) throws IOException { return Files.exists(path) ? new String(Files.readAllBytes(path)) : "{}"; } - private void shouldResolveGetWithLocalMockMatchQueryCaseX(String uri, String caseX) throws IOException { + private void shouldResolveGetWithLocalMockMatchQueryCaseX(String uri, String caseX) throws IOException, JSONException { // given final String fileName = resource.getFile().concat("get").concat(uri).concat("/").concat(caseX).concat(fileExtension); @@ -85,7 +86,7 @@ private void shouldResolveGetWithLocalMockMatchQueryCaseX(String uri, String cas } @Test(timeout = 2000) - public void shouldResolveGetWithSimpleResponseWithoutRequest() throws IOException { + public void shouldResolveGetWithSimpleResponseWithoutRequest() throws IOException, JSONException { // given final String uri = "/guests/132/users/21/cc"; final String fileName = resource.getFile().concat("get" + uri + "/1" + fileExtension); @@ -103,7 +104,7 @@ public void shouldResolveGetWithSimpleResponseWithoutRequest() throws IOExceptio } @Test(timeout = 2000) - public void shouldResolveGetWithSimpleResponseWithRequest() throws IOException { + public void shouldResolveGetWithSimpleResponseWithRequest() throws IOException, JSONException { // given final String uri = "/guests/132/users/22/cc"; final String fileName = resource.getFile().concat("get" + uri + "/1" + fileExtension); @@ -121,7 +122,7 @@ public void shouldResolveGetWithSimpleResponseWithRequest() throws IOException { } @Test(timeout = 2000) - public void shouldResolveGetWithLocalMock() throws IOException { + public void shouldResolveGetWithLocalMock() throws IOException, JSONException { // given final String uri = "/users/123"; @@ -138,7 +139,7 @@ public void shouldResolveGetWithLocalMock() throws IOException { } @Test(timeout = 2000) - public void shouldResolveWithHttpStatusCreated() throws IOException { + public void shouldResolveWithHttpStatusCreated() throws IOException, JSONException { // given final String uri = "/users/123"; @@ -156,31 +157,31 @@ public void shouldResolveWithHttpStatusCreated() throws IOException { } @Test(timeout = 2000) - public void shouldResolvePatchWithLocalMock() throws IOException { + public void shouldResolvePatchWithLocalMock() throws IOException, JSONException { shouldResolveWithLocalMockMatcheRequest("/users/1456", "1", HttpStatus.OK, HttpMethod.PATCH); } @Test(timeout = 2000) - public void shouldResolveGetWithLocalMockMatchQueryCase1() throws IOException { + public void shouldResolveGetWithLocalMockMatchQueryCase1() throws IOException, JSONException { shouldResolveGetWithLocalMockMatchQueryCaseX("/payments/user/detail", "1"); } @Test(timeout = 2000) - public void shouldResolveGetWithLocalMockMatchQueryCase2() throws IOException { + public void shouldResolveGetWithLocalMockMatchQueryCase2() throws IOException, JSONException { shouldResolveGetWithLocalMockMatchQueryCaseX("/payments/user/detail", "2"); } // fail @Test(timeout = 2000) - public void shouldResolveGetWithLocalMockWithSubDirectory() throws IOException { + public void shouldResolveGetWithLocalMockWithSubDirectory() throws IOException, JSONException { shouldResolveGetWithLocalMockMatchQueryCaseX("/guests/132", "1"); } - private void shouldResolvePostWithLocalMockMatcheRequest(final String url, final String caseX, final HttpStatus httpStatus) throws IOException { + private void shouldResolvePostWithLocalMockMatcheRequest(final String url, final String caseX, final HttpStatus httpStatus) throws IOException, JSONException { shouldResolveWithLocalMockMatcheRequest(url, caseX, httpStatus, HttpMethod.POST); } - private void shouldResolveWithLocalMockMatcheRequest(final String uri, final String caseX, final HttpStatus httpStatus, HttpMethod httpMethod) throws IOException { + private void shouldResolveWithLocalMockMatcheRequest(final String uri, final String caseX, final HttpStatus httpStatus, HttpMethod httpMethod) throws IOException, JSONException { // given final String fileName = resource.getFile().concat(httpMethod.name().toLowerCase()).concat(uri).concat("/").concat(caseX).concat(fileExtension); @@ -202,17 +203,17 @@ private void shouldResolveWithLocalMockMatcheRequest(final String uri, final Str } @Test(timeout = 2000) - public void shouldResolvePostWithLocalMockMatcheRequest() throws IOException { + public void shouldResolvePostWithLocalMockMatcheRequest() throws IOException, JSONException { shouldResolvePostWithLocalMockMatcheRequest("/move/to/country/13", "1", HttpStatus.OK); } @Test//(timeout = 2000) - public void shouldResolvePostWithLocalMockMatcheRequestCase1() throws IOException { + public void shouldResolvePostWithLocalMockMatcheRequestCase1() throws IOException, JSONException { shouldResolvePostWithLocalMockMatcheRequest("/move/to/country/13/pi", "1", HttpStatus.OK); } @Test(timeout = 2000) - public void shouldResolvePostWithLocalMockMatcheRequestCase2() throws IOException { + public void shouldResolvePostWithLocalMockMatcheRequestCase2() throws IOException, JSONException { shouldResolvePostWithLocalMockMatcheRequest("/move/to/country/13/pi", "2", HttpStatus.UNPROCESSABLE_ENTITY); } diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapperTest.java b/src/test/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapperTest.java index 5333621..ca75061 100755 --- a/src/test/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapperTest.java +++ b/src/test/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapperTest.java @@ -4,6 +4,7 @@ import br.com.concrete.mock.generic.mapper.QueryMapper; import br.com.concrete.mock.generic.model.Request; import com.google.common.collect.ImmutableMap; +import org.json.JSONException; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Answers; @@ -114,7 +115,7 @@ public void shouldMapRequestWithQueryString() throws URISyntaxException { } @Test - public void shouldMapRequestWithBody() throws URISyntaxException { + public void shouldMapRequestWithBody() throws URISyntaxException, JSONException { // given final MockHttpServletRequest httpServletRequest = new MockHttpServletRequest(); diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java index 86c22e6..8721611 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java +++ b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java @@ -6,6 +6,7 @@ import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import com.google.gson.Gson; +import org.json.JSONException; import org.junit.BeforeClass; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -54,7 +55,7 @@ public void shouldConvertResponse() { } @Test - public void shouldConvertFromModel() { + public void shouldConvertFromModel() throws JSONException { // given final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID_FULL); final String expectedJson = "{\n" + @@ -88,7 +89,7 @@ public void shouldConvertFromModel() { } @Test - public void shouldConvertFromModelWithoutHttpStatus() { + public void shouldConvertFromModelWithoutHttpStatus() throws JSONException { // given final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID_FULL); final String expectedJson = "{\n" + @@ -120,7 +121,7 @@ public void shouldConvertFromModelWithoutHttpStatus() { } @Test - public void shouldConvertFromModelWithList() { + public void shouldConvertFromModelWithList() throws JSONException { // given final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID_WITH_LIST); final String expectedJson = "{\n" + diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java index a21a6ce..55020ad 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java +++ b/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java @@ -6,6 +6,7 @@ import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import com.google.gson.Gson; +import org.json.JSONException; import org.junit.BeforeClass; import org.junit.Test; import org.skyscreamer.jsonassert.JSONAssert; @@ -21,7 +22,7 @@ public static void initClass() { } @Test - public void shouldConvertFromJsonAnObject() { + public void shouldConvertFromJsonAnObject() throws JSONException { // given final String json = "{ \"body\": { \"tt\": \"789\" } }"; @@ -51,7 +52,7 @@ public void shouldConvertFromJsonAListOfObjects() { } @Test - public void shouldBeSerializableWhenIsObject() { + public void shouldBeSerializableWhenIsObject() throws JSONException { // given final Response model = Fixture.from(Response.class).gimme(ResponseTemplate.VALID_FULL); final String expectedJson = "{ \"body\": {\"name\": \"Paul\"} }"; @@ -65,7 +66,7 @@ public void shouldBeSerializableWhenIsObject() { } @Test - public void shouldBeSerializableWhenIsArray() { + public void shouldBeSerializableWhenIsArray() throws JSONException { // given final Response model = Fixture.from(Response.class).gimme(ResponseTemplate.VALID_WITH_LIST); final String expectedJson = "{ \"body\": [ {\"name\": \"Paul\"}, {\"name\": \"Peter\"} ] }"; diff --git a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java b/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java index eea7f77..2c763ed 100755 --- a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java +++ b/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java @@ -7,6 +7,7 @@ import br.com.concrete.mock.infra.property.FileProperty; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; +import org.json.JSONException; import org.junit.*; import org.junit.runner.RunWith; import org.skyscreamer.jsonassert.JSONAssert; @@ -92,7 +93,7 @@ public void setupRestore() throws IOException { @Test(timeout = 2000) @Ignore - public void shouldDoARequestAndDoNotCaptureBackupWhenIsNotConfigured() throws IOException { + public void shouldDoARequestAndDoNotCaptureBackupWhenIsNotConfigured() throws IOException, JSONException { // when final ResponseEntity response = restTemplate.getForEntity(uri, String.class); @@ -104,7 +105,7 @@ public void shouldDoARequestAndDoNotCaptureBackupWhenIsNotConfigured() throws IO } @Test//(timeout = 2000) - public void shouldDoARequestAndCaptureBackupWhenIsConfigured() throws IOException { + public void shouldDoARequestAndCaptureBackupWhenIsConfigured() throws IOException, JSONException { // given final String path = "/v2/5928a3aa0f0000140538834a"; final String name = baseName + "get" + path; diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java b/src/test/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java index c73b870..a08f67a 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java +++ b/src/test/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java @@ -2,6 +2,7 @@ import com.google.gson.Gson; +import org.json.JSONException; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -17,7 +18,7 @@ public class FromJsonStringToObjectConverterImplTest { private FromJsonStringToObjectConverterImpl converter; @Test - public void shouldConvertObject() { + public void shouldConvertObject() throws JSONException { // given final String expectedJson = "{ \"name\": \"Peter\", \"age\": 99}"; final Optional jsonString = Optional.of(expectedJson); @@ -31,7 +32,7 @@ public void shouldConvertObject() { } @Test - public void shouldConvertArray() { + public void shouldConvertArray() throws JSONException { // given final String expectedJson = " [ { \"name\": \"Peter\", \"age\": 99}, { \"name\": \"Paul\", \"age\": 98} ]"; final Optional jsonString = Optional.of(expectedJson); @@ -45,7 +46,7 @@ public void shouldConvertArray() { } @Test - public void shouldConvertNull() { + public void shouldConvertNull() throws JSONException { // given final String expectedJson = "{ }"; final Optional jsonString = Optional.of(expectedJson); diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImplTest.java b/src/test/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImplTest.java index 521356e..91bee45 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImplTest.java +++ b/src/test/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImplTest.java @@ -1,5 +1,6 @@ package br.com.concrete.mock.infra.component.impl; +import org.json.JSONException; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -16,7 +17,7 @@ public class JsonValueCompilerImplTest { private JsonValueCompilerImpl jsonValueCompiler; @Test - public void shouldBeEqualWhenNotExistVariables() { + public void shouldBeEqualWhenNotExistVariables() throws JSONException { // given final String jsonWithValue = "{ \"id\": \"first\", \"name\": \"Paul\" }"; @@ -28,7 +29,7 @@ public void shouldBeEqualWhenNotExistVariables() { } @Test - public void shouldCompileVariable3daysAgo() { + public void shouldCompileVariable3daysAgo() throws JSONException { // given final String format = "YYYY/MM/dd"; final String jsonWithValue = "{ \"date1\": \"#{{3daysAgo:" + format + "}}\", \"name\": \"Paul\" }"; @@ -43,7 +44,7 @@ public void shouldCompileVariable3daysAgo() { } @Test - public void shouldCompileVariable3daysAgoRepeated() { + public void shouldCompileVariable3daysAgoRepeated() throws JSONException { // given final String format = "YYYY/MM/dd"; final String jsonWithValue = "{ \"date1\": \"#{{3daysAgo:" + format + "}}\", \"date2\": \"#{{3daysAgo:" + format + "}}\", \"name\": \"Paul\" }"; @@ -58,7 +59,7 @@ public void shouldCompileVariable3daysAgoRepeated() { } @Test - public void shouldCompileVariableNdaysAgo() { + public void shouldCompileVariableNdaysAgo() throws JSONException { // given final String format = "YYYY/MM/dd"; final String jsonWithValue = "{ \"date1\": \"#{{3daysAgo:" + format + "}}\", \"date2\": \"#{{3daysAgo:" + format + "}}\", \"date3\": \"#{{7daysAgo:" + format + "}}\", \"date4\": \"#{{8daysAgo:" + format + "}}\", \"name\": \"Paul\" }"; From a9d764205128b12bbc08285acbe614b4055141b6 Mon Sep 17 00:00:00 2001 From: Kleber Almeida Toyota Date: Thu, 13 Jul 2017 17:03:02 -0300 Subject: [PATCH 11/54] Arrumando RestTemplate --- build.gradle | 5 +---- src/main/java/br/com/concrete/mock/ApiApplication.java | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 2e14593..a2daa3c 100644 --- a/build.gradle +++ b/build.gradle @@ -23,15 +23,12 @@ repositories { dependencies { - compile('org.springframework.boot:spring-boot-starter', { - exclude module: 'org.apache.httpcomponents:httpclient' - }) + compile 'org.springframework.boot:spring-boot-starter' compile 'org.springframework.boot:spring-boot-starter-undertow' compile 'org.springframework.boot:spring-boot-starter-hateoas' compile 'com.google.code.gson:gson' compile 'javax.ws.rs:javax.ws.rs-api:2.0' compile 'net.minidev:json-smart:1.0.8' - compile 'org.apache.httpcomponents:httpclient' compile 'com.google.guava:guava:22.0' compile 'org.modelmapper:modelmapper:0.7.5' compile 'commons-io:commons-io:2.5' diff --git a/src/main/java/br/com/concrete/mock/ApiApplication.java b/src/main/java/br/com/concrete/mock/ApiApplication.java index c61d41b..e70d881 100755 --- a/src/main/java/br/com/concrete/mock/ApiApplication.java +++ b/src/main/java/br/com/concrete/mock/ApiApplication.java @@ -17,11 +17,8 @@ public static void main(String[] args) { } @Bean - public RestTemplate restTemplate() { - final RestTemplate restTemplate = new RestTemplate(); - restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(HttpClients.createDefault())); - - return restTemplate; + public RestTemplate restTemplate(RestTemplateBuilder builder) { + return builder.build(); } } From 2b2566de18afe87c6d0e3409d4c69116d585b7f4 Mon Sep 17 00:00:00 2001 From: Kleber Almeida Toyota Date: Thu, 13 Jul 2017 17:21:04 -0300 Subject: [PATCH 12/54] Arrumando dependencias --- build.gradle | 1 + src/main/java/br/com/concrete/mock/ApiApplication.java | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index a2daa3c..218593f 100644 --- a/build.gradle +++ b/build.gradle @@ -25,6 +25,7 @@ repositories { dependencies { compile 'org.springframework.boot:spring-boot-starter' compile 'org.springframework.boot:spring-boot-starter-undertow' + compile 'org.springframework.boot:spring-boot-starter-web' compile 'org.springframework.boot:spring-boot-starter-hateoas' compile 'com.google.code.gson:gson' compile 'javax.ws.rs:javax.ws.rs-api:2.0' diff --git a/src/main/java/br/com/concrete/mock/ApiApplication.java b/src/main/java/br/com/concrete/mock/ApiApplication.java index e70d881..698c7dc 100755 --- a/src/main/java/br/com/concrete/mock/ApiApplication.java +++ b/src/main/java/br/com/concrete/mock/ApiApplication.java @@ -1,11 +1,9 @@ package br.com.concrete.mock; -import org.apache.http.impl.client.HttpClients; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; @SpringBootApplication From c034192d104fd1d5f4e80b833be2280a2ae05e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Formento?= Date: Fri, 14 Jul 2017 21:53:32 -0300 Subject: [PATCH 13/54] =?UTF-8?q?Corrige=20erro=20de=20compila=C3=A7=C3=A3?= =?UTF-8?q?o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/br/com/concrete/mock/ApiApplication.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/br/com/concrete/mock/ApiApplication.java b/src/main/java/br/com/concrete/mock/ApiApplication.java index 698c7dc..4b88e59 100755 --- a/src/main/java/br/com/concrete/mock/ApiApplication.java +++ b/src/main/java/br/com/concrete/mock/ApiApplication.java @@ -2,6 +2,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.web.client.RestTemplate; From 44aaeba866ae3734dc486a9e83d8f031d8b8ba7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Formento?= Date: Fri, 14 Jul 2017 22:24:50 -0300 Subject: [PATCH 14/54] Corrige quebra de testes integrados --- build.gradle | 3 ++- .../br/com/concrete/mock/ApiApplication.java | 10 ++++++-- .../mock/infra/component/ExternalApi.java | 24 ++++--------------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/build.gradle b/build.gradle index 218593f..1f76ae7 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ repositories { dependencies { - compile 'org.springframework.boot:spring-boot-starter' + compile('org.springframework.boot:spring-boot-starter') compile 'org.springframework.boot:spring-boot-starter-undertow' compile 'org.springframework.boot:spring-boot-starter-web' compile 'org.springframework.boot:spring-boot-starter-hateoas' @@ -33,6 +33,7 @@ dependencies { compile 'com.google.guava:guava:22.0' compile 'org.modelmapper:modelmapper:0.7.5' compile 'commons-io:commons-io:2.5' + compile 'org.apache.httpcomponents:httpclient:4.4.1' testCompile 'org.springframework.boot:spring-boot-starter-test' testCompile 'br.com.six2six:fixture-factory:3.1.0' diff --git a/src/main/java/br/com/concrete/mock/ApiApplication.java b/src/main/java/br/com/concrete/mock/ApiApplication.java index 4b88e59..484a50c 100755 --- a/src/main/java/br/com/concrete/mock/ApiApplication.java +++ b/src/main/java/br/com/concrete/mock/ApiApplication.java @@ -1,10 +1,14 @@ package br.com.concrete.mock; +import org.apache.http.client.HttpClient; +import org.apache.http.impl.client.HttpClientBuilder; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; @SpringBootApplication @@ -16,8 +20,10 @@ public static void main(String[] args) { } @Bean - public RestTemplate restTemplate(RestTemplateBuilder builder) { - return builder.build(); + public RestTemplate restTemplate() { + HttpClient httpClient = HttpClientBuilder.create().build(); + ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); + return new RestTemplate(requestFactory); } } diff --git a/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java b/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java index a8e6a56..81ecea8 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java +++ b/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java @@ -6,6 +6,8 @@ import br.com.concrete.mock.generic.model.Request; import br.com.concrete.mock.infra.model.UriConfiguration; import br.com.concrete.mock.infra.property.ApiProperty; +import java.util.Optional; +import java.util.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -16,9 +18,6 @@ import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; -import java.util.Optional; -import java.util.regex.Pattern; - @Component public class ExternalApi { @@ -69,22 +68,9 @@ public Optional execute(final Request request) { .concat(parameters); LOGGER.info("URL => {}", url); - ResponseEntity apiResult = null; - try { - apiResult = restTemplate.exchange(url, HttpMethod.valueOf(request.getMethod().name().toUpperCase()), entity, - String.class); - return Optional.of(new ExternalApiResult(apiResult, uriConfiguration)); - } catch (Exception e) { - LOGGER.error("Erro chamada API " + HttpMethod.valueOf(request.getMethod().name().toUpperCase()) + " " + url, - e); - - LOGGER.error("Tentando mais uma vez " + HttpMethod.valueOf(request.getMethod().name().toUpperCase()) + " " - + url); - } - // } - - return Optional.empty(); - + final ResponseEntity apiResult = restTemplate.exchange(url, HttpMethod.valueOf(request.getMethod().name().toUpperCase()), entity, + String.class); + return Optional.of(new ExternalApiResult(apiResult, uriConfiguration)); } } From a4a7d0c80c2edff37c9fe01ede5cb858f18589c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Formento?= Date: Fri, 14 Jul 2017 22:37:44 -0300 Subject: [PATCH 15/54] Add travis --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..562264f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: java +jdk: + - oraclejdk8 + +notifications: + email: false From 41439edb0d0f4054ea210bb701b5d4b7c959e672 Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Thu, 10 Aug 2017 19:37:39 -0300 Subject: [PATCH 16/54] Fix request/response body (de)serialization to JsonElement --- .../java/br/com/concrete/mock/generic/mapper/RequestDto.java | 5 +++-- .../br/com/concrete/mock/generic/mapper/ResponseDto.java | 5 +++-- .../infra/component/FromJsonStringToObjectConverter.java | 4 +++- .../component/impl/FromJsonStringToObjectConverterImpl.java | 5 +++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/RequestDto.java b/src/main/java/br/com/concrete/mock/generic/mapper/RequestDto.java index 2a2b955..0ea573c 100755 --- a/src/main/java/br/com/concrete/mock/generic/mapper/RequestDto.java +++ b/src/main/java/br/com/concrete/mock/generic/mapper/RequestDto.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.Gson; +import com.google.gson.JsonElement; import org.springframework.http.HttpHeaders; import org.springframework.web.bind.annotation.RequestMethod; @@ -18,10 +19,10 @@ public class RequestDto implements Serializable { private final HttpHeaders headers; private final Map query; - private final Object body; + private final JsonElement body; @JsonCreator - public RequestDto(@JsonProperty("headers") HttpHeaders headers, @JsonProperty("query") Map query, @JsonProperty("body") Object body) { + public RequestDto(@JsonProperty("headers") HttpHeaders headers, @JsonProperty("query") Map query, @JsonProperty("body") JsonElement body) { this.headers = headers; this.query = query; this.body = body; diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/ResponseDto.java b/src/main/java/br/com/concrete/mock/generic/mapper/ResponseDto.java index 97a993c..ac01196 100755 --- a/src/main/java/br/com/concrete/mock/generic/mapper/ResponseDto.java +++ b/src/main/java/br/com/concrete/mock/generic/mapper/ResponseDto.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.Gson; +import com.google.gson.JsonElement; import org.springframework.http.HttpStatus; import java.io.Serializable; @@ -15,11 +16,11 @@ public class ResponseDto implements Serializable { private static final Gson GSON = new Gson(); - private final Object body; + private final JsonElement body; private final Integer httpStatus; @JsonCreator - public ResponseDto(@JsonProperty("body") Object body, @JsonProperty("httpStatus") Integer httpStatus) { + public ResponseDto(@JsonProperty("body") JsonElement body, @JsonProperty("httpStatus") Integer httpStatus) { this.body = body; this.httpStatus = httpStatus; } diff --git a/src/main/java/br/com/concrete/mock/infra/component/FromJsonStringToObjectConverter.java b/src/main/java/br/com/concrete/mock/infra/component/FromJsonStringToObjectConverter.java index d5fe862..a2be2fc 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/FromJsonStringToObjectConverter.java +++ b/src/main/java/br/com/concrete/mock/infra/component/FromJsonStringToObjectConverter.java @@ -1,10 +1,12 @@ package br.com.concrete.mock.infra.component; +import com.google.gson.JsonElement; + import java.util.Optional; @FunctionalInterface public interface FromJsonStringToObjectConverter { - Object apply(final Optional json); + JsonElement apply(final Optional json); } diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java b/src/main/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java index 33ff502..b231537 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java +++ b/src/main/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java @@ -1,6 +1,7 @@ package br.com.concrete.mock.infra.component.impl; import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; +import com.google.gson.JsonElement; import com.google.gson.JsonParser; import org.springframework.stereotype.Component; @@ -12,7 +13,7 @@ public class FromJsonStringToObjectConverterImpl implements FromJsonStringToObje private static final JsonParser JSON_PARSER = new JsonParser(); @Override - public Object apply(final Optional json) { + public JsonElement apply(final Optional json) { return json .map(JSON_PARSER::parse) .filter(jsonElement -> !jsonElement.isJsonNull()) @@ -20,7 +21,7 @@ public Object apply(final Optional json) { jsonElement.getAsJsonObject() : jsonElement.getAsJsonArray() ) - .orElse(JSON_PARSER.parse("").getAsJsonNull()); + .orElse(JSON_PARSER.parse("")); } } From 0e1b17db71b45467bad182e446bb1b67a75f9394 Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Fri, 11 Aug 2017 14:53:19 -0300 Subject: [PATCH 17/54] =?UTF-8?q?Corrige=20testes=20unit=C3=A1rios=20e=20i?= =?UTF-8?q?ntegrados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...cApiControllerExternalIntegrationTest.java | 145 +++++++++--------- .../GenericApiControllerIntegrationTest.java | 33 ++-- .../mock/generic/mapper/EndpointDtoTest.java | 2 +- .../mock/generic/mapper/ResponseDtoTest.java | 2 +- .../impl/EndpointRepositoryModelTest.java | 19 ++- .../component/file/FileJsonReaderTest.java | 18 ++- .../file/FileNameGeneratorImplTest.java | 20 +-- 7 files changed, 125 insertions(+), 114 deletions(-) diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java index 089c27e..db544fd 100755 --- a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java +++ b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java @@ -15,8 +15,9 @@ import org.springframework.http.*; import org.springframework.test.context.junit4.SpringRunner; +import java.io.File; import java.io.IOException; -import java.net.URL; +import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Map; @@ -29,76 +30,76 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class GenericApiControllerExternalIntegrationTest { - @Autowired - private TestRestTemplate restTemplate; - - @Value("${file.base}") - private String fileBase; - @Value("${file.extension}") - private String fileExtension; - - private URL resource; - - @Before - public void init() { - this.resource = getClass().getClassLoader().getResource(fileBase); - } - - @Test - public void shouldFileExistsInTest() { - assertNotNull(resource); - assertNotNull(resource.getFile()); - } - - private String getJson(String fileNameExpected) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileNameExpected))); - } - - @Test(timeout = 10000) - public void shouldResolvePostWithExternalMock() throws IOException, JSONException { - shouldResolveWithExternalMock(HttpMethod.POST); - } - - @Test(timeout = 5000) - public void shouldResolvePathWithExternalMock() throws IOException, JSONException { - shouldResolveWithExternalMock(HttpMethod.PATCH); - } - - private void shouldResolveWithExternalMock(final HttpMethod httpMethod) throws IOException, JSONException { - final ImmutableMap headers = ImmutableMap.builder() - .put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).build(); - - shouldResolveWithExternalMock(httpMethod, Optional.of(headers)); - } - - private void shouldResolveWithExternalMock(final HttpMethod httpMethod, final Optional> headers) - throws IOException, JSONException { - // given - final String url = "/v2/57fbd6280f0000ed154fd470"; - - final HttpStatus httpStatus = HttpStatus.OK; - final String fileName = resource.getFile().concat("/").concat(httpMethod.name().toLowerCase()).concat(url) - .concat("/1").concat(fileExtension); - - final EndpointDto endpointDto = new Gson().fromJson(getJson(fileName), EndpointDto.class); - final String requestJson = new Gson().toJson(endpointDto.getRequest().getBody()); - final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); - - final HttpHeaders httpHeaders = headers.filter(mapHeaders -> !mapHeaders.isEmpty()).map(map -> { - final HttpHeaders result = new HttpHeaders(); - result.setContentType(MediaType.APPLICATION_JSON); - return result; - }).orElse(null); - - final HttpEntity httpEntity = new HttpEntity<>(requestJson, httpHeaders); - - // when - final ResponseEntity response = restTemplate.exchange(url, httpMethod, httpEntity, String.class); - - // then - assertEquals(httpStatus, response.getStatusCode()); - JSONAssert.assertEquals(responseJson, response.getBody(), false); - assertNotNull(response.getHeaders().get("Access-Control-Allow-Origin")); - } + @Autowired + private TestRestTemplate restTemplate; + + @Value("${file.base}") + private String fileBase; + @Value("${file.extension}") + private String fileExtension; + + private File resource; + + @Before + public void init() throws URISyntaxException { + this.resource = Paths.get(getClass().getClassLoader().getResource(fileBase).toURI()).toFile(); + } + + @Test + public void shouldFileExistsInTest() { + assertNotNull(resource); + } + + private String getJson(String fileNameExpected) throws IOException { + return new String(Files.readAllBytes(Paths.get(fileNameExpected))); + } + + @Test(timeout = 10000) + public void shouldResolvePostWithExternalMock() throws IOException, JSONException { + shouldResolveWithExternalMock(HttpMethod.POST); + } + + @Test(timeout = 5000) + public void shouldResolvePathWithExternalMock() throws IOException, JSONException { + shouldResolveWithExternalMock(HttpMethod.PATCH); + } + + private void shouldResolveWithExternalMock(final HttpMethod httpMethod) throws IOException, JSONException { + final ImmutableMap headers = ImmutableMap.builder() + .put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).build(); + + shouldResolveWithExternalMock(httpMethod, Optional.of(headers)); + } + + private void shouldResolveWithExternalMock(final HttpMethod httpMethod, final Optional> headers) + throws IOException, JSONException { + // given + final String url = "/v2/57fbd6280f0000ed154fd470"; + + final HttpStatus httpStatus = HttpStatus.OK; + final String fileName = + Paths.get(resource.getAbsolutePath(), httpMethod.name().toLowerCase(), url, "1" + fileExtension) + .toAbsolutePath().toString(); + + final EndpointDto endpointDto = new Gson().fromJson(getJson(fileName), EndpointDto.class); + final String requestJson = new Gson().toJson(endpointDto.getRequest().getBody()); + final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); + + final HttpHeaders httpHeaders = headers.filter(mapHeaders -> !mapHeaders.isEmpty()).map(map -> { + final HttpHeaders result = new HttpHeaders(); + result.setContentType(MediaType.APPLICATION_JSON); + return result; + }).orElse(null); + + final HttpEntity httpEntity = new HttpEntity<>(requestJson, httpHeaders); + + // when + final ResponseEntity response = restTemplate.exchange(url, httpMethod, httpEntity, String.class); + + // then + assertEquals(httpStatus, response.getStatusCode()); + JSONAssert.assertEquals(responseJson, response.getBody(), false); + assertNotNull(response.getHeaders().get("Access-Control-Allow-Origin")); + } } diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java index 58f110e..37d8c94 100755 --- a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java +++ b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java @@ -17,7 +17,9 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.bind.annotation.RequestMethod; +import java.io.File; import java.io.IOException; +import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; @@ -41,17 +43,16 @@ public class GenericApiControllerIntegrationTest { @Value("${file.base}") private String fileBase; - private URL resource; + private File resource; @Before - public void init() { - this.resource = getClass().getClassLoader().getResource(fileBase.concat("/")); + public void init() throws URISyntaxException { + this.resource = Paths.get(getClass().getClassLoader().getResource(fileBase).toURI()).toFile(); } @Test public void shouldFileExistsInTest() { assertNotNull(resource); - assertNotNull(resource.getFile()); } private String getJson(String fileNameExpected) throws IOException { @@ -61,7 +62,9 @@ private String getJson(String fileNameExpected) throws IOException { private void shouldResolveGetWithLocalMockMatchQueryCaseX(String uri, String caseX) throws IOException, JSONException { // given - final String fileName = resource.getFile().concat("get").concat(uri).concat("/").concat(caseX).concat(fileExtension); + final String fileName = + Paths.get(resource.getAbsolutePath(), "get", uri, caseX + fileExtension) + .toAbsolutePath().toString(); final String endpointJson = getJson(fileName); @@ -89,7 +92,9 @@ private void shouldResolveGetWithLocalMockMatchQueryCaseX(String uri, String cas public void shouldResolveGetWithSimpleResponseWithoutRequest() throws IOException, JSONException { // given final String uri = "/guests/132/users/21/cc"; - final String fileName = resource.getFile().concat("get" + uri + "/1" + fileExtension); + final String fileName = + Paths.get(resource.getAbsolutePath(), "get", uri, "1" + fileExtension) + .toAbsolutePath().toString(); final String endpointJson = getJson(fileName); final EndpointDto endpointDto = new Gson().fromJson(endpointJson, EndpointDto.class); final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); @@ -107,7 +112,9 @@ public void shouldResolveGetWithSimpleResponseWithoutRequest() throws IOExceptio public void shouldResolveGetWithSimpleResponseWithRequest() throws IOException, JSONException { // given final String uri = "/guests/132/users/22/cc"; - final String fileName = resource.getFile().concat("get" + uri + "/1" + fileExtension); + final String fileName = + Paths.get(resource.getAbsolutePath(), "get", uri, "1" + fileExtension) + .toAbsolutePath().toString(); final String endpointJson = getJson(fileName); final EndpointDto endpointDto = new Gson().fromJson(endpointJson, EndpointDto.class); final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); @@ -126,7 +133,9 @@ public void shouldResolveGetWithLocalMock() throws IOException, JSONException { // given final String uri = "/users/123"; - final String fileName = resource.getFile().concat("get").concat(uri).concat("/1").concat(fileExtension); + final String fileName = + Paths.get(resource.getAbsolutePath(), "get", uri, "1" + fileExtension) + .toAbsolutePath().toString(); final EndpointDto endpointDto = new Gson().fromJson(getJson(fileName), EndpointDto.class); final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); @@ -143,7 +152,9 @@ public void shouldResolveWithHttpStatusCreated() throws IOException, JSONExcepti // given final String uri = "/users/123"; - final String fileName = resource.getFile().concat("get").concat(uri).concat("/2").concat(fileExtension); + final String fileName = + Paths.get(resource.getAbsolutePath(), "get", uri, "2" + fileExtension) + .toAbsolutePath().toString(); final EndpointDto endpointDto = new Gson().fromJson(getJson(fileName), EndpointDto.class); final String responseJson = new Gson().toJson(endpointDto.getResponse().getBody()); final String query = queryStringBuilder.fromMap(endpointDto.getRequest().getQuery()); @@ -183,7 +194,9 @@ private void shouldResolvePostWithLocalMockMatcheRequest(final String url, final private void shouldResolveWithLocalMockMatcheRequest(final String uri, final String caseX, final HttpStatus httpStatus, HttpMethod httpMethod) throws IOException, JSONException { // given - final String fileName = resource.getFile().concat(httpMethod.name().toLowerCase()).concat(uri).concat("/").concat(caseX).concat(fileExtension); + final String fileName = + Paths.get(resource.getAbsolutePath(), httpMethod.name().toLowerCase(), uri, caseX + fileExtension) + .toAbsolutePath().toString(); final EndpointDto endpointDto = new Gson().fromJson(getJson(fileName), EndpointDto.class); final String requestJson = new Gson().toJson(endpointDto.getRequest().getBody()); diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java index 8721611..b49cedb 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java +++ b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java @@ -51,7 +51,7 @@ public void shouldConvertResponse() { assertNotNull(endpoint); assertNotNull(endpoint.getResponse()); assertNotNull(endpoint.getResponse().getBody()); - assertEquals("[{\"age\":8.0}]", endpoint.getResponse().getBody()); + assertEquals("[{\"age\":8}]", endpoint.getResponse().getBody()); } @Test diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java index 55020ad..fbeda82 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java +++ b/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java @@ -48,7 +48,7 @@ public void shouldConvertFromJsonAListOfObjects() { // then assertNotNull(response); assertNotNull(response.getBody()); - assertEquals("[{\"age\":10.0},{\"age\":11.0}]", response.getBody()); + assertEquals("[{\"age\":10},{\"age\":11}]", response.getBody()); } @Test diff --git a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java b/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java index 0d9cb05..804673d 100755 --- a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java +++ b/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java @@ -20,8 +20,10 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.bind.annotation.RequestMethod; +import java.io.File; import java.io.IOException; -import java.net.URL; +import java.net.URISyntaxException; +import java.nio.file.Paths; import java.util.Collection; import java.util.Optional; @@ -47,7 +49,9 @@ public class EndpointRepositoryModelTest { private BaseFileNameBuilderModel baseFileNameBuilder; @Mock private EndpointFileFilterRequest endpointMockFileFilterRequest; - private URL resource; + + private File resource; + @Value("${file.base}") private String fileBase; @Value("${file.extension}") @@ -59,14 +63,13 @@ public static void initClass() { } @Before - public void init() { - this.resource = getClass().getClassLoader().getResource(fileBase.concat(NAME)); + public void init() throws URISyntaxException { + this.resource = Paths.get(getClass().getClassLoader().getResource(fileBase).toURI()).toFile(); } @Test public void shouldFileExistsInTest() { assertNotNull(resource); - assertNotNull(resource.getFile()); } @Test @@ -74,7 +77,7 @@ public void shouldFindSomeResponse() throws IOException { // given final RequestMethod requestMethod = RequestMethod.GET; final String requestUrl = "person/11"; - final String basePath = resource.getFile() + requestUrl; + final String basePath = Paths.get(resource.getAbsolutePath(), requestMethod.toString(), requestUrl).toAbsolutePath().toString(); final Optional endpoint = Optional.of(Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID)); // when @@ -94,7 +97,7 @@ public void shouldNotFindResponseWhenDoNotExists() throws IOException { // given final RequestMethod requestMethod = RequestMethod.GET; final String requestUrl = "/person/66"; - final String basePath = resource.getFile() + requestUrl; + final String basePath = Paths.get(resource.getAbsolutePath(), requestUrl).toAbsolutePath().toString(); // when when(baseFileNameBuilder.buildPath(any(), any())).thenReturn(basePath); @@ -110,7 +113,7 @@ public void shouldNotFindResponseWhenDoNotExists() throws IOException { public void shouldFilterByMethodAndUriAndQuery() { // given final String requestUrl = "person/11"; - final String basePath = resource.getFile() + requestUrl; + final String basePath = Paths.get(resource.getAbsolutePath(), requestUrl).toAbsolutePath().toString(); final Optional result = Optional.empty(); // when diff --git a/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java b/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java index e629adb..0e1a2ca 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java +++ b/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java @@ -8,8 +8,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import java.io.File; import java.io.IOException; +import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.Paths; import java.util.Optional; import static org.hamcrest.CoreMatchers.containsString; @@ -24,26 +27,26 @@ public class FileJsonReaderTest { @InjectMocks private FileJsonReader fileJsonReader; - private URL resource; + private File resource; @Value("${file.base}") private String fileBase; @Before - public void init() { - this.resource = getClass().getClassLoader().getResource(fileBase.concat(NAME)); + public void init() throws URISyntaxException { + File dir = Paths.get(getClass().getClassLoader().getResource(fileBase).toURI()).toFile(); + this.resource = Paths.get(dir.getAbsolutePath(), NAME).toFile(); } @Test public void shouldFileExistsInTest() { assertNotNull(resource); - assertNotNull(resource.getFile()); } @Test public void shouldReadFile() throws IOException { // when - final Optional jsonFile = fileJsonReader.getJsonByFileName(resource.getFile()); + final Optional jsonFile = fileJsonReader.getJsonByFileName(resource.getAbsolutePath()); // then assertTrue(jsonFile.isPresent()); @@ -53,7 +56,10 @@ public void shouldReadFile() throws IOException { @Test public void shouldReturnEmptyWhenFileNotFound() throws IOException { // when - final Optional jsonFile = fileJsonReader.getJsonByFileName(resource.getFile() + "-file-not-found"); + final Optional jsonFile = + fileJsonReader.getJsonByFileName( + Paths.get(resource.getAbsolutePath(), "-file-not-found" + ).toAbsolutePath().toString()); // then assertFalse(jsonFile.isPresent()); diff --git a/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java b/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java index a63b628..b026d55 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java +++ b/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java @@ -15,6 +15,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.attribute.FileAttribute; import java.util.Optional; import static org.junit.Assert.assertEquals; @@ -36,22 +37,9 @@ public class FileNameGeneratorImplTest { @Before public void init() throws IOException { - path = Optional - .ofNullable(getClass().getClassLoader().getResource("mocks-test")) - .map(URL::getFile) - .map(f -> new File(f, "filenametest")) - .map(file -> { - try { - final Path p = Paths.get(file.getAbsolutePath()); - FileUtils.deleteDirectory(file); - - return Files.createDirectories(p); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - }) - .orElse(null); + path = + Files.createTempDirectory("filenametest") + .toAbsolutePath(); } @Test From 39a5c4cda058f29303741fcd128ac20f6a30db92 Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Fri, 11 Aug 2017 15:25:53 -0300 Subject: [PATCH 18/54] Adcionando configs tanto para travis-ci quanto codecov --- .travis.yml | 14 +++++++++++++- build.gradle | 13 +++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 562264f..a0d3488 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,18 @@ language: java jdk: - - oraclejdk8 +- oraclejdk8 +before_cache: +- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock +- rm -fr $HOME/.gradle/caches/*/plugin-resolution/ +cache: + directories: + - "$HOME/.gradle/caches/" + - "$HOME/.gradle/wrapper/" +script: +- gradle check +- gradle codeCoverageReport +after_success: +- bash <(curl -s https://codecov.io/bash) -t notifications: email: false diff --git a/build.gradle b/build.gradle index 1f76ae7..11cc0cf 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,7 @@ buildscript { apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' +apply plugin: 'jacoco' version = '4.0.0-SNAPSHOT' sourceCompatibility = 1.8 @@ -43,3 +44,15 @@ bootRun { String activeProfile = System.properties['spring.profiles.active'] systemProperty "spring.profiles.active", activeProfile } + +task codeCoverageReport(type: JacocoReport) { + executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec") + + sourceSets sourceSets.main + reports { + xml.enabled true + xml.destination "${buildDir}/reports/jacoco/report.xml" + html.enabled false + csv.enabled false + } +} From d01c4c3c1f2290e5f300698d00884ced585423dc Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Fri, 11 Aug 2017 15:49:21 -0300 Subject: [PATCH 19/54] Fixing unit tests --- .../br/com/concrete/mock/generic/mapper/EndpointDtoTest.java | 2 +- .../br/com/concrete/mock/generic/mapper/ResponseDtoTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java index 8721611..d4e2fde 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java +++ b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java @@ -41,7 +41,7 @@ public void shouldConvertRequest() { @Test public void shouldConvertResponse() { // given - final String json = "{\"request\":{\"body\":[{\"run\":\"7\"}]},\"response\":{\"body\":[{\"age\":8}]}}"; + final String json = "{\"request\":{\"body\":[{\"run\":\"7\"}]},\"response\":{\"body\":[{\"age\":8.0}]}}"; // when final EndpointDto endpointDto = new Gson().fromJson(json, EndpointDto.class); diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java index 55020ad..e9756ec 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java +++ b/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java @@ -39,7 +39,7 @@ public void shouldConvertFromJsonAnObject() throws JSONException { @Test public void shouldConvertFromJsonAListOfObjects() { // given - final String json = "{ \"body\": [{ \"age\": 10 }, { \"age\": 11 }] }"; + final String json = "{ \"body\": [{ \"age\": 10.0 }, { \"age\": 11.0 }] }"; // when final ResponseDto responseDto = new Gson().fromJson(json, ResponseDto.class); From b89ce09749489d48fd46b1300629f4f46df7dbd3 Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Fri, 11 Aug 2017 15:54:10 -0300 Subject: [PATCH 20/54] Adding badges to README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index be5d763..da75d46 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Build Status](https://travis-ci.org/concretesolutions/mock-api.svg?branch=master)](https://travis-ci.org/concretesolutions/mock-api) +[![codecov.io](https://codecov.io/github/concretesolutions/mock-api/coverage.svg?branch=master)](https://codecov.io/github/concretesolutions/mock-api?branch=master) + # Mock API App criado para fazer mock com REST utilizando JSON From 96035d28e7b4b743f47237365461995fd665953f Mon Sep 17 00:00:00 2001 From: andreformento Date: Tue, 15 Aug 2017 13:29:56 -0300 Subject: [PATCH 21/54] Corrige testes quebrados --- .../br/com/concrete/mock/generic/mapper/EndpointDtoTest.java | 2 +- .../br/com/concrete/mock/generic/mapper/ResponseDtoTest.java | 2 +- .../generic/repository/impl/EndpointRepositoryModelTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java index 54b134b..b49cedb 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java +++ b/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java @@ -41,7 +41,7 @@ public void shouldConvertRequest() { @Test public void shouldConvertResponse() { // given - final String json = "{\"request\":{\"body\":[{\"run\":\"7\"}]},\"response\":{\"body\":[{\"age\":8.0}]}}"; + final String json = "{\"request\":{\"body\":[{\"run\":\"7\"}]},\"response\":{\"body\":[{\"age\":8}]}}"; // when final EndpointDto endpointDto = new Gson().fromJson(json, EndpointDto.class); diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java b/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java index 32bd5d4..fbeda82 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java +++ b/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java @@ -39,7 +39,7 @@ public void shouldConvertFromJsonAnObject() throws JSONException { @Test public void shouldConvertFromJsonAListOfObjects() { // given - final String json = "{ \"body\": [{ \"age\": 10.0 }, { \"age\": 11.0 }] }"; + final String json = "{ \"body\": [{ \"age\": 10 }, { \"age\": 11 }] }"; // when final ResponseDto responseDto = new Gson().fromJson(json, ResponseDto.class); diff --git a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java b/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java index 804673d..4f882ce 100755 --- a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java +++ b/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java @@ -77,7 +77,7 @@ public void shouldFindSomeResponse() throws IOException { // given final RequestMethod requestMethod = RequestMethod.GET; final String requestUrl = "person/11"; - final String basePath = Paths.get(resource.getAbsolutePath(), requestMethod.toString(), requestUrl).toAbsolutePath().toString(); + final String basePath = Paths.get(resource.getAbsolutePath(), requestMethod.toString().toLowerCase(), requestUrl).toAbsolutePath().toString(); final Optional endpoint = Optional.of(Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID)); // when From 073b6ae3dc06d44313b1416c1527ea048e35baea Mon Sep 17 00:00:00 2001 From: andreformento Date: Tue, 15 Aug 2017 13:37:11 -0300 Subject: [PATCH 22/54] =?UTF-8?q?Otimiza=20propriedades=20n=C3=A3o=20utili?= =?UTF-8?q?zadas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generic/repository/impl/EndpointRepositoryBackup.java | 4 +--- .../mock/generic/repository/impl/EndpointRepositoryBase.java | 5 +---- .../generic/repository/impl/EndpointRepositoryModel.java | 4 +--- .../mock/infra/component/file/BaseFileNameBuilderBase.java | 4 ++-- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBackup.java b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBackup.java index 10e7e8c..8fc0483 100755 --- a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBackup.java +++ b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBackup.java @@ -4,7 +4,6 @@ import br.com.concrete.mock.generic.repository.EndpointRepository; import br.com.concrete.mock.infra.component.file.BaseFileNameBuilder; import br.com.concrete.mock.infra.property.FileExtensionProperty; -import br.com.concrete.mock.infra.property.FileProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; @@ -13,9 +12,8 @@ public class EndpointRepositoryBackup extends EndpointRepositoryBase implements EndpointRepository { @Autowired - public EndpointRepositoryBackup(@Qualifier("FilePropertyBackup") FileProperty fileProperty, FileExtensionProperty fileExtensionProperty, EndpointMapper endpointMapper, @Qualifier("BaseFileNameBuilderBackup") BaseFileNameBuilder baseFileNameBuilder, EndpointFileFilterRequest endpointFileFilterRequest) { + public EndpointRepositoryBackup(FileExtensionProperty fileExtensionProperty, EndpointMapper endpointMapper, @Qualifier("BaseFileNameBuilderBackup") BaseFileNameBuilder baseFileNameBuilder, EndpointFileFilterRequest endpointFileFilterRequest) { super( - fileProperty, fileExtensionProperty, endpointMapper, baseFileNameBuilder, diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBase.java b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBase.java index 3453023..4ffc115 100755 --- a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBase.java +++ b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBase.java @@ -6,7 +6,6 @@ import br.com.concrete.mock.generic.repository.EndpointRepository; import br.com.concrete.mock.infra.component.file.BaseFileNameBuilder; import br.com.concrete.mock.infra.property.FileExtensionProperty; -import br.com.concrete.mock.infra.property.FileProperty; import com.google.common.collect.ImmutableList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,14 +26,12 @@ public class EndpointRepositoryBase implements EndpointRepository { private static final Logger LOGGER = LoggerFactory.getLogger(EndpointRepositoryBase.class); - private final FileProperty fileProperty; private final FileExtensionProperty fileExtensionProperty; private final EndpointMapper endpointMapper; private final BaseFileNameBuilder baseFileNameBuilder; private final EndpointFileFilterRequest endpointFileFilterRequest; - public EndpointRepositoryBase(FileProperty fileProperty, FileExtensionProperty fileExtensionProperty, EndpointMapper endpointMapper, BaseFileNameBuilder baseFileNameBuilder, EndpointFileFilterRequest endpointFileFilterRequest) { - this.fileProperty = fileProperty; + public EndpointRepositoryBase(FileExtensionProperty fileExtensionProperty, EndpointMapper endpointMapper, BaseFileNameBuilder baseFileNameBuilder, EndpointFileFilterRequest endpointFileFilterRequest) { this.fileExtensionProperty = fileExtensionProperty; this.endpointMapper = endpointMapper; this.baseFileNameBuilder = baseFileNameBuilder; diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModel.java b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModel.java index 60e7771..24216de 100755 --- a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModel.java +++ b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModel.java @@ -4,7 +4,6 @@ import br.com.concrete.mock.generic.repository.EndpointRepository; import br.com.concrete.mock.infra.component.file.BaseFileNameBuilder; import br.com.concrete.mock.infra.property.FileExtensionProperty; -import br.com.concrete.mock.infra.property.FileProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; @@ -13,9 +12,8 @@ public class EndpointRepositoryModel extends EndpointRepositoryBase implements EndpointRepository { @Autowired - public EndpointRepositoryModel(@Qualifier("FilePropertyModel") FileProperty fileProperty, FileExtensionProperty fileExtensionProperty, EndpointMapper endpointMapper, @Qualifier("BaseFileNameBuilderModel") BaseFileNameBuilder baseFileNameBuilder, EndpointFileFilterRequest endpointFileFilterRequest) { + public EndpointRepositoryModel(FileExtensionProperty fileExtensionProperty, EndpointMapper endpointMapper, @Qualifier("BaseFileNameBuilderModel") BaseFileNameBuilder baseFileNameBuilder, EndpointFileFilterRequest endpointFileFilterRequest) { super( - fileProperty, fileExtensionProperty, endpointMapper, baseFileNameBuilder, endpointFileFilterRequest diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBase.java b/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBase.java index e03f227..9a67526 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBase.java +++ b/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBase.java @@ -12,14 +12,14 @@ public BaseFileNameBuilderBase(FileProperty fileProperty) { } public String buildPath(RequestMethod requestMethod, String pathUri) { - return buildPath(fileProperty.getFileBase(), requestMethod.name().toLowerCase(), pathUri); + return buildPath(fileProperty.getFileBase(), requestMethod.name(), pathUri); } public String buildPath(String fileBaseName, String methodName, String pathUri) { return new StringBuilder() .append(fileBaseName) .append("/") - .append(methodName) + .append(methodName.toLowerCase()) .append(pathUri) .toString(); } From 5ccb99fbe1e394302d70c96f3d53a6c4211938f3 Mon Sep 17 00:00:00 2001 From: brunoalvesrocha Date: Tue, 15 Aug 2017 13:56:04 -0300 Subject: [PATCH 23/54] adiciona .DS_Store no git ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b22d2cd..f2f2307 100755 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ application-*.yml *.iws *.iml *.ipr +*.DS_Store ### NetBeans ### nbproject/private/ From b8696a9e8ac9e8960922312fc0ae46dbf6dbfb9a Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Tue, 15 Aug 2017 15:13:51 -0300 Subject: [PATCH 24/54] Adding Codacy badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index da75d46..1ea2df6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![Build Status](https://travis-ci.org/concretesolutions/mock-api.svg?branch=master)](https://travis-ci.org/concretesolutions/mock-api) [![codecov.io](https://codecov.io/github/concretesolutions/mock-api/coverage.svg?branch=master)](https://codecov.io/github/concretesolutions/mock-api?branch=master) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/67cdddf44d87495c84e3bddfdb5de074)](https://www.codacy.com/app/jfelipesp/mock-api?utm_source=github.com&utm_medium=referral&utm_content=concretesolutions/mock-api&utm_campaign=Badge_Grade) # Mock API From 1dac7582fe549c0111ed0d2bf1348b4ec6ed65be Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Tue, 15 Aug 2017 15:26:11 -0300 Subject: [PATCH 25/54] Codacy appointed fixes - Removing unused imports - Reordering var declarations --- src/main/java/br/com/concrete/mock/ApiApplication.java | 1 - .../impl/EndpointBackupServiceFileIntegrarionTest.java | 10 +++++----- .../service/impl/EndpointBackupServiceFileTest.java | 10 +++++----- .../mock/infra/component/file/FileJsonReaderTest.java | 1 - .../component/file/FileNameGeneratorImplTest.java | 5 ----- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/main/java/br/com/concrete/mock/ApiApplication.java b/src/main/java/br/com/concrete/mock/ApiApplication.java index 484a50c..91612ab 100755 --- a/src/main/java/br/com/concrete/mock/ApiApplication.java +++ b/src/main/java/br/com/concrete/mock/ApiApplication.java @@ -4,7 +4,6 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.http.client.ClientHttpRequestFactory; diff --git a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java b/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java index 2c763ed..cdb265a 100755 --- a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java +++ b/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java @@ -34,11 +34,6 @@ public class EndpointBackupServiceFileIntegrarionTest { private static final String CONFIGURATION_CAPTURE_STATE = "/configuration/capture-state"; - @BeforeClass - public static void initClass() { - FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); - } - @Autowired private TestRestTemplate restTemplate; @@ -61,6 +56,11 @@ public static void initClass() { private String fileName; private URL resource; + @BeforeClass + public static void initClass() { + FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + } + @Before public void init() throws IOException { final Endpoint endpoint = Fixture.from(Endpoint.class).gimme(EndpointTemplate.VALID); diff --git a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileTest.java b/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileTest.java index 8661a15..ffa5166 100755 --- a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileTest.java +++ b/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileTest.java @@ -39,11 +39,6 @@ public class EndpointBackupServiceFileTest { private static final String BACKUP_TEMP = "backup-temp/"; - @BeforeClass - public static void initClass() { - FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); - } - @InjectMocks private EndpointBackupServiceFile endpointBackupServiceFile; @@ -62,6 +57,11 @@ public static void initClass() { @Mock private EndpointRepository endpointRepository; + @BeforeClass + public static void initClass() { + FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + } + @Test public void shouldDoBackup() throws IOException { // given diff --git a/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java b/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java index 0e1a2ca..76abdaa 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java +++ b/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java @@ -11,7 +11,6 @@ import java.io.File; import java.io.IOException; import java.net.URISyntaxException; -import java.net.URL; import java.nio.file.Paths; import java.util.Optional; diff --git a/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java b/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java index b026d55..9fded17 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java +++ b/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java @@ -1,7 +1,6 @@ package br.com.concrete.mock.infra.component.file; import br.com.concrete.mock.infra.property.FileExtensionProperty; -import org.apache.tomcat.util.http.fileupload.FileUtils; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -9,14 +8,10 @@ import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import java.io.File; import java.io.IOException; -import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.nio.file.attribute.FileAttribute; -import java.util.Optional; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; From de3af985ea74998e7beb9d5ba1001eed7da3e639 Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Tue, 15 Aug 2017 15:34:40 -0300 Subject: [PATCH 26/54] updating codify badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ea2df6..99727d7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Build Status](https://travis-ci.org/concretesolutions/mock-api.svg?branch=master)](https://travis-ci.org/concretesolutions/mock-api) [![codecov.io](https://codecov.io/github/concretesolutions/mock-api/coverage.svg?branch=master)](https://codecov.io/github/concretesolutions/mock-api?branch=master) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/67cdddf44d87495c84e3bddfdb5de074)](https://www.codacy.com/app/jfelipesp/mock-api?utm_source=github.com&utm_medium=referral&utm_content=concretesolutions/mock-api&utm_campaign=Badge_Grade) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/67cdddf44d87495c84e3bddfdb5de074)](https://www.codacy.com/app/concrete/mock-api?utm_source=github.com&utm_medium=referral&utm_content=concretesolutions/mock-api&utm_campaign=Badge_Grade) # Mock API From d5f864b54a5715470b62e72cf843b6c10a21eb19 Mon Sep 17 00:00:00 2001 From: brunoalvesrocha Date: Tue, 15 Aug 2017 21:25:31 -0300 Subject: [PATCH 27/54] Using CommandLineRunner interface springBoot instead @PostConstruct --- .../v1/controller/CaptureStateController.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java b/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java index 5ff5fad..ea86892 100755 --- a/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java +++ b/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java @@ -6,12 +6,12 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import javax.annotation.PostConstruct; - @RestController @RequestMapping("/configuration/capture-state") public class CaptureStateController { @@ -28,13 +28,14 @@ public CaptureStateController(CaptureStateService service) { this.service = service; } - @PostConstruct - public void init (){ - - LOGGER.info("Application capture state: " + captureState); - if(captureState){ - this.service.enable(); - } + @Bean + CommandLineRunner init() { + return args -> { + LOGGER.info("Application capture state: " + captureState); + if(captureState) { + this.service.enable(); + } + }; } @RequestMapping(method = RequestMethod.GET) From 4ada9e9e0f7592bec02caf3c382a2540409cbe2c Mon Sep 17 00:00:00 2001 From: brunoalvesrocha Date: Tue, 15 Aug 2017 21:43:00 -0300 Subject: [PATCH 28/54] fixing_codacy_suggestion --- .../configuration/api/v1/controller/CaptureStateController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java b/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java index ea86892..df08f05 100755 --- a/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java +++ b/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java @@ -29,7 +29,7 @@ public CaptureStateController(CaptureStateService service) { } @Bean - CommandLineRunner init() { + private CommandLineRunner init() { return args -> { LOGGER.info("Application capture state: " + captureState); if(captureState) { From 9b1b7ae245a06d5ed9388cbbc3d108db7ec32af8 Mon Sep 17 00:00:00 2001 From: brunoalvesrocha Date: Tue, 15 Aug 2017 21:45:57 -0300 Subject: [PATCH 29/54] fixing_codacy_suggestion --- .../configuration/api/v1/controller/CaptureStateController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java b/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java index df08f05..04d0838 100755 --- a/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java +++ b/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java @@ -29,7 +29,7 @@ public CaptureStateController(CaptureStateService service) { } @Bean - private CommandLineRunner init() { + private CommandLineRunner onLoad() { return args -> { LOGGER.info("Application capture state: " + captureState); if(captureState) { From 5b7ffeec432bebb39317bc19dc99de222cf45ed5 Mon Sep 17 00:00:00 2001 From: Antonio Sampaio Date: Wed, 16 Aug 2017 15:07:09 -0300 Subject: [PATCH 30/54] Altera maneira como o projeto realiza requisicoes com o verbo http GET --- build.gradle | 1 + .../br/com/concrete/mock/ApiApplication.java | 6 +++ .../v1/controller/GenericApiController.java | 13 +++-- .../generic/service/GenericApiService.java | 2 + .../service/impl/GenericApiServiceImpl.java | 32 ++++++++++++ .../mock/infra/component/ExternalApi.java | 52 +++++++++++++++++-- 6 files changed, 100 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 11cc0cf..4691a52 100644 --- a/build.gradle +++ b/build.gradle @@ -35,6 +35,7 @@ dependencies { compile 'org.modelmapper:modelmapper:0.7.5' compile 'commons-io:commons-io:2.5' compile 'org.apache.httpcomponents:httpclient:4.4.1' + compile 'com.squareup.okhttp3:okhttp:3.8.1' testCompile 'org.springframework.boot:spring-boot-starter-test' testCompile 'br.com.six2six:fixture-factory:3.1.0' diff --git a/src/main/java/br/com/concrete/mock/ApiApplication.java b/src/main/java/br/com/concrete/mock/ApiApplication.java index 91612ab..2ce12db 100755 --- a/src/main/java/br/com/concrete/mock/ApiApplication.java +++ b/src/main/java/br/com/concrete/mock/ApiApplication.java @@ -1,5 +1,6 @@ package br.com.concrete.mock; +import okhttp3.OkHttpClient; import org.apache.http.client.HttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.springframework.boot.SpringApplication; @@ -25,4 +26,9 @@ public RestTemplate restTemplate() { return new RestTemplate(requestFactory); } + @Bean + public OkHttpClient okHttpClient(){ + return new OkHttpClient(); + } + } diff --git a/src/main/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiController.java b/src/main/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiController.java index 95615c5..a632a2c 100755 --- a/src/main/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiController.java +++ b/src/main/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiController.java @@ -9,6 +9,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -51,13 +52,19 @@ private void logJson(final String jsonString) { LOGGER.warn("cannot print json: " + jsonString); } } - private ResponseEntity interceptRequestAnyMedia(final HttpServletRequest request, final Optional requestBody) { logRequest(request, requestBody); - final Optional> responseEntity = genericApiService - .genericResponseEntity(requestMapper.mapper(request, requestBody)); + Optional> responseEntity; + if((request.getMethod().equalsIgnoreCase(HttpMethod.GET.name()))&& + (request.getQueryString() != null)){ + responseEntity = genericApiService + .genericResponseEntityGET(requestMapper.mapper(request, requestBody), request); + }else { + responseEntity = genericApiService + .genericResponseEntity(requestMapper.mapper(request, requestBody)); + } final ResponseEntity result = responseEntity .map(r -> { diff --git a/src/main/java/br/com/concrete/mock/generic/service/GenericApiService.java b/src/main/java/br/com/concrete/mock/generic/service/GenericApiService.java index 6817212..fa712d2 100755 --- a/src/main/java/br/com/concrete/mock/generic/service/GenericApiService.java +++ b/src/main/java/br/com/concrete/mock/generic/service/GenericApiService.java @@ -15,4 +15,6 @@ public interface GenericApiService { Map getHeaders(final HttpServletRequest request); + Optional> genericResponseEntityGET(Request request, HttpServletRequest httpServletRequest); + } diff --git a/src/main/java/br/com/concrete/mock/generic/service/impl/GenericApiServiceImpl.java b/src/main/java/br/com/concrete/mock/generic/service/impl/GenericApiServiceImpl.java index 448bd99..57f2126 100755 --- a/src/main/java/br/com/concrete/mock/generic/service/impl/GenericApiServiceImpl.java +++ b/src/main/java/br/com/concrete/mock/generic/service/impl/GenericApiServiceImpl.java @@ -76,6 +76,38 @@ public Optional> genericResponseEntity(Request request) { }); } + @Override + public Optional> genericResponseEntityGET(Request request, HttpServletRequest httpServletRequest) { + final Endpoint endpointNotSafe = getEndpoint(request).orElse(null); + + final Optional> apiResult; + + // TODO refatorar: esta no if porque estava dando problema ao colocar + // dentro do orElse() + if (endpointNotSafe == null) { + apiResult = externalApi.okHttpClientRequest(httpServletRequest, request).map(r -> { + captureExecutor.execute(r, new Endpoint.Builder(request, r.getApiResult()).build()); + return r.getApiResult(); + }); + } else { + final String body = jsonValueCompiler.compile(endpointNotSafe.getResponse().getBody()); + apiResult = Optional.of( + new ResponseEntity<>(body, endpointNotSafe.getResponse().getHttpStatus().orElse(HttpStatus.OK))); + } + + return apiResult.map(responseEntity -> { + final ResponseEntity.BodyBuilder bodyBuilder = ResponseEntity.status(responseEntity.getStatusCode()); + + apiProperty.getDefaultHeaders().forEach(header -> { + final String headerName = header.getHeaderName(); + final String[] headerValues = header.getHeaderValues().stream().toArray(String[]::new); + bodyBuilder.header(headerName, headerValues); + }); + + return bodyBuilder.body(responseEntity.getBody()); + }); + } + public Map getHeaders(final HttpServletRequest request) { Map map = new HashMap<>(); Enumeration headerNames = request.getHeaderNames(); diff --git a/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java b/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java index 81ecea8..eeb8b0e 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java +++ b/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java @@ -6,18 +6,26 @@ import br.com.concrete.mock.generic.model.Request; import br.com.concrete.mock.infra.model.UriConfiguration; import br.com.concrete.mock.infra.property.ApiProperty; -import java.util.Optional; -import java.util.regex.Pattern; +import okhttp3.Headers; +import okhttp3.OkHttpClient; +import okhttp3.Response; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.util.Enumeration; +import java.util.Optional; +import java.util.regex.Pattern; + @Component public class ExternalApi { @@ -28,15 +36,17 @@ public class ExternalApi { private final RestTemplate restTemplate; private final HeaderFilter headerFilter; private final CaptureStateRepository captureStateRepository; + private final OkHttpClient okHttpClient; @Autowired public ExternalApi(ApiProperty apiProperty, QueryStringBuilder queryStringBuilder, RestTemplate restTemplate, - HeaderFilter headerFilter, CaptureStateRepository captureStateRepository) { + HeaderFilter headerFilter, CaptureStateRepository captureStateRepository, OkHttpClient okHttpClient) { this.apiProperty = apiProperty; this.queryStringBuilder = queryStringBuilder; this.restTemplate = restTemplate; this.headerFilter = headerFilter; this.captureStateRepository = captureStateRepository; + this.okHttpClient = okHttpClient; } public Optional execute(final Request request) { @@ -73,4 +83,40 @@ public Optional execute(final Request request) { return Optional.of(new ExternalApiResult(apiResult, uriConfiguration)); } + public Optional okHttpClientRequest(HttpServletRequest request, Request req){ + + final Boolean state = captureStateRepository + .getCurrent() + .map(CaptureState::isEnabled) + .orElse(true); + + Enumeration headerNames = request.getHeaderNames(); + Headers.Builder builder = new Headers.Builder(); + while (headerNames.hasMoreElements()) { + final String name = headerNames.nextElement(); + builder.add(name, request.getHeader(name)); + } + Headers h = builder.build(); + + final UriConfiguration uriConfiguration = apiProperty + .getConfiguration(req.getUri()) + .orElse(new UriConfiguration(apiProperty.getHost(), Pattern.compile(".*"), state)); + + okhttp3.Request okHttpRequest = new okhttp3.Request.Builder() + .url(uriConfiguration.getHost()+req.getUri()+"?"+request.getQueryString()) + .get() + .headers(h) + .build(); + + ResponseEntity apiResult = null; + try { + Response response = okHttpClient.newCall(okHttpRequest).execute(); + apiResult = new ResponseEntity<>(response.body().string(), new HttpHeaders(), HttpStatus.OK); + } catch (IOException e) { + e.printStackTrace(); + } + + return Optional.of(new ExternalApiResult(apiResult, uriConfiguration)); + } + } From f66617b7fd1d6fde4f2f1eb88e97bf98b3f44fe2 Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Thu, 17 Aug 2017 12:03:02 -0300 Subject: [PATCH 31/54] Fixing FindBugs-IDEA appointed errors. --- .../concrete/mock/generic/model/Endpoint.java | 20 +++++++++++++++++-- .../concrete/mock/generic/model/Request.java | 18 +++++++++++++++++ .../impl/EndpointBackupServiceFile.java | 20 +++++++++++++++++-- .../ApplicationExceptionHandler.java | 5 +---- ...cApiControllerExternalIntegrationTest.java | 4 +++- .../GenericApiControllerIntegrationTest.java | 3 ++- .../model/template/EndpointTemplate.java | 10 ++++++---- 7 files changed, 66 insertions(+), 14 deletions(-) diff --git a/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java b/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java index e206b9e..78a9cda 100755 --- a/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java +++ b/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java @@ -1,6 +1,7 @@ package br.com.concrete.mock.generic.model; import java.util.Map; +import java.util.Objects; import java.util.Optional; import org.springframework.http.ResponseEntity; @@ -44,6 +45,21 @@ public int compareTo(Endpoint o) { return this.request.compareTo(o.request); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Endpoint endpoint = (Endpoint) o; + return Objects.equals(id, endpoint.id) && + Objects.equals(request, endpoint.request) && + Objects.equals(response, endpoint.response); + } + + @Override + public int hashCode() { + return Objects.hash(id, request, response); + } + public static class Builder { private Optional id; @@ -83,12 +99,12 @@ public Builder withRequest(Optional> requestQuery, Optional< return withRequest(new Request.Builder(this.request).withQuery(requestQuery).withBody(requestBody).build()); } - public Builder withRequest(Request request) { + Builder withRequest(Request request) { this.request = request; return this; } - public Builder withEmptyRequest(RequestMethod method, String url) { + Builder withEmptyRequest(RequestMethod method, String url) { return withRequest(new Request.Builder(method, url).build()); } diff --git a/src/main/java/br/com/concrete/mock/generic/model/Request.java b/src/main/java/br/com/concrete/mock/generic/model/Request.java index a4f0a7a..cd2f786 100755 --- a/src/main/java/br/com/concrete/mock/generic/model/Request.java +++ b/src/main/java/br/com/concrete/mock/generic/model/Request.java @@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import java.util.Map; +import java.util.Objects; import java.util.Optional; public class Request implements Comparable { @@ -100,6 +101,23 @@ public int compareTo(Request o) { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Request request = (Request) o; + return method == request.method && + Objects.equals(uri, request.uri) && + Objects.equals(headers, request.headers) && + Objects.equals(query, request.query) && + Objects.equals(body, request.body); + } + + @Override + public int hashCode() { + return Objects.hash(method, uri, headers, query, body); + } + public static class Builder { private final Request instance; diff --git a/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java b/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java index 0d17f55..0ade60e 100755 --- a/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java +++ b/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java @@ -19,7 +19,10 @@ import org.springframework.stereotype.Service; import org.springframework.util.FileSystemUtils; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; @@ -68,14 +71,27 @@ private Boolean execute(final Endpoint endpoint) { final EndpointDto endpointDto = new EndpointDto(endpoint, fromJsonStringToObjectConverter); final String endpointJson = jsonFormatterPretty.format(new Gson().toJson(endpointDto)); + FileOutputStream output = null; + OutputStreamWriter writer = null; try { + output = new FileOutputStream(Paths.get(fileName).toString()); + writer = new OutputStreamWriter(output, StandardCharsets.UTF_8); Files.createDirectories(Paths.get(pathName)); - Files.write(Paths.get(fileName), endpointJson.getBytes()); - + writer.write(endpointJson); LOGGER.info("Backup into " + fileName); } catch (IOException e) { LOGGER.error("Cannot backup endpoint {}", e); + } finally { + try { + if (output != null) + output.close(); + if (writer != null) + writer.close(); + } catch (IOException ex) { + LOGGER.error("Error closing streams {}", ex); + } } + return true; } diff --git a/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionHandler.java b/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionHandler.java index 3cf7b21..c3ac694 100755 --- a/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionHandler.java +++ b/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionHandler.java @@ -25,16 +25,14 @@ public class ApplicationExceptionHandler { @ExceptionHandler(ApplicationExceptionImpl.class) @ResponseBody public ApplicationExceptionMessage handleBadRequest(ApplicationException e) { - final ApplicationExceptionMessage applicationExceptionMessage = e.buildApplicationExceptionMessage(); LOGGER.error("handleBadRequest", e); - return applicationExceptionMessage; + return e.buildApplicationExceptionMessage(); } @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) @ExceptionHandler(ErrorApplicationException.class) @ResponseBody public ApplicationExceptionMessage handleMockError(ErrorApplicationException e) { - final ApplicationExceptionMessage applicationExceptionMessage = e.buildApplicationExceptionMessage(); LOGGER.error("handleMockApiError", e); return e.buildApplicationExceptionMessage(); } @@ -43,7 +41,6 @@ public ApplicationExceptionMessage handleMockError(ErrorApplicationException e) @ExceptionHandler(ApiApplicationException.class) @ResponseBody public ApplicationExceptionMessage handleApiException(ApiApplicationException e) { - final ApplicationExceptionMessage applicationExceptionMessage = e.buildApplicationExceptionMessage(); LOGGER.error("handleApiException", e); return e.buildApplicationExceptionMessage(); } diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java index db544fd..030ffe3 100755 --- a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java +++ b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java @@ -18,6 +18,8 @@ import java.io.File; import java.io.IOException; import java.net.URISyntaxException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Map; @@ -51,7 +53,7 @@ public void shouldFileExistsInTest() { } private String getJson(String fileNameExpected) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileNameExpected))); + return new String(Files.readAllBytes(Paths.get(fileNameExpected)), StandardCharsets.UTF_8); } @Test(timeout = 10000) diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java index 37d8c94..6684b80 100755 --- a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java +++ b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -57,7 +58,7 @@ public void shouldFileExistsInTest() { private String getJson(String fileNameExpected) throws IOException { final Path path = Paths.get(fileNameExpected); - return Files.exists(path) ? new String(Files.readAllBytes(path)) : "{}"; + return Files.exists(path) ? new String(Files.readAllBytes(path), StandardCharsets.UTF_8) : "{}"; } private void shouldResolveGetWithLocalMockMatchQueryCaseX(String uri, String caseX) throws IOException, JSONException { diff --git a/src/test/java/br/com/concrete/mock/generic/model/template/EndpointTemplate.java b/src/test/java/br/com/concrete/mock/generic/model/template/EndpointTemplate.java index eaa62e1..d7a5319 100755 --- a/src/test/java/br/com/concrete/mock/generic/model/template/EndpointTemplate.java +++ b/src/test/java/br/com/concrete/mock/generic/model/template/EndpointTemplate.java @@ -3,25 +3,27 @@ import br.com.concrete.mock.generic.model.Endpoint; import br.com.concrete.mock.generic.model.Request; import br.com.concrete.mock.generic.model.Response; -import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.Rule; import br.com.six2six.fixturefactory.loader.TemplateLoader; +import static br.com.six2six.fixturefactory.Fixture.of; + import java.util.Optional; public class EndpointTemplate implements TemplateLoader { + private static final String VALID_WITHOUT_HTTPSTATUS = "validFull"; + private static final String NOT_VALID = "notValid"; public static final String VALID = "valid"; public static final String VALID_FULL = "validFull"; - public static final String VALID_WITHOUT_HTTPSTATUS = "validFull"; public static final String VALID_WITH_LIST = "validWithList"; public static final String VALID_WITH_REQUEST_QUERY_AGE10 = "validWithRequestQueryAge10"; public static final String VALID_WITH_REQUEST_BODY_ID6 = "validWithRequestBodyId6"; - public static final String NOT_VALID = "notValid"; + @Override public void load() { - Fixture.of(Endpoint.class) + of(Endpoint.class) .addTemplate(VALID, new Rule() {{ add("id", Optional.empty()); add("request", one(Request.class, RequestTemplate.VALID_EMPTY)); From 65c6fb4ad8163a1d25dc23ee451704699a06d3fc Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Thu, 17 Aug 2017 12:23:22 -0300 Subject: [PATCH 32/54] fixing error with filename --- .../mock/generic/service/impl/EndpointBackupServiceFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java b/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java index 0ade60e..47625ef 100755 --- a/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java +++ b/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java @@ -74,7 +74,7 @@ private Boolean execute(final Endpoint endpoint) { FileOutputStream output = null; OutputStreamWriter writer = null; try { - output = new FileOutputStream(Paths.get(fileName).toString()); + output = new FileOutputStream(fileName); writer = new OutputStreamWriter(output, StandardCharsets.UTF_8); Files.createDirectories(Paths.get(pathName)); writer.write(endpointJson); From 74bd0a557f3b0c589ca08feb50d099692dc16148 Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Thu, 17 Aug 2017 12:56:31 -0300 Subject: [PATCH 33/54] Reverting File creation changes --- .../impl/EndpointBackupServiceFile.java | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java b/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java index 47625ef..0d17f55 100755 --- a/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java +++ b/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java @@ -19,10 +19,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.FileSystemUtils; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStreamWriter; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; @@ -71,27 +68,14 @@ private Boolean execute(final Endpoint endpoint) { final EndpointDto endpointDto = new EndpointDto(endpoint, fromJsonStringToObjectConverter); final String endpointJson = jsonFormatterPretty.format(new Gson().toJson(endpointDto)); - FileOutputStream output = null; - OutputStreamWriter writer = null; try { - output = new FileOutputStream(fileName); - writer = new OutputStreamWriter(output, StandardCharsets.UTF_8); Files.createDirectories(Paths.get(pathName)); - writer.write(endpointJson); + Files.write(Paths.get(fileName), endpointJson.getBytes()); + LOGGER.info("Backup into " + fileName); } catch (IOException e) { LOGGER.error("Cannot backup endpoint {}", e); - } finally { - try { - if (output != null) - output.close(); - if (writer != null) - writer.close(); - } catch (IOException ex) { - LOGGER.error("Error closing streams {}", ex); - } } - return true; } From 8146c0890eba096b4c8620e1c6e219149ffca563 Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Thu, 17 Aug 2017 15:54:01 -0300 Subject: [PATCH 34/54] fixing some Codacy issues --- .../java/br/com/concrete/mock/generic/model/Endpoint.java | 4 ++-- .../mock/infra/component/impl/QueryStringBuilderImpl.java | 4 ---- src/test/java/br/com/concrete/mock/ApiApplicationTests.java | 3 --- .../GenericApiControllerExternalIntegrationTest.java | 1 - 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java b/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java index 78a9cda..5837300 100755 --- a/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java +++ b/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java @@ -99,12 +99,12 @@ public Builder withRequest(Optional> requestQuery, Optional< return withRequest(new Request.Builder(this.request).withQuery(requestQuery).withBody(requestBody).build()); } - Builder withRequest(Request request) { + public Builder withRequest(Request request) { this.request = request; return this; } - Builder withEmptyRequest(RequestMethod method, String url) { + public Builder withEmptyRequest(RequestMethod method, String url) { return withRequest(new Request.Builder(method, url).build()); } diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImpl.java b/src/main/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImpl.java index 1e6edc4..c9871e7 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImpl.java +++ b/src/main/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImpl.java @@ -2,8 +2,6 @@ import br.com.concrete.mock.infra.component.ConvertJson; import br.com.concrete.mock.infra.component.QueryStringBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -12,8 +10,6 @@ @Component public class QueryStringBuilderImpl implements QueryStringBuilder { - private static final Logger LOGGER = LoggerFactory.getLogger(QueryStringBuilderImpl.class); - private final ConvertJson convertJson; @Autowired diff --git a/src/test/java/br/com/concrete/mock/ApiApplicationTests.java b/src/test/java/br/com/concrete/mock/ApiApplicationTests.java index c29a56b..ef2d1f0 100755 --- a/src/test/java/br/com/concrete/mock/ApiApplicationTests.java +++ b/src/test/java/br/com/concrete/mock/ApiApplicationTests.java @@ -9,8 +9,5 @@ @SpringBootTest public class ApiApplicationTests { - @Test - public void contextLoads() { - } } diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java index 030ffe3..e66311c 100755 --- a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java +++ b/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java @@ -18,7 +18,6 @@ import java.io.File; import java.io.IOException; import java.net.URISyntaxException; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; From c09b877782369ebc5eeb7c24793b1b6b72693a3c Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Thu, 17 Aug 2017 16:06:02 -0300 Subject: [PATCH 35/54] reverting --- src/test/java/br/com/concrete/mock/ApiApplicationTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/br/com/concrete/mock/ApiApplicationTests.java b/src/test/java/br/com/concrete/mock/ApiApplicationTests.java index ef2d1f0..c29a56b 100755 --- a/src/test/java/br/com/concrete/mock/ApiApplicationTests.java +++ b/src/test/java/br/com/concrete/mock/ApiApplicationTests.java @@ -9,5 +9,8 @@ @SpringBootTest public class ApiApplicationTests { + @Test + public void contextLoads() { + } } From c165cd7c77cf8fe0a364a7bfa5ceef42df405375 Mon Sep 17 00:00:00 2001 From: andreformento Date: Tue, 22 Aug 2017 13:21:54 -0300 Subject: [PATCH 36/54] Implement shutdown controller --- .../infra/controller/ShutdownController.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/br/com/concrete/mock/infra/controller/ShutdownController.java diff --git a/src/main/java/br/com/concrete/mock/infra/controller/ShutdownController.java b/src/main/java/br/com/concrete/mock/infra/controller/ShutdownController.java new file mode 100644 index 0000000..d7ed3f7 --- /dev/null +++ b/src/main/java/br/com/concrete/mock/infra/controller/ShutdownController.java @@ -0,0 +1,21 @@ +package br.com.concrete.mock.infra.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.context.ApplicationContext; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.web.bind.annotation.RequestMethod.POST; + +@RestController +public class ShutdownController { + + @Autowired + private ApplicationContext appContext; + + @RequestMapping(value = "/shutdown", method = POST) + public void initiateShutdown() { + SpringApplication.exit(appContext); + } +} From ad766f2d9a687b324ae66958f606601cf919589d Mon Sep 17 00:00:00 2001 From: Joao Felipe Santoro Pinto Date: Tue, 22 Aug 2017 13:56:10 -0300 Subject: [PATCH 37/54] Adding Coverage history --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 99727d7..51bf898 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ [![codecov.io](https://codecov.io/github/concretesolutions/mock-api/coverage.svg?branch=master)](https://codecov.io/github/concretesolutions/mock-api?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/67cdddf44d87495c84e3bddfdb5de074)](https://www.codacy.com/app/concrete/mock-api?utm_source=github.com&utm_medium=referral&utm_content=concretesolutions/mock-api&utm_campaign=Badge_Grade) +## Coverage History +![codecov.io](https://codecov.io/github/concretesolutions/mock-api/branch.svg?branch=master) + # Mock API App criado para fazer mock com REST utilizando JSON From 9e5e9bbe024c175552bb11b3ef25efccfebac895 Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Thu, 28 Sep 2017 18:08:35 -0300 Subject: [PATCH 38/54] Create docker image for the app --- README.md | 25 +++++++++++++++++++++++-- build.gradle | 16 +++++++++++++++- src/main/docker/Dockerfile | 16 ++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 src/main/docker/Dockerfile diff --git a/README.md b/README.md index 51bf898..b370863 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,32 @@ Crie seu arquivo de propriedade `src/main/resources/application-custom.yml` e ro gradle bootRun -Dspring.profiles.active=custom ``` +## Usando imagem Docker +Para gerar a imagem Docker do projeto, execute: +``` +gradle buildDocker +``` + +Por padrão, o nome da imagem será `concretesolutions/mock-api:VERSAO`. + +Para rodar a aplicação, crie dois diretórios: um contendo o arquivo de configuração `application-custom.yml` e o outro contendo os arquivos de mock. Execute então: + +``` +docker run -d --name mock-api \ + -p 9090:9090 \ + -v /path/para/arquivo/application-custom.yml:/config/application.yml \ + -v /path/para/diretorio/dados/:/data \ + concretesolutions/mock-api:VERSAO +``` + +A porta `9090` expõe o serviço enquanto a porta `5000` é utilizada para debug da aplicação. + +Para visualizar os logs da aplicação a partir do container: `docker logs -f mock-api` + ## TODO -* Adicionar a opção de fazer build com Docker * Separar testes unitários dos testes integrados * Corrigir os testes ignorados * Corrigir Code Style -* Adcionar plugin do FindBugs +* Adicionar plugin do FindBugs * Revisar dependências (ver, por exemplo, se é mesmo necessário ter o GSON ou modelmapper) * Usar objectmapper como component: `compile('com.fasterxml.jackson.datatype:jackson-datatype-jdk8')` diff --git a/build.gradle b/build.gradle index 11cc0cf..79857c5 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,7 @@ buildscript { } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") + classpath('se.transmode.gradle:gradle-docker:1.2') } } @@ -14,6 +15,7 @@ apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' apply plugin: 'jacoco' +apply plugin: 'docker' version = '4.0.0-SNAPSHOT' sourceCompatibility = 1.8 @@ -22,7 +24,6 @@ repositories { mavenCentral() } - dependencies { compile('org.springframework.boot:spring-boot-starter') compile 'org.springframework.boot:spring-boot-starter-undertow' @@ -56,3 +57,16 @@ task codeCoverageReport(type: JacocoReport) { csv.enabled false } } + + +task buildDocker(type: Docker, dependsOn: build) { + push = false + applicationName = 'concretesolutions/' + jar.baseName + dockerfile = file('src/main/docker/Dockerfile') + doFirst { + copy { + from jar + into stageDir + } + } +} \ No newline at end of file diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile new file mode 100644 index 0000000..0c135e8 --- /dev/null +++ b/src/main/docker/Dockerfile @@ -0,0 +1,16 @@ +FROM frolvlad/alpine-oraclejdk8:slim + +VOLUME /config +VOLUME /data + +WORKDIR / + +EXPOSE 5000 +EXPOSE 9090 + +COPY mock-api-*.jar app.jar +ENTRYPOINT ["java", \ + "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5000 -Djava.security.egd=file:/dev/./urandom", \ + "-jar", \ + "/app.jar", \ + "--spring.config.location=file:/config/application.yml"] \ No newline at end of file From 7b6ee3246f0bfdeedaf61a941ebc61160b0aa7c5 Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Thu, 28 Sep 2017 18:17:44 -0300 Subject: [PATCH 39/54] Adiciona maintainer do docker --- src/main/docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile index 0c135e8..b84c47f 100644 --- a/src/main/docker/Dockerfile +++ b/src/main/docker/Dockerfile @@ -1,4 +1,5 @@ FROM frolvlad/alpine-oraclejdk8:slim +MAINTAINER "Concrete " VOLUME /config VOLUME /data From f1a459562a69275f31a98b4c2e118e4d96e714dc Mon Sep 17 00:00:00 2001 From: Luis Fernando de Souza Moro Date: Mon, 2 Oct 2017 09:21:58 -0300 Subject: [PATCH 40/54] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b370863..dd6626b 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ A porta `9090` expõe o serviço enquanto a porta `5000` é utilizada para debug Para visualizar os logs da aplicação a partir do container: `docker logs -f mock-api` ## TODO +* Inseriri exemplo do "arquivo de propriedades" no README * Separar testes unitários dos testes integrados * Corrigir os testes ignorados * Corrigir Code Style From 405d4ccb29ba0115bf62cd503af37bbe184febfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Formento?= Date: Sun, 22 Oct 2017 16:35:42 -0200 Subject: [PATCH 41/54] Change to elementa-source --- .gitignore | 2 ++ README.md | 12 ++++++------ build.gradle | 4 ++-- src/main/docker/Dockerfile | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index f2f2307..432f3a0 100755 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ backup-temp/ mocks-prod fake-api-data out +bin +.vscode diff --git a/README.md b/README.md index dd6626b..bb32582 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -[![Build Status](https://travis-ci.org/concretesolutions/mock-api.svg?branch=master)](https://travis-ci.org/concretesolutions/mock-api) -[![codecov.io](https://codecov.io/github/concretesolutions/mock-api/coverage.svg?branch=master)](https://codecov.io/github/concretesolutions/mock-api?branch=master) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/67cdddf44d87495c84e3bddfdb5de074)](https://www.codacy.com/app/concrete/mock-api?utm_source=github.com&utm_medium=referral&utm_content=concretesolutions/mock-api&utm_campaign=Badge_Grade) +[![Build Status](https://travis-ci.org/elemental-source/mock-api.svg?branch=master)](https://travis-ci.org/elemental-source/mock-api) +[![codecov.io](https://codecov.io/github/elemental-source/mock-api/coverage.svg?branch=master)](https://codecov.io/github/elemental-source/mock-api?branch=master) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/67cdddf44d87495c84e3bddfdb5de074)](https://www.codacy.com/app/elemental-source/mock-api?utm_source=github.com&utm_medium=referral&utm_content=elemental-source/mock-api&utm_campaign=Badge_Grade) ## Coverage History -![codecov.io](https://codecov.io/github/concretesolutions/mock-api/branch.svg?branch=master) +![codecov.io](https://codecov.io/github/elemental-source/mock-api/branch.svg?branch=master) # Mock API @@ -35,7 +35,7 @@ Para gerar a imagem Docker do projeto, execute: gradle buildDocker ``` -Por padrão, o nome da imagem será `concretesolutions/mock-api:VERSAO`. +Por padrão, o nome da imagem será `elemental-source/mock-api:VERSAO`. Para rodar a aplicação, crie dois diretórios: um contendo o arquivo de configuração `application-custom.yml` e o outro contendo os arquivos de mock. Execute então: @@ -44,7 +44,7 @@ docker run -d --name mock-api \ -p 9090:9090 \ -v /path/para/arquivo/application-custom.yml:/config/application.yml \ -v /path/para/diretorio/dados/:/data \ - concretesolutions/mock-api:VERSAO + elemental-source/mock-api:VERSAO ``` A porta `9090` expõe o serviço enquanto a porta `5000` é utilizada para debug da aplicação. diff --git a/build.gradle b/build.gradle index 4143663..0ef226d 100644 --- a/build.gradle +++ b/build.gradle @@ -62,7 +62,7 @@ task codeCoverageReport(type: JacocoReport) { task buildDocker(type: Docker, dependsOn: build) { push = false - applicationName = 'concretesolutions/' + jar.baseName + applicationName = 'elemental-source/' + jar.baseName dockerfile = file('src/main/docker/Dockerfile') doFirst { copy { @@ -70,4 +70,4 @@ task buildDocker(type: Docker, dependsOn: build) { into stageDir } } -} \ No newline at end of file +} diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile index b84c47f..9c4342e 100644 --- a/src/main/docker/Dockerfile +++ b/src/main/docker/Dockerfile @@ -1,5 +1,5 @@ FROM frolvlad/alpine-oraclejdk8:slim -MAINTAINER "Concrete " +MAINTAINER "elemental-source" VOLUME /config VOLUME /data From 81372b0795834dbadd7387fd5dfcf71ab6cb3d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Formento?= Date: Sun, 22 Oct 2017 16:46:10 -0200 Subject: [PATCH 42/54] Update codacy Badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb32582..b92efae 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Build Status](https://travis-ci.org/elemental-source/mock-api.svg?branch=master)](https://travis-ci.org/elemental-source/mock-api) [![codecov.io](https://codecov.io/github/elemental-source/mock-api/coverage.svg?branch=master)](https://codecov.io/github/elemental-source/mock-api?branch=master) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/67cdddf44d87495c84e3bddfdb5de074)](https://www.codacy.com/app/elemental-source/mock-api?utm_source=github.com&utm_medium=referral&utm_content=elemental-source/mock-api&utm_campaign=Badge_Grade) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2be4911c74b14b68a37e78ca4c2c8273)](https://www.codacy.com/app/elemental-source/mock-api?utm_source=github.com&utm_medium=referral&utm_content=elemental-source/mock-api&utm_campaign=Badge_Grade) ## Coverage History ![codecov.io](https://codecov.io/github/elemental-source/mock-api/branch.svg?branch=master) From fe1cf3e5542db4697ff8d79a734eadde09b82416 Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Thu, 26 Oct 2017 22:30:29 -0200 Subject: [PATCH 43/54] Add contributing guide --- CONTRIBUTING.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..e3cc9db --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,38 @@ +# Contributing +:clap::tada: Thank you for taking the time to contribute! :tada::clap: + +We really value your willingness to contribute to this project. In order to higher the chances of your contribution being accepted, please refer to the following guidelines! + +## Steps + +1. Fork it! +2. Create your feature branch: `git checkout -b feature/xyz develop` +3. Commit your changes according to our commit message standards: `git commit -am 'feat(xyz) Added new functionality'` +4. Push to your repo: `git push origin feature/xyz` +5. Submit a pull request to `develop` + +## Workflow +This repo uses Gitflow as its branch management system. You can learn more about Gitflow [here](https://www.atlassian.com/git/tutorials/comparing-workflows#gitflow-workflow). +A few quick tips: +* All feature branches should be based on `develop` and have the format `feature/branch_name`. +* Minor bug fixes should be based on `master` and have the format `hotfix/branch_name`. + +### Commit Conventions +In order to make the changelog generation easier we recommend the use of messages based on [Conventional Commits](https://conventionalcommits.org/). + +Examples: +``` +feat(orders): added `XYZ` helper function + +commit description + +footer notes +``` + +``` +refactor(orders): refactored `ABC` helper function + +The behaviour of `ABC` was inconsistent and (...) + +BREAKING CHANGE: return type of `ABC` is now `String` +``` From dedce79bd751312f8a7b8b46835ab880ee750ae9 Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Thu, 26 Oct 2017 22:40:24 -0200 Subject: [PATCH 44/54] Add findbugs plugin --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index 0ef226d..5c333c0 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' apply plugin: 'jacoco' apply plugin: 'docker' +apply plugin: 'findbugs' version = '4.0.0-SNAPSHOT' sourceCompatibility = 1.8 From 769401c4a46b866bab68c6441a7bd1b7e03f0249 Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Thu, 26 Oct 2017 22:54:15 -0200 Subject: [PATCH 45/54] Add findbugs configuration and fix build --- build.gradle | 9 ++++++++- .../generic/service/impl/EndpointBackupServiceFile.java | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 5c333c0..e476c2b 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,13 @@ apply plugin: 'jacoco' apply plugin: 'docker' apply plugin: 'findbugs' +findbugs { + sourceSets = [sourceSets.main] + ignoreFailures = true + effort = "default" + reportLevel = "high" +} + version = '4.0.0-SNAPSHOT' sourceCompatibility = 1.8 @@ -38,7 +45,6 @@ dependencies { compile 'commons-io:commons-io:2.5' compile 'org.apache.httpcomponents:httpclient:4.4.1' compile 'com.squareup.okhttp3:okhttp:3.8.1' - testCompile 'org.springframework.boot:spring-boot-starter-test' testCompile 'br.com.six2six:fixture-factory:3.1.0' } @@ -72,3 +78,4 @@ task buildDocker(type: Docker, dependsOn: build) { } } } + diff --git a/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java b/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java index 0d17f55..9e490d2 100755 --- a/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java +++ b/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java @@ -12,6 +12,8 @@ import br.com.concrete.mock.infra.property.FileExtensionProperty; import br.com.concrete.mock.infra.property.FileProperty; import com.google.gson.Gson; +import java.nio.charset.Charset; +import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -70,8 +72,7 @@ private Boolean execute(final Endpoint endpoint) { try { Files.createDirectories(Paths.get(pathName)); - Files.write(Paths.get(fileName), endpointJson.getBytes()); - + Files.write(Paths.get(fileName), Arrays.asList(endpointJson), Charset.defaultCharset()); LOGGER.info("Backup into " + fileName); } catch (IOException e) { LOGGER.error("Cannot backup endpoint {}", e); From 36da314d195ffc5c9a18228437542b5a75535ab7 Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Thu, 26 Oct 2017 22:58:15 -0200 Subject: [PATCH 46/54] Remove from TODO --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b92efae..801f67f 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,5 @@ Para visualizar os logs da aplicação a partir do container: `docker logs -f mo * Separar testes unitários dos testes integrados * Corrigir os testes ignorados * Corrigir Code Style -* Adicionar plugin do FindBugs * Revisar dependências (ver, por exemplo, se é mesmo necessário ter o GSON ou modelmapper) * Usar objectmapper como component: `compile('com.fasterxml.jackson.datatype:jackson-datatype-jdk8')` From c0b7c952b8ca787211cc045ea9f9c382e779b43e Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Thu, 26 Oct 2017 23:07:23 -0200 Subject: [PATCH 47/54] Show todo as checklist --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 801f67f..4fbf6cf 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,9 @@ A porta `9090` expõe o serviço enquanto a porta `5000` é utilizada para debug Para visualizar os logs da aplicação a partir do container: `docker logs -f mock-api` ## TODO -* Inseriri exemplo do "arquivo de propriedades" no README -* Separar testes unitários dos testes integrados -* Corrigir os testes ignorados -* Corrigir Code Style -* Revisar dependências (ver, por exemplo, se é mesmo necessário ter o GSON ou modelmapper) -* Usar objectmapper como component: `compile('com.fasterxml.jackson.datatype:jackson-datatype-jdk8')` +- [ ] Inserir exemplo do "arquivo de propriedades" no README +- [ ] Separar testes unitários dos testes integrados +- [ ] Corrigir os testes ignorados +- [ ] Corrigir Code Style +- [ ] Revisar dependências (ver, por exemplo, se é mesmo necessário ter o GSON ou modelmapper) +- [ ] Usar objectmapper como component: `compile('com.fasterxml.jackson.datatype:jackson-datatype-jdk8')` From b1afbcaed8336ff10c38fa9bfaa13df9113f0f0d Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Thu, 26 Oct 2017 23:40:43 -0200 Subject: [PATCH 48/54] Add checkstyle plugin and configuration based on Google style --- build.gradle | 7 + config/checkstyle/checkstyle.xml | 322 +++++++++++++++++++++++++++++++ 2 files changed, 329 insertions(+) create mode 100644 config/checkstyle/checkstyle.xml diff --git a/build.gradle b/build.gradle index e476c2b..04adf14 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ apply plugin: 'org.springframework.boot' apply plugin: 'jacoco' apply plugin: 'docker' apply plugin: 'findbugs' +apply plugin: 'checkstyle' findbugs { sourceSets = [sourceSets.main] @@ -25,6 +26,12 @@ findbugs { reportLevel = "high" } +checkstyle { + toolVersion = '8.3' + sourceSets= [sourceSets.main] + ignoreFailures = true +} + version = '4.0.0-SNAPSHOT' sourceCompatibility = 1.8 diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000..2ea3261 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,322 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From d33d97ea1c4f54f4f8a5615a301b4fb6fb76da7c Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Thu, 26 Oct 2017 23:45:36 -0200 Subject: [PATCH 49/54] Mark todo as done --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fbf6cf..7b56d0b 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,9 @@ A porta `9090` expõe o serviço enquanto a porta `5000` é utilizada para debug Para visualizar os logs da aplicação a partir do container: `docker logs -f mock-api` ## TODO +- [X] Corrigir Code Style - [ ] Inserir exemplo do "arquivo de propriedades" no README - [ ] Separar testes unitários dos testes integrados - [ ] Corrigir os testes ignorados -- [ ] Corrigir Code Style - [ ] Revisar dependências (ver, por exemplo, se é mesmo necessário ter o GSON ou modelmapper) - [ ] Usar objectmapper como component: `compile('com.fasterxml.jackson.datatype:jackson-datatype-jdk8')` From 473d2146768c991cff908048fb2812424ccc4980 Mon Sep 17 00:00:00 2001 From: Luis Moro Date: Fri, 27 Oct 2017 11:33:48 -0200 Subject: [PATCH 50/54] Altera o package name para condizer com a finalidade do projeto --- .../service/CaptureExecutor.java | 11 --- .../repository/impl/EndpointFileFilter.java | 10 --- .../mock/ApiApplication.java | 2 +- .../v1/controller/CaptureStateController.java | 6 +- .../api/v1/mapper/CaptureStateDto.java | 4 +- .../configuration/model/CaptureState.java | 2 +- .../repository/CaptureStateRepository.java | 4 +- .../impl/CaptureStateRepositoryImpl.java | 6 +- .../service/CaptureExecutor.java | 11 +++ .../service/CaptureStateService.java | 4 +- .../service/impl/CaptureExecutorImpl.java | 10 +-- .../service/impl/CaptureStateServiceImpl.java | 10 +-- .../v1/controller/GenericApiController.java | 10 +-- .../generic/api/v1/mapper/RequestMapper.java | 8 +-- .../mock/generic/mapper/EndpointDto.java | 12 ++-- .../mock/generic/mapper/EndpointMapper.java | 6 +- .../mock/generic/mapper/HeaderMapper.java | 2 +- .../mock/generic/mapper/QueryMapper.java | 4 +- .../mock/generic/mapper/RequestDto.java | 6 +- .../mock/generic/mapper/ResponseDto.java | 8 +-- .../mock/generic/model/Endpoint.java | 2 +- .../mock/generic/model/Error.java | 2 +- .../mock/generic/model/ExternalApiResult.java | 5 +- .../mock/generic/model/Request.java | 8 +-- .../mock/generic/model/Response.java | 2 +- .../repository/EndpointRepository.java | 6 +- .../repository/impl/EndpointFileFilter.java | 10 +++ .../impl/EndpointFileFilterBody.java | 6 +- .../impl/EndpointFileFilterQuery.java | 6 +- .../impl/EndpointFileFilterRequest.java | 6 +- .../impl/EndpointRepositoryBackup.java | 10 +-- .../impl/EndpointRepositoryBase.java | 14 ++-- .../impl/EndpointRepositoryModel.java | 10 +-- .../service/EndpointBackupService.java | 4 +- .../generic/service/GenericApiService.java | 5 +- .../impl/EndpointBackupServiceFile.java | 24 +++---- .../service/impl/GenericApiServiceImpl.java | 20 +++--- .../mock/infra/component/CompareJson.java | 2 +- .../mock/infra/component/CompareMap.java | 2 +- .../mock/infra/component/ConvertJson.java | 2 +- .../mock/infra/component/ExternalApi.java | 16 ++--- .../FromJsonStringToObjectConverter.java | 2 +- .../mock/infra/component/HeaderFilter.java | 4 +- .../mock/infra/component/JsonFormatter.java | 2 +- .../infra/component/JsonValueCompiler.java | 2 +- .../infra/component/QueryStringBuilder.java | 2 +- .../infra/component/RequestFormatter.java | 2 +- .../component/file/BaseFileNameBuilder.java | 2 +- .../file/BaseFileNameBuilderBackup.java | 4 +- .../file/BaseFileNameBuilderBase.java | 4 +- .../file/BaseFileNameBuilderModel.java | 4 +- .../infra/component/file/FileJsonReader.java | 2 +- .../component/file/FileNameGenerator.java | 2 +- .../component/file/FileNameGeneratorImpl.java | 4 +- .../infra/component/impl/ConvertJsonImpl.java | 6 +- .../FromJsonStringToObjectConverterImpl.java | 4 +- .../component/impl/JsonFormatterPretty.java | 4 +- .../component/impl/JsonValueCompilerImpl.java | 4 +- .../impl/QueryStringBuilderImpl.java | 6 +- .../component/impl/RequestFormatterImpl.java | 4 +- .../infra/controller/ShutdownController.java | 2 +- .../infra/exception/ApplicationException.java | 2 +- .../ApplicationExceptionHandler.java | 10 +-- .../ApplicationExceptionMessage.java | 2 +- .../impl/ApiApplicationException.java | 4 +- .../impl/ApplicationExceptionImpl.java | 6 +- .../impl/ApplicationExceptionMessageImpl.java | 4 +- .../impl/ErrorApplicationException.java | 4 +- .../impl/JsonApiApplicationException.java | 4 +- .../mock/infra/model/DefaultHeader.java | 2 +- .../mock/infra/model/UriConfiguration.java | 2 +- .../mock/infra/property/ApiProperty.java | 6 +- .../infra/property/FileExtensionProperty.java | 2 +- .../mock/infra/property/FileProperty.java | 2 +- .../impl/FileExtensionPropertyImpl.java | 4 +- .../property/impl/FilePropertyBackup.java | 4 +- .../property/impl/FilePropertyModel.java | 4 +- src/main/resources/application.yml | 68 ++++++++++--------- .../mock/ApiApplicationTests.java | 2 +- ...CaptureStateControllerIntegrationTest.java | 8 +-- ...cApiControllerExternalIntegrationTest.java | 4 +- .../GenericApiControllerIntegrationTest.java | 9 ++- .../api/v1/mapper/RequestMapperTest.java | 8 +-- .../mock/generic/mapper/EndpointDtoTest.java | 8 +-- .../generic/mapper/EndpointMapperTest.java | 6 +- .../mock/generic/mapper/HeaderMapperTest.java | 2 +- .../mock/generic/mapper/QueryMapperTest.java | 2 +- .../mock/generic/mapper/ResponseDtoTest.java | 8 +-- .../mock/generic/model/RequestTest.java | 4 +- .../model/template/EndpointTemplate.java | 8 +-- .../model/template/RequestTemplate.java | 4 +- .../model/template/ResponseTemplate.java | 4 +- .../impl/EndpointFileFilterBodyTest.java | 10 +-- .../impl/EndpointFileFilterQueryTest.java | 10 +-- .../impl/EndpointRepositoryModelTest.java | 18 ++--- ...pointBackupServiceFileIntegrarionTest.java | 12 ++-- .../impl/EndpointBackupServiceFileTest.java | 24 +++---- .../mock/infra/component/ApiPropertyTest.java | 8 +-- .../mock/infra/component/CompareJsonTest.java | 4 +- .../mock/infra/component/CompareMapTest.java | 2 +- .../mock/infra/component/ExternalApiTest.java | 10 +-- .../file/BaseFileNameBuilderModelTest.java | 4 +- .../component/file/FileJsonReaderTest.java | 2 +- .../file/FileNameGeneratorImplTest.java | 4 +- .../component/impl/ConvertJsonImplTest.java | 2 +- ...omJsonStringToObjectConverterImplTest.java | 2 +- .../impl/JsonFormatterPrettyTest.java | 2 +- .../impl/JsonValueCompilerImplTest.java | 2 +- .../impl/QueryStringBuilderImplTest.java | 4 +- 109 files changed, 347 insertions(+), 344 deletions(-) delete mode 100755 src/main/java/br/com/concrete/mock/configuration/service/CaptureExecutor.java delete mode 100755 src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilter.java rename src/main/java/br/com/{concrete => elementasource}/mock/ApiApplication.java (96%) rename src/main/java/br/com/{concrete => elementasource}/mock/configuration/api/v1/controller/CaptureStateController.java (88%) rename src/main/java/br/com/{concrete => elementasource}/mock/configuration/api/v1/mapper/CaptureStateDto.java (85%) rename src/main/java/br/com/{concrete => elementasource}/mock/configuration/model/CaptureState.java (79%) rename src/main/java/br/com/{concrete => elementasource}/mock/configuration/repository/CaptureStateRepository.java (59%) rename src/main/java/br/com/{concrete => elementasource}/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java (81%) create mode 100755 src/main/java/br/com/elementasource/mock/configuration/service/CaptureExecutor.java rename src/main/java/br/com/{concrete => elementasource}/mock/configuration/service/CaptureStateService.java (56%) rename src/main/java/br/com/{concrete => elementasource}/mock/configuration/service/impl/CaptureExecutorImpl.java (63%) rename src/main/java/br/com/{concrete => elementasource}/mock/configuration/service/impl/CaptureStateServiceImpl.java (75%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/api/v1/controller/GenericApiController.java (91%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/api/v1/mapper/RequestMapper.java (86%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/mapper/EndpointDto.java (81%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/mapper/EndpointMapper.java (87%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/mapper/HeaderMapper.java (93%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/mapper/QueryMapper.java (92%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/mapper/RequestDto.java (89%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/mapper/ResponseDto.java (84%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/model/Endpoint.java (98%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/model/Error.java (89%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/model/ExternalApiResult.java (81%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/model/Request.java (94%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/model/Response.java (90%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/repository/EndpointRepository.java (65%) create mode 100755 src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilter.java rename src/main/java/br/com/{concrete => elementasource}/mock/generic/repository/impl/EndpointFileFilterBody.java (83%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/repository/impl/EndpointFileFilterQuery.java (84%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/repository/impl/EndpointFileFilterRequest.java (83%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/repository/impl/EndpointRepositoryBackup.java (68%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/repository/impl/EndpointRepositoryBase.java (87%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/repository/impl/EndpointRepositoryModel.java (68%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/service/EndpointBackupService.java (54%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/service/GenericApiService.java (80%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/service/impl/EndpointBackupServiceFile.java (82%) rename src/main/java/br/com/{concrete => elementasource}/mock/generic/service/impl/GenericApiServiceImpl.java (89%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/CompareJson.java (95%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/CompareMap.java (92%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/ConvertJson.java (72%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/ExternalApi.java (91%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/FromJsonStringToObjectConverter.java (78%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/HeaderFilter.java (93%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/JsonFormatter.java (61%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/JsonValueCompiler.java (66%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/QueryStringBuilder.java (68%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/RequestFormatter.java (80%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/file/BaseFileNameBuilder.java (81%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/file/BaseFileNameBuilderBackup.java (79%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/file/BaseFileNameBuilderBase.java (86%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/file/BaseFileNameBuilderModel.java (79%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/file/FileJsonReader.java (94%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/file/FileNameGenerator.java (58%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/file/FileNameGeneratorImpl.java (91%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/impl/ConvertJsonImpl.java (79%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java (84%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/impl/JsonFormatterPretty.java (82%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/impl/JsonValueCompilerImpl.java (88%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/impl/QueryStringBuilderImpl.java (80%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/component/impl/RequestFormatterImpl.java (82%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/controller/ShutdownController.java (92%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/exception/ApplicationException.java (68%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/exception/ApplicationExceptionHandler.java (87%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/exception/ApplicationExceptionMessage.java (66%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/exception/impl/ApiApplicationException.java (72%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/exception/impl/ApplicationExceptionImpl.java (67%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java (78%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/exception/impl/ErrorApplicationException.java (63%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/exception/impl/JsonApiApplicationException.java (73%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/model/DefaultHeader.java (96%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/model/UriConfiguration.java (97%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/property/ApiProperty.java (91%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/property/FileExtensionProperty.java (60%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/property/FileProperty.java (55%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/property/impl/FileExtensionPropertyImpl.java (78%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/property/impl/FilePropertyBackup.java (78%) rename src/main/java/br/com/{concrete => elementasource}/mock/infra/property/impl/FilePropertyModel.java (77%) rename src/test/java/br/com/{concrete => elementasource}/mock/ApiApplicationTests.java (89%) rename src/test/java/br/com/{concrete => elementasource}/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java (91%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java (96%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java (97%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/api/v1/mapper/RequestMapperTest.java (95%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/mapper/EndpointDtoTest.java (95%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/mapper/EndpointMapperTest.java (91%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/mapper/HeaderMapperTest.java (95%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/mapper/QueryMapperTest.java (97%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/mapper/ResponseDtoTest.java (90%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/model/RequestTest.java (93%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/model/template/EndpointTemplate.java (91%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/model/template/RequestTemplate.java (96%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/model/template/ResponseTemplate.java (92%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/repository/impl/EndpointFileFilterBodyTest.java (87%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/repository/impl/EndpointFileFilterQueryTest.java (87%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/repository/impl/EndpointRepositoryModelTest.java (89%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java (91%) rename src/test/java/br/com/{concrete => elementasource}/mock/generic/service/impl/EndpointBackupServiceFileTest.java (84%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/ApiPropertyTest.java (89%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/CompareJsonTest.java (95%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/CompareMapTest.java (98%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/ExternalApiTest.java (90%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/file/BaseFileNameBuilderModelTest.java (93%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/file/FileJsonReaderTest.java (97%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/file/FileNameGeneratorImplTest.java (95%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/impl/ConvertJsonImplTest.java (92%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java (96%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/impl/JsonFormatterPrettyTest.java (95%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/impl/JsonValueCompilerImplTest.java (98%) rename src/test/java/br/com/{concrete => elementasource}/mock/infra/component/impl/QueryStringBuilderImplTest.java (93%) diff --git a/src/main/java/br/com/concrete/mock/configuration/service/CaptureExecutor.java b/src/main/java/br/com/concrete/mock/configuration/service/CaptureExecutor.java deleted file mode 100755 index cb2a9f3..0000000 --- a/src/main/java/br/com/concrete/mock/configuration/service/CaptureExecutor.java +++ /dev/null @@ -1,11 +0,0 @@ -package br.com.concrete.mock.configuration.service; - -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.ExternalApiResult; - -@FunctionalInterface -public interface CaptureExecutor { - - void execute(ExternalApiResult apiResult, Endpoint endpoint); - -} diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilter.java b/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilter.java deleted file mode 100755 index d29282b..0000000 --- a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilter.java +++ /dev/null @@ -1,10 +0,0 @@ -package br.com.concrete.mock.generic.repository.impl; - -import br.com.concrete.mock.generic.model.Endpoint; - -@FunctionalInterface -interface EndpointFileFilter { - - Boolean apply(Endpoint endpoint, T request); - -} diff --git a/src/main/java/br/com/concrete/mock/ApiApplication.java b/src/main/java/br/com/elementasource/mock/ApiApplication.java similarity index 96% rename from src/main/java/br/com/concrete/mock/ApiApplication.java rename to src/main/java/br/com/elementasource/mock/ApiApplication.java index 2ce12db..9274e0f 100755 --- a/src/main/java/br/com/concrete/mock/ApiApplication.java +++ b/src/main/java/br/com/elementasource/mock/ApiApplication.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock; +package br.com.elementasource.mock; import okhttp3.OkHttpClient; import org.apache.http.client.HttpClient; diff --git a/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java b/src/main/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateController.java similarity index 88% rename from src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java rename to src/main/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateController.java index 04d0838..f290dd9 100755 --- a/src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java +++ b/src/main/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateController.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.configuration.api.v1.controller; +package br.com.elementasource.mock.configuration.api.v1.controller; -import br.com.concrete.mock.configuration.api.v1.mapper.CaptureStateDto; -import br.com.concrete.mock.configuration.service.CaptureStateService; +import br.com.elementasource.mock.configuration.api.v1.mapper.CaptureStateDto; +import br.com.elementasource.mock.configuration.service.CaptureStateService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/br/com/concrete/mock/configuration/api/v1/mapper/CaptureStateDto.java b/src/main/java/br/com/elementasource/mock/configuration/api/v1/mapper/CaptureStateDto.java similarity index 85% rename from src/main/java/br/com/concrete/mock/configuration/api/v1/mapper/CaptureStateDto.java rename to src/main/java/br/com/elementasource/mock/configuration/api/v1/mapper/CaptureStateDto.java index bcd7778..8dd014c 100755 --- a/src/main/java/br/com/concrete/mock/configuration/api/v1/mapper/CaptureStateDto.java +++ b/src/main/java/br/com/elementasource/mock/configuration/api/v1/mapper/CaptureStateDto.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.configuration.api.v1.mapper; +package br.com.elementasource.mock.configuration.api.v1.mapper; -import br.com.concrete.mock.configuration.model.CaptureState; +import br.com.elementasource.mock.configuration.model.CaptureState; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/br/com/concrete/mock/configuration/model/CaptureState.java b/src/main/java/br/com/elementasource/mock/configuration/model/CaptureState.java similarity index 79% rename from src/main/java/br/com/concrete/mock/configuration/model/CaptureState.java rename to src/main/java/br/com/elementasource/mock/configuration/model/CaptureState.java index 3344213..f96e1cd 100755 --- a/src/main/java/br/com/concrete/mock/configuration/model/CaptureState.java +++ b/src/main/java/br/com/elementasource/mock/configuration/model/CaptureState.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.configuration.model; +package br.com.elementasource.mock.configuration.model; public class CaptureState { diff --git a/src/main/java/br/com/concrete/mock/configuration/repository/CaptureStateRepository.java b/src/main/java/br/com/elementasource/mock/configuration/repository/CaptureStateRepository.java similarity index 59% rename from src/main/java/br/com/concrete/mock/configuration/repository/CaptureStateRepository.java rename to src/main/java/br/com/elementasource/mock/configuration/repository/CaptureStateRepository.java index a01dac1..a29826c 100755 --- a/src/main/java/br/com/concrete/mock/configuration/repository/CaptureStateRepository.java +++ b/src/main/java/br/com/elementasource/mock/configuration/repository/CaptureStateRepository.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.configuration.repository; +package br.com.elementasource.mock.configuration.repository; -import br.com.concrete.mock.configuration.model.CaptureState; +import br.com.elementasource.mock.configuration.model.CaptureState; import java.util.Optional; diff --git a/src/main/java/br/com/concrete/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java b/src/main/java/br/com/elementasource/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java similarity index 81% rename from src/main/java/br/com/concrete/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java rename to src/main/java/br/com/elementasource/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java index 62634d6..1e9cb3f 100755 --- a/src/main/java/br/com/concrete/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java +++ b/src/main/java/br/com/elementasource/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.configuration.repository.impl; +package br.com.elementasource.mock.configuration.repository.impl; -import br.com.concrete.mock.configuration.model.CaptureState; -import br.com.concrete.mock.configuration.repository.CaptureStateRepository; +import br.com.elementasource.mock.configuration.model.CaptureState; +import br.com.elementasource.mock.configuration.repository.CaptureStateRepository; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; diff --git a/src/main/java/br/com/elementasource/mock/configuration/service/CaptureExecutor.java b/src/main/java/br/com/elementasource/mock/configuration/service/CaptureExecutor.java new file mode 100755 index 0000000..dbfc427 --- /dev/null +++ b/src/main/java/br/com/elementasource/mock/configuration/service/CaptureExecutor.java @@ -0,0 +1,11 @@ +package br.com.elementasource.mock.configuration.service; + +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.ExternalApiResult; + +@FunctionalInterface +public interface CaptureExecutor { + + void execute(ExternalApiResult apiResult, Endpoint endpoint); + +} diff --git a/src/main/java/br/com/concrete/mock/configuration/service/CaptureStateService.java b/src/main/java/br/com/elementasource/mock/configuration/service/CaptureStateService.java similarity index 56% rename from src/main/java/br/com/concrete/mock/configuration/service/CaptureStateService.java rename to src/main/java/br/com/elementasource/mock/configuration/service/CaptureStateService.java index b908a48..ccd615b 100755 --- a/src/main/java/br/com/concrete/mock/configuration/service/CaptureStateService.java +++ b/src/main/java/br/com/elementasource/mock/configuration/service/CaptureStateService.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.configuration.service; +package br.com.elementasource.mock.configuration.service; -import br.com.concrete.mock.configuration.model.CaptureState; +import br.com.elementasource.mock.configuration.model.CaptureState; import java.util.Optional; diff --git a/src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureExecutorImpl.java b/src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureExecutorImpl.java similarity index 63% rename from src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureExecutorImpl.java rename to src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureExecutorImpl.java index 7851524..16935c3 100755 --- a/src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureExecutorImpl.java +++ b/src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureExecutorImpl.java @@ -1,12 +1,12 @@ -package br.com.concrete.mock.configuration.service.impl; +package br.com.elementasource.mock.configuration.service.impl; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.ExternalApiResult; +import br.com.elementasource.mock.generic.service.EndpointBackupService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import br.com.concrete.mock.configuration.service.CaptureExecutor; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.ExternalApiResult; -import br.com.concrete.mock.generic.service.EndpointBackupService; +import br.com.elementasource.mock.configuration.service.CaptureExecutor; @Service public class CaptureExecutorImpl implements CaptureExecutor { diff --git a/src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureStateServiceImpl.java b/src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureStateServiceImpl.java similarity index 75% rename from src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureStateServiceImpl.java rename to src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureStateServiceImpl.java index d4f2e77..0ef1cad 100755 --- a/src/main/java/br/com/concrete/mock/configuration/service/impl/CaptureStateServiceImpl.java +++ b/src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureStateServiceImpl.java @@ -1,9 +1,9 @@ -package br.com.concrete.mock.configuration.service.impl; +package br.com.elementasource.mock.configuration.service.impl; -import br.com.concrete.mock.configuration.model.CaptureState; -import br.com.concrete.mock.configuration.repository.CaptureStateRepository; -import br.com.concrete.mock.configuration.service.CaptureStateService; -import br.com.concrete.mock.infra.exception.impl.ApiApplicationException; +import br.com.elementasource.mock.configuration.model.CaptureState; +import br.com.elementasource.mock.configuration.repository.CaptureStateRepository; +import br.com.elementasource.mock.configuration.service.CaptureStateService; +import br.com.elementasource.mock.infra.exception.impl.ApiApplicationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiController.java b/src/main/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiController.java similarity index 91% rename from src/main/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiController.java rename to src/main/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiController.java index a632a2c..f7401ba 100755 --- a/src/main/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiController.java +++ b/src/main/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiController.java @@ -1,9 +1,9 @@ -package br.com.concrete.mock.generic.api.v1.controller; +package br.com.elementasource.mock.generic.api.v1.controller; -import br.com.concrete.mock.generic.api.v1.mapper.RequestMapper; -import br.com.concrete.mock.generic.service.GenericApiService; -import br.com.concrete.mock.infra.component.JsonFormatter; -import br.com.concrete.mock.infra.component.RequestFormatter; +import br.com.elementasource.mock.generic.api.v1.mapper.RequestMapper; +import br.com.elementasource.mock.generic.service.GenericApiService; +import br.com.elementasource.mock.infra.component.JsonFormatter; +import br.com.elementasource.mock.infra.component.RequestFormatter; import com.google.gson.Gson; import com.google.gson.JsonParseException; import org.slf4j.Logger; diff --git a/src/main/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapper.java b/src/main/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapper.java similarity index 86% rename from src/main/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapper.java rename to src/main/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapper.java index bf36d99..158cfa7 100755 --- a/src/main/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapper.java +++ b/src/main/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapper.java @@ -1,8 +1,8 @@ -package br.com.concrete.mock.generic.api.v1.mapper; +package br.com.elementasource.mock.generic.api.v1.mapper; -import br.com.concrete.mock.generic.mapper.HeaderMapper; -import br.com.concrete.mock.generic.mapper.QueryMapper; -import br.com.concrete.mock.generic.model.Request; +import br.com.elementasource.mock.generic.mapper.HeaderMapper; +import br.com.elementasource.mock.generic.mapper.QueryMapper; +import br.com.elementasource.mock.generic.model.Request; import com.google.gson.Gson; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/EndpointDto.java b/src/main/java/br/com/elementasource/mock/generic/mapper/EndpointDto.java similarity index 81% rename from src/main/java/br/com/concrete/mock/generic/mapper/EndpointDto.java rename to src/main/java/br/com/elementasource/mock/generic/mapper/EndpointDto.java index ad45ce0..b2df748 100755 --- a/src/main/java/br/com/concrete/mock/generic/mapper/EndpointDto.java +++ b/src/main/java/br/com/elementasource/mock/generic/mapper/EndpointDto.java @@ -1,10 +1,10 @@ -package br.com.concrete.mock.generic.mapper; +package br.com.elementasource.mock.generic.mapper; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.generic.model.Response; -import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; -import br.com.concrete.mock.infra.exception.impl.ApiApplicationException; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.generic.model.Response; +import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementasource.mock.infra.exception.impl.ApiApplicationException; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/EndpointMapper.java b/src/main/java/br/com/elementasource/mock/generic/mapper/EndpointMapper.java similarity index 87% rename from src/main/java/br/com/concrete/mock/generic/mapper/EndpointMapper.java rename to src/main/java/br/com/elementasource/mock/generic/mapper/EndpointMapper.java index acafc1e..0b5943e 100755 --- a/src/main/java/br/com/concrete/mock/generic/mapper/EndpointMapper.java +++ b/src/main/java/br/com/elementasource/mock/generic/mapper/EndpointMapper.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.generic.mapper; +package br.com.elementasource.mock.generic.mapper; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.infra.component.file.FileJsonReader; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.infra.component.file.FileJsonReader; import com.google.gson.Gson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/HeaderMapper.java b/src/main/java/br/com/elementasource/mock/generic/mapper/HeaderMapper.java similarity index 93% rename from src/main/java/br/com/concrete/mock/generic/mapper/HeaderMapper.java rename to src/main/java/br/com/elementasource/mock/generic/mapper/HeaderMapper.java index a12bbef..7894c66 100755 --- a/src/main/java/br/com/concrete/mock/generic/mapper/HeaderMapper.java +++ b/src/main/java/br/com/elementasource/mock/generic/mapper/HeaderMapper.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.generic.mapper; +package br.com.elementasource.mock.generic.mapper; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/QueryMapper.java b/src/main/java/br/com/elementasource/mock/generic/mapper/QueryMapper.java similarity index 92% rename from src/main/java/br/com/concrete/mock/generic/mapper/QueryMapper.java rename to src/main/java/br/com/elementasource/mock/generic/mapper/QueryMapper.java index 1f858ff..b374821 100755 --- a/src/main/java/br/com/concrete/mock/generic/mapper/QueryMapper.java +++ b/src/main/java/br/com/elementasource/mock/generic/mapper/QueryMapper.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.generic.mapper; +package br.com.elementasource.mock.generic.mapper; -import br.com.concrete.mock.infra.exception.impl.ApiApplicationException; +import br.com.elementasource.mock.infra.exception.impl.ApiApplicationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/RequestDto.java b/src/main/java/br/com/elementasource/mock/generic/mapper/RequestDto.java similarity index 89% rename from src/main/java/br/com/concrete/mock/generic/mapper/RequestDto.java rename to src/main/java/br/com/elementasource/mock/generic/mapper/RequestDto.java index 0ea573c..a517990 100755 --- a/src/main/java/br/com/concrete/mock/generic/mapper/RequestDto.java +++ b/src/main/java/br/com/elementasource/mock/generic/mapper/RequestDto.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.generic.mapper; +package br.com.elementasource.mock.generic.mapper; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.Gson; diff --git a/src/main/java/br/com/concrete/mock/generic/mapper/ResponseDto.java b/src/main/java/br/com/elementasource/mock/generic/mapper/ResponseDto.java similarity index 84% rename from src/main/java/br/com/concrete/mock/generic/mapper/ResponseDto.java rename to src/main/java/br/com/elementasource/mock/generic/mapper/ResponseDto.java index ac01196..636020a 100755 --- a/src/main/java/br/com/concrete/mock/generic/mapper/ResponseDto.java +++ b/src/main/java/br/com/elementasource/mock/generic/mapper/ResponseDto.java @@ -1,8 +1,8 @@ -package br.com.concrete.mock.generic.mapper; +package br.com.elementasource.mock.generic.mapper; -import br.com.concrete.mock.generic.model.Response; -import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; -import br.com.concrete.mock.infra.exception.impl.ApiApplicationException; +import br.com.elementasource.mock.generic.model.Response; +import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementasource.mock.infra.exception.impl.ApiApplicationException; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.Gson; diff --git a/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java b/src/main/java/br/com/elementasource/mock/generic/model/Endpoint.java similarity index 98% rename from src/main/java/br/com/concrete/mock/generic/model/Endpoint.java rename to src/main/java/br/com/elementasource/mock/generic/model/Endpoint.java index 5837300..d821494 100755 --- a/src/main/java/br/com/concrete/mock/generic/model/Endpoint.java +++ b/src/main/java/br/com/elementasource/mock/generic/model/Endpoint.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.generic.model; +package br.com.elementasource.mock.generic.model; import java.util.Map; import java.util.Objects; diff --git a/src/main/java/br/com/concrete/mock/generic/model/Error.java b/src/main/java/br/com/elementasource/mock/generic/model/Error.java similarity index 89% rename from src/main/java/br/com/concrete/mock/generic/model/Error.java rename to src/main/java/br/com/elementasource/mock/generic/model/Error.java index ba4cff4..e5afa1e 100755 --- a/src/main/java/br/com/concrete/mock/generic/model/Error.java +++ b/src/main/java/br/com/elementasource/mock/generic/model/Error.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.generic.model; +package br.com.elementasource.mock.generic.model; import java.io.Serializable; diff --git a/src/main/java/br/com/concrete/mock/generic/model/ExternalApiResult.java b/src/main/java/br/com/elementasource/mock/generic/model/ExternalApiResult.java similarity index 81% rename from src/main/java/br/com/concrete/mock/generic/model/ExternalApiResult.java rename to src/main/java/br/com/elementasource/mock/generic/model/ExternalApiResult.java index 3c51e58..5488cf1 100644 --- a/src/main/java/br/com/concrete/mock/generic/model/ExternalApiResult.java +++ b/src/main/java/br/com/elementasource/mock/generic/model/ExternalApiResult.java @@ -1,9 +1,8 @@ -package br.com.concrete.mock.generic.model; +package br.com.elementasource.mock.generic.model; +import br.com.elementasource.mock.infra.model.UriConfiguration; import org.springframework.http.ResponseEntity; -import br.com.concrete.mock.infra.model.UriConfiguration; - public class ExternalApiResult { private final ResponseEntity apiResult; diff --git a/src/main/java/br/com/concrete/mock/generic/model/Request.java b/src/main/java/br/com/elementasource/mock/generic/model/Request.java similarity index 94% rename from src/main/java/br/com/concrete/mock/generic/model/Request.java rename to src/main/java/br/com/elementasource/mock/generic/model/Request.java index cd2f786..238a125 100755 --- a/src/main/java/br/com/concrete/mock/generic/model/Request.java +++ b/src/main/java/br/com/elementasource/mock/generic/model/Request.java @@ -1,8 +1,8 @@ -package br.com.concrete.mock.generic.model; +package br.com.elementasource.mock.generic.model; -import br.com.concrete.mock.infra.component.ConvertJson; -import br.com.concrete.mock.infra.component.impl.ConvertJsonImpl; -import br.com.concrete.mock.infra.exception.impl.JsonApiApplicationException; +import br.com.elementasource.mock.infra.component.ConvertJson; +import br.com.elementasource.mock.infra.component.impl.ConvertJsonImpl; +import br.com.elementasource.mock.infra.exception.impl.JsonApiApplicationException; import org.springframework.http.HttpHeaders; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/src/main/java/br/com/concrete/mock/generic/model/Response.java b/src/main/java/br/com/elementasource/mock/generic/model/Response.java similarity index 90% rename from src/main/java/br/com/concrete/mock/generic/model/Response.java rename to src/main/java/br/com/elementasource/mock/generic/model/Response.java index dc9acf6..cb3fb0f 100755 --- a/src/main/java/br/com/concrete/mock/generic/model/Response.java +++ b/src/main/java/br/com/elementasource/mock/generic/model/Response.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.generic.model; +package br.com.elementasource.mock.generic.model; import org.springframework.http.HttpStatus; diff --git a/src/main/java/br/com/concrete/mock/generic/repository/EndpointRepository.java b/src/main/java/br/com/elementasource/mock/generic/repository/EndpointRepository.java similarity index 65% rename from src/main/java/br/com/concrete/mock/generic/repository/EndpointRepository.java rename to src/main/java/br/com/elementasource/mock/generic/repository/EndpointRepository.java index cf510a0..ca05792 100755 --- a/src/main/java/br/com/concrete/mock/generic/repository/EndpointRepository.java +++ b/src/main/java/br/com/elementasource/mock/generic/repository/EndpointRepository.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.generic.repository; +package br.com.elementasource.mock.generic.repository; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.Request; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Request; import org.springframework.web.bind.annotation.RequestMethod; import java.util.Collection; diff --git a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilter.java b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilter.java new file mode 100755 index 0000000..3ae0e9a --- /dev/null +++ b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilter.java @@ -0,0 +1,10 @@ +package br.com.elementasource.mock.generic.repository.impl; + +import br.com.elementasource.mock.generic.model.Endpoint; + +@FunctionalInterface +interface EndpointFileFilter { + + Boolean apply(Endpoint endpoint, T request); + +} diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBody.java b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBody.java similarity index 83% rename from src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBody.java rename to src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBody.java index c1944c0..fc80f66 100755 --- a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBody.java +++ b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBody.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.generic.repository.impl; +package br.com.elementasource.mock.generic.repository.impl; -import br.com.concrete.mock.infra.component.CompareJson; -import br.com.concrete.mock.generic.model.Endpoint; +import br.com.elementasource.mock.infra.component.CompareJson; +import br.com.elementasource.mock.generic.model.Endpoint; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQuery.java b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQuery.java similarity index 84% rename from src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQuery.java rename to src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQuery.java index acb3d05..a4b3968 100755 --- a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQuery.java +++ b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQuery.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.generic.repository.impl; +package br.com.elementasource.mock.generic.repository.impl; -import br.com.concrete.mock.infra.component.CompareMap; -import br.com.concrete.mock.generic.model.Endpoint; +import br.com.elementasource.mock.infra.component.CompareMap; +import br.com.elementasource.mock.generic.model.Endpoint; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterRequest.java b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterRequest.java similarity index 83% rename from src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterRequest.java rename to src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterRequest.java index 2f7684d..e4d040b 100755 --- a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterRequest.java +++ b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterRequest.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.generic.repository.impl; +package br.com.elementasource.mock.generic.repository.impl; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.Request; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Request; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBackup.java b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBackup.java similarity index 68% rename from src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBackup.java rename to src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBackup.java index 8fc0483..39a2e76 100755 --- a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBackup.java +++ b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBackup.java @@ -1,9 +1,9 @@ -package br.com.concrete.mock.generic.repository.impl; +package br.com.elementasource.mock.generic.repository.impl; -import br.com.concrete.mock.generic.mapper.EndpointMapper; -import br.com.concrete.mock.generic.repository.EndpointRepository; -import br.com.concrete.mock.infra.component.file.BaseFileNameBuilder; -import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.elementasource.mock.generic.mapper.EndpointMapper; +import br.com.elementasource.mock.generic.repository.EndpointRepository; +import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilder; +import br.com.elementasource.mock.infra.property.FileExtensionProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBase.java b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBase.java similarity index 87% rename from src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBase.java rename to src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBase.java index 4ffc115..ce2a504 100755 --- a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryBase.java +++ b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBase.java @@ -1,11 +1,11 @@ -package br.com.concrete.mock.generic.repository.impl; +package br.com.elementasource.mock.generic.repository.impl; -import br.com.concrete.mock.generic.mapper.EndpointMapper; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.generic.repository.EndpointRepository; -import br.com.concrete.mock.infra.component.file.BaseFileNameBuilder; -import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.elementasource.mock.generic.mapper.EndpointMapper; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.generic.repository.EndpointRepository; +import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilder; +import br.com.elementasource.mock.infra.property.FileExtensionProperty; import com.google.common.collect.ImmutableList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModel.java b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModel.java similarity index 68% rename from src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModel.java rename to src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModel.java index 24216de..28cdbb2 100755 --- a/src/main/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModel.java +++ b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModel.java @@ -1,9 +1,9 @@ -package br.com.concrete.mock.generic.repository.impl; +package br.com.elementasource.mock.generic.repository.impl; -import br.com.concrete.mock.generic.mapper.EndpointMapper; -import br.com.concrete.mock.generic.repository.EndpointRepository; -import br.com.concrete.mock.infra.component.file.BaseFileNameBuilder; -import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.elementasource.mock.generic.mapper.EndpointMapper; +import br.com.elementasource.mock.generic.repository.EndpointRepository; +import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilder; +import br.com.elementasource.mock.infra.property.FileExtensionProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; diff --git a/src/main/java/br/com/concrete/mock/generic/service/EndpointBackupService.java b/src/main/java/br/com/elementasource/mock/generic/service/EndpointBackupService.java similarity index 54% rename from src/main/java/br/com/concrete/mock/generic/service/EndpointBackupService.java rename to src/main/java/br/com/elementasource/mock/generic/service/EndpointBackupService.java index 472d51e..f284797 100755 --- a/src/main/java/br/com/concrete/mock/generic/service/EndpointBackupService.java +++ b/src/main/java/br/com/elementasource/mock/generic/service/EndpointBackupService.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.generic.service; +package br.com.elementasource.mock.generic.service; -import br.com.concrete.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Endpoint; public interface EndpointBackupService { diff --git a/src/main/java/br/com/concrete/mock/generic/service/GenericApiService.java b/src/main/java/br/com/elementasource/mock/generic/service/GenericApiService.java similarity index 80% rename from src/main/java/br/com/concrete/mock/generic/service/GenericApiService.java rename to src/main/java/br/com/elementasource/mock/generic/service/GenericApiService.java index fa712d2..5fb87db 100755 --- a/src/main/java/br/com/concrete/mock/generic/service/GenericApiService.java +++ b/src/main/java/br/com/elementasource/mock/generic/service/GenericApiService.java @@ -1,14 +1,13 @@ -package br.com.concrete.mock.generic.service; +package br.com.elementasource.mock.generic.service; import java.util.Map; import java.util.Optional; import javax.servlet.http.HttpServletRequest; +import br.com.elementasource.mock.generic.model.Request; import org.springframework.http.ResponseEntity; -import br.com.concrete.mock.generic.model.Request; - public interface GenericApiService { Optional> genericResponseEntity(Request request); diff --git a/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java b/src/main/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFile.java similarity index 82% rename from src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java rename to src/main/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFile.java index 9e490d2..74d848b 100755 --- a/src/main/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFile.java +++ b/src/main/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFile.java @@ -1,16 +1,16 @@ -package br.com.concrete.mock.generic.service.impl; +package br.com.elementasource.mock.generic.service.impl; -import br.com.concrete.mock.generic.mapper.EndpointDto; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.generic.repository.EndpointRepository; -import br.com.concrete.mock.generic.service.EndpointBackupService; -import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; -import br.com.concrete.mock.infra.component.file.BaseFileNameBuilder; -import br.com.concrete.mock.infra.component.file.FileNameGenerator; -import br.com.concrete.mock.infra.component.impl.JsonFormatterPretty; -import br.com.concrete.mock.infra.property.FileExtensionProperty; -import br.com.concrete.mock.infra.property.FileProperty; +import br.com.elementasource.mock.generic.mapper.EndpointDto; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.generic.repository.EndpointRepository; +import br.com.elementasource.mock.generic.service.EndpointBackupService; +import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilder; +import br.com.elementasource.mock.infra.component.file.FileNameGenerator; +import br.com.elementasource.mock.infra.component.impl.JsonFormatterPretty; +import br.com.elementasource.mock.infra.property.FileExtensionProperty; +import br.com.elementasource.mock.infra.property.FileProperty; import com.google.gson.Gson; import java.nio.charset.Charset; import java.util.Arrays; diff --git a/src/main/java/br/com/concrete/mock/generic/service/impl/GenericApiServiceImpl.java b/src/main/java/br/com/elementasource/mock/generic/service/impl/GenericApiServiceImpl.java similarity index 89% rename from src/main/java/br/com/concrete/mock/generic/service/impl/GenericApiServiceImpl.java rename to src/main/java/br/com/elementasource/mock/generic/service/impl/GenericApiServiceImpl.java index 57f2126..7c2ad95 100755 --- a/src/main/java/br/com/concrete/mock/generic/service/impl/GenericApiServiceImpl.java +++ b/src/main/java/br/com/elementasource/mock/generic/service/impl/GenericApiServiceImpl.java @@ -1,13 +1,13 @@ -package br.com.concrete.mock.generic.service.impl; - -import br.com.concrete.mock.configuration.service.CaptureExecutor; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.generic.repository.EndpointRepository; -import br.com.concrete.mock.generic.service.GenericApiService; -import br.com.concrete.mock.infra.component.ExternalApi; -import br.com.concrete.mock.infra.component.JsonValueCompiler; -import br.com.concrete.mock.infra.property.ApiProperty; +package br.com.elementasource.mock.generic.service.impl; + +import br.com.elementasource.mock.configuration.service.CaptureExecutor; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.generic.repository.EndpointRepository; +import br.com.elementasource.mock.generic.service.GenericApiService; +import br.com.elementasource.mock.infra.component.ExternalApi; +import br.com.elementasource.mock.infra.component.JsonValueCompiler; +import br.com.elementasource.mock.infra.property.ApiProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; diff --git a/src/main/java/br/com/concrete/mock/infra/component/CompareJson.java b/src/main/java/br/com/elementasource/mock/infra/component/CompareJson.java similarity index 95% rename from src/main/java/br/com/concrete/mock/infra/component/CompareJson.java rename to src/main/java/br/com/elementasource/mock/infra/component/CompareJson.java index 044b899..e57e05a 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/CompareJson.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/CompareJson.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/infra/component/CompareMap.java b/src/main/java/br/com/elementasource/mock/infra/component/CompareMap.java similarity index 92% rename from src/main/java/br/com/concrete/mock/infra/component/CompareMap.java rename to src/main/java/br/com/elementasource/mock/infra/component/CompareMap.java index e64de1b..9caef24 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/CompareMap.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/CompareMap.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/infra/component/ConvertJson.java b/src/main/java/br/com/elementasource/mock/infra/component/ConvertJson.java similarity index 72% rename from src/main/java/br/com/concrete/mock/infra/component/ConvertJson.java rename to src/main/java/br/com/elementasource/mock/infra/component/ConvertJson.java index a1e4484..6d36e96 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/ConvertJson.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/ConvertJson.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; import java.util.HashMap; diff --git a/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java b/src/main/java/br/com/elementasource/mock/infra/component/ExternalApi.java similarity index 91% rename from src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java rename to src/main/java/br/com/elementasource/mock/infra/component/ExternalApi.java index eeb8b0e..baf4311 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/ExternalApi.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/ExternalApi.java @@ -1,11 +1,11 @@ -package br.com.concrete.mock.infra.component; - -import br.com.concrete.mock.configuration.model.CaptureState; -import br.com.concrete.mock.configuration.repository.CaptureStateRepository; -import br.com.concrete.mock.generic.model.ExternalApiResult; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.infra.model.UriConfiguration; -import br.com.concrete.mock.infra.property.ApiProperty; +package br.com.elementasource.mock.infra.component; + +import br.com.elementasource.mock.configuration.model.CaptureState; +import br.com.elementasource.mock.configuration.repository.CaptureStateRepository; +import br.com.elementasource.mock.generic.model.ExternalApiResult; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.infra.model.UriConfiguration; +import br.com.elementasource.mock.infra.property.ApiProperty; import okhttp3.Headers; import okhttp3.OkHttpClient; import okhttp3.Response; diff --git a/src/main/java/br/com/concrete/mock/infra/component/FromJsonStringToObjectConverter.java b/src/main/java/br/com/elementasource/mock/infra/component/FromJsonStringToObjectConverter.java similarity index 78% rename from src/main/java/br/com/concrete/mock/infra/component/FromJsonStringToObjectConverter.java rename to src/main/java/br/com/elementasource/mock/infra/component/FromJsonStringToObjectConverter.java index a2be2fc..427f1ee 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/FromJsonStringToObjectConverter.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/FromJsonStringToObjectConverter.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; import com.google.gson.JsonElement; diff --git a/src/main/java/br/com/concrete/mock/infra/component/HeaderFilter.java b/src/main/java/br/com/elementasource/mock/infra/component/HeaderFilter.java similarity index 93% rename from src/main/java/br/com/concrete/mock/infra/component/HeaderFilter.java rename to src/main/java/br/com/elementasource/mock/infra/component/HeaderFilter.java index baeb783..3e074fe 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/HeaderFilter.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/HeaderFilter.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; -import br.com.concrete.mock.infra.property.ApiProperty; +import br.com.elementasource.mock.infra.property.ApiProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/infra/component/JsonFormatter.java b/src/main/java/br/com/elementasource/mock/infra/component/JsonFormatter.java similarity index 61% rename from src/main/java/br/com/concrete/mock/infra/component/JsonFormatter.java rename to src/main/java/br/com/elementasource/mock/infra/component/JsonFormatter.java index 252e830..ff896ee 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/JsonFormatter.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/JsonFormatter.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; public interface JsonFormatter { diff --git a/src/main/java/br/com/concrete/mock/infra/component/JsonValueCompiler.java b/src/main/java/br/com/elementasource/mock/infra/component/JsonValueCompiler.java similarity index 66% rename from src/main/java/br/com/concrete/mock/infra/component/JsonValueCompiler.java rename to src/main/java/br/com/elementasource/mock/infra/component/JsonValueCompiler.java index 887e53d..7ef0893 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/JsonValueCompiler.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/JsonValueCompiler.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; @FunctionalInterface public interface JsonValueCompiler { diff --git a/src/main/java/br/com/concrete/mock/infra/component/QueryStringBuilder.java b/src/main/java/br/com/elementasource/mock/infra/component/QueryStringBuilder.java similarity index 68% rename from src/main/java/br/com/concrete/mock/infra/component/QueryStringBuilder.java rename to src/main/java/br/com/elementasource/mock/infra/component/QueryStringBuilder.java index be9a651..452c9fb 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/QueryStringBuilder.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/QueryStringBuilder.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; import java.util.Map; diff --git a/src/main/java/br/com/concrete/mock/infra/component/RequestFormatter.java b/src/main/java/br/com/elementasource/mock/infra/component/RequestFormatter.java similarity index 80% rename from src/main/java/br/com/concrete/mock/infra/component/RequestFormatter.java rename to src/main/java/br/com/elementasource/mock/infra/component/RequestFormatter.java index 431302d..131e7ba 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/RequestFormatter.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/RequestFormatter.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; import javax.servlet.http.HttpServletRequest; import java.util.Optional; diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilder.java b/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilder.java similarity index 81% rename from src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilder.java rename to src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilder.java index ab5952f..59b7382 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilder.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilder.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component.file; +package br.com.elementasource.mock.infra.component.file; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBackup.java b/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBackup.java similarity index 79% rename from src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBackup.java rename to src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBackup.java index ae5d127..ca2e1a5 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBackup.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBackup.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component.file; +package br.com.elementasource.mock.infra.component.file; -import br.com.concrete.mock.infra.property.FileProperty; +import br.com.elementasource.mock.infra.property.FileProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBase.java b/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBase.java similarity index 86% rename from src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBase.java rename to src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBase.java index 9a67526..34d4278 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderBase.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBase.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component.file; +package br.com.elementasource.mock.infra.component.file; -import br.com.concrete.mock.infra.property.FileProperty; +import br.com.elementasource.mock.infra.property.FileProperty; import org.springframework.web.bind.annotation.RequestMethod; public class BaseFileNameBuilderBase implements BaseFileNameBuilder { diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModel.java b/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModel.java similarity index 79% rename from src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModel.java rename to src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModel.java index eb6114e..d000a56 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModel.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModel.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component.file; +package br.com.elementasource.mock.infra.component.file; -import br.com.concrete.mock.infra.property.FileProperty; +import br.com.elementasource.mock.infra.property.FileProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/FileJsonReader.java b/src/main/java/br/com/elementasource/mock/infra/component/file/FileJsonReader.java similarity index 94% rename from src/main/java/br/com/concrete/mock/infra/component/file/FileJsonReader.java rename to src/main/java/br/com/elementasource/mock/infra/component/file/FileJsonReader.java index edf7c78..30c9099 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/file/FileJsonReader.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/file/FileJsonReader.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component.file; +package br.com.elementasource.mock.infra.component.file; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/FileNameGenerator.java b/src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGenerator.java similarity index 58% rename from src/main/java/br/com/concrete/mock/infra/component/file/FileNameGenerator.java rename to src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGenerator.java index 80c511c..f50be83 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/file/FileNameGenerator.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGenerator.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component.file; +package br.com.elementasource.mock.infra.component.file; public interface FileNameGenerator { diff --git a/src/main/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImpl.java b/src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImpl.java similarity index 91% rename from src/main/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImpl.java rename to src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImpl.java index 2bd46cd..370179c 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImpl.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImpl.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component.file; +package br.com.elementasource.mock.infra.component.file; -import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.elementasource.mock.infra.property.FileExtensionProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImpl.java b/src/main/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImpl.java similarity index 79% rename from src/main/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImpl.java rename to src/main/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImpl.java index 9c82e90..a489dc7 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImpl.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImpl.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.infra.component.impl; +package br.com.elementasource.mock.infra.component.impl; -import br.com.concrete.mock.infra.component.ConvertJson; -import br.com.concrete.mock.infra.exception.impl.JsonApiApplicationException; +import br.com.elementasource.mock.infra.component.ConvertJson; +import br.com.elementasource.mock.infra.exception.impl.JsonApiApplicationException; import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java b/src/main/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java similarity index 84% rename from src/main/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java rename to src/main/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java index b231537..ed42621 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component.impl; +package br.com.elementasource.mock.infra.component.impl; -import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPretty.java b/src/main/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPretty.java similarity index 82% rename from src/main/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPretty.java rename to src/main/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPretty.java index 79c5553..4853a9a 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPretty.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPretty.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component.impl; +package br.com.elementasource.mock.infra.component.impl; -import br.com.concrete.mock.infra.component.JsonFormatter; +import br.com.elementasource.mock.infra.component.JsonFormatter; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImpl.java b/src/main/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImpl.java similarity index 88% rename from src/main/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImpl.java rename to src/main/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImpl.java index ca6620d..5e3c48a 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImpl.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImpl.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component.impl; +package br.com.elementasource.mock.infra.component.impl; -import br.com.concrete.mock.infra.component.JsonValueCompiler; +import br.com.elementasource.mock.infra.component.JsonValueCompiler; import org.springframework.stereotype.Component; import java.time.LocalDate; diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImpl.java b/src/main/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImpl.java similarity index 80% rename from src/main/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImpl.java rename to src/main/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImpl.java index c9871e7..b03bf53 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImpl.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImpl.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.infra.component.impl; +package br.com.elementasource.mock.infra.component.impl; -import br.com.concrete.mock.infra.component.ConvertJson; -import br.com.concrete.mock.infra.component.QueryStringBuilder; +import br.com.elementasource.mock.infra.component.ConvertJson; +import br.com.elementasource.mock.infra.component.QueryStringBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/infra/component/impl/RequestFormatterImpl.java b/src/main/java/br/com/elementasource/mock/infra/component/impl/RequestFormatterImpl.java similarity index 82% rename from src/main/java/br/com/concrete/mock/infra/component/impl/RequestFormatterImpl.java rename to src/main/java/br/com/elementasource/mock/infra/component/impl/RequestFormatterImpl.java index ee6f421..477bbc0 100755 --- a/src/main/java/br/com/concrete/mock/infra/component/impl/RequestFormatterImpl.java +++ b/src/main/java/br/com/elementasource/mock/infra/component/impl/RequestFormatterImpl.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component.impl; +package br.com.elementasource.mock.infra.component.impl; -import br.com.concrete.mock.infra.component.RequestFormatter; +import br.com.elementasource.mock.infra.component.RequestFormatter; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; diff --git a/src/main/java/br/com/concrete/mock/infra/controller/ShutdownController.java b/src/main/java/br/com/elementasource/mock/infra/controller/ShutdownController.java similarity index 92% rename from src/main/java/br/com/concrete/mock/infra/controller/ShutdownController.java rename to src/main/java/br/com/elementasource/mock/infra/controller/ShutdownController.java index d7ed3f7..1d02211 100644 --- a/src/main/java/br/com/concrete/mock/infra/controller/ShutdownController.java +++ b/src/main/java/br/com/elementasource/mock/infra/controller/ShutdownController.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.controller; +package br.com.elementasource.mock.infra.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; diff --git a/src/main/java/br/com/concrete/mock/infra/exception/ApplicationException.java b/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationException.java similarity index 68% rename from src/main/java/br/com/concrete/mock/infra/exception/ApplicationException.java rename to src/main/java/br/com/elementasource/mock/infra/exception/ApplicationException.java index 197418d..6fb4060 100755 --- a/src/main/java/br/com/concrete/mock/infra/exception/ApplicationException.java +++ b/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationException.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.exception; +package br.com.elementasource.mock.infra.exception; public interface ApplicationException { diff --git a/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionHandler.java b/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionHandler.java similarity index 87% rename from src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionHandler.java rename to src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionHandler.java index c3ac694..c450412 100755 --- a/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionHandler.java +++ b/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionHandler.java @@ -1,9 +1,9 @@ -package br.com.concrete.mock.infra.exception; +package br.com.elementasource.mock.infra.exception; -import br.com.concrete.mock.infra.exception.impl.ApiApplicationException; -import br.com.concrete.mock.infra.exception.impl.ApplicationExceptionImpl; -import br.com.concrete.mock.infra.exception.impl.ApplicationExceptionMessageImpl; -import br.com.concrete.mock.infra.exception.impl.ErrorApplicationException; +import br.com.elementasource.mock.infra.exception.impl.ApiApplicationException; +import br.com.elementasource.mock.infra.exception.impl.ApplicationExceptionImpl; +import br.com.elementasource.mock.infra.exception.impl.ApplicationExceptionMessageImpl; +import br.com.elementasource.mock.infra.exception.impl.ErrorApplicationException; import com.google.gson.Gson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionMessage.java b/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionMessage.java similarity index 66% rename from src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionMessage.java rename to src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionMessage.java index 4a5d7d9..f6649a2 100755 --- a/src/main/java/br/com/concrete/mock/infra/exception/ApplicationExceptionMessage.java +++ b/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionMessage.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.exception; +package br.com.elementasource.mock.infra.exception; public interface ApplicationExceptionMessage { diff --git a/src/main/java/br/com/concrete/mock/infra/exception/impl/ApiApplicationException.java b/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApiApplicationException.java similarity index 72% rename from src/main/java/br/com/concrete/mock/infra/exception/impl/ApiApplicationException.java rename to src/main/java/br/com/elementasource/mock/infra/exception/impl/ApiApplicationException.java index ff25bb0..4be1db8 100755 --- a/src/main/java/br/com/concrete/mock/infra/exception/impl/ApiApplicationException.java +++ b/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApiApplicationException.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.exception.impl; +package br.com.elementasource.mock.infra.exception.impl; -import br.com.concrete.mock.infra.exception.ApplicationException; +import br.com.elementasource.mock.infra.exception.ApplicationException; import org.springframework.http.HttpStatus; public class ApiApplicationException extends ApplicationExceptionImpl implements ApplicationException { diff --git a/src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionImpl.java b/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionImpl.java similarity index 67% rename from src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionImpl.java rename to src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionImpl.java index c7c7e16..89b1352 100755 --- a/src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionImpl.java +++ b/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionImpl.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.infra.exception.impl; +package br.com.elementasource.mock.infra.exception.impl; -import br.com.concrete.mock.infra.exception.ApplicationException; -import br.com.concrete.mock.infra.exception.ApplicationExceptionMessage; +import br.com.elementasource.mock.infra.exception.ApplicationException; +import br.com.elementasource.mock.infra.exception.ApplicationExceptionMessage; public class ApplicationExceptionImpl extends RuntimeException implements ApplicationException { diff --git a/src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java b/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java similarity index 78% rename from src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java rename to src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java index cf7fbe2..5ddafc7 100755 --- a/src/main/java/br/com/concrete/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java +++ b/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.exception.impl; +package br.com.elementasource.mock.infra.exception.impl; -import br.com.concrete.mock.infra.exception.ApplicationExceptionMessage; +import br.com.elementasource.mock.infra.exception.ApplicationExceptionMessage; import java.io.Serializable; diff --git a/src/main/java/br/com/concrete/mock/infra/exception/impl/ErrorApplicationException.java b/src/main/java/br/com/elementasource/mock/infra/exception/impl/ErrorApplicationException.java similarity index 63% rename from src/main/java/br/com/concrete/mock/infra/exception/impl/ErrorApplicationException.java rename to src/main/java/br/com/elementasource/mock/infra/exception/impl/ErrorApplicationException.java index 060e6d9..6d55439 100755 --- a/src/main/java/br/com/concrete/mock/infra/exception/impl/ErrorApplicationException.java +++ b/src/main/java/br/com/elementasource/mock/infra/exception/impl/ErrorApplicationException.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.exception.impl; +package br.com.elementasource.mock.infra.exception.impl; -import br.com.concrete.mock.infra.exception.ApplicationException; +import br.com.elementasource.mock.infra.exception.ApplicationException; public class ErrorApplicationException extends ApplicationExceptionImpl implements ApplicationException { diff --git a/src/main/java/br/com/concrete/mock/infra/exception/impl/JsonApiApplicationException.java b/src/main/java/br/com/elementasource/mock/infra/exception/impl/JsonApiApplicationException.java similarity index 73% rename from src/main/java/br/com/concrete/mock/infra/exception/impl/JsonApiApplicationException.java rename to src/main/java/br/com/elementasource/mock/infra/exception/impl/JsonApiApplicationException.java index 3c355c5..16853ce 100755 --- a/src/main/java/br/com/concrete/mock/infra/exception/impl/JsonApiApplicationException.java +++ b/src/main/java/br/com/elementasource/mock/infra/exception/impl/JsonApiApplicationException.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.exception.impl; +package br.com.elementasource.mock.infra.exception.impl; -import br.com.concrete.mock.infra.exception.ApplicationException; +import br.com.elementasource.mock.infra.exception.ApplicationException; import org.springframework.http.HttpStatus; public class JsonApiApplicationException extends ApplicationExceptionImpl implements ApplicationException { diff --git a/src/main/java/br/com/concrete/mock/infra/model/DefaultHeader.java b/src/main/java/br/com/elementasource/mock/infra/model/DefaultHeader.java similarity index 96% rename from src/main/java/br/com/concrete/mock/infra/model/DefaultHeader.java rename to src/main/java/br/com/elementasource/mock/infra/model/DefaultHeader.java index 3d33c31..4c76709 100644 --- a/src/main/java/br/com/concrete/mock/infra/model/DefaultHeader.java +++ b/src/main/java/br/com/elementasource/mock/infra/model/DefaultHeader.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.model; +package br.com.elementasource.mock.infra.model; import java.io.Serializable; import java.util.List; diff --git a/src/main/java/br/com/concrete/mock/infra/model/UriConfiguration.java b/src/main/java/br/com/elementasource/mock/infra/model/UriConfiguration.java similarity index 97% rename from src/main/java/br/com/concrete/mock/infra/model/UriConfiguration.java rename to src/main/java/br/com/elementasource/mock/infra/model/UriConfiguration.java index dca3278..f079867 100644 --- a/src/main/java/br/com/concrete/mock/infra/model/UriConfiguration.java +++ b/src/main/java/br/com/elementasource/mock/infra/model/UriConfiguration.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.model; +package br.com.elementasource.mock.infra.model; import java.io.Serializable; import java.util.Objects; diff --git a/src/main/java/br/com/concrete/mock/infra/property/ApiProperty.java b/src/main/java/br/com/elementasource/mock/infra/property/ApiProperty.java similarity index 91% rename from src/main/java/br/com/concrete/mock/infra/property/ApiProperty.java rename to src/main/java/br/com/elementasource/mock/infra/property/ApiProperty.java index c15ee95..a3abb35 100755 --- a/src/main/java/br/com/concrete/mock/infra/property/ApiProperty.java +++ b/src/main/java/br/com/elementasource/mock/infra/property/ApiProperty.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.infra.property; +package br.com.elementasource.mock.infra.property; -import br.com.concrete.mock.infra.model.DefaultHeader; -import br.com.concrete.mock.infra.model.UriConfiguration; +import br.com.elementasource.mock.infra.model.DefaultHeader; +import br.com.elementasource.mock.infra.model.UriConfiguration; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/infra/property/FileExtensionProperty.java b/src/main/java/br/com/elementasource/mock/infra/property/FileExtensionProperty.java similarity index 60% rename from src/main/java/br/com/concrete/mock/infra/property/FileExtensionProperty.java rename to src/main/java/br/com/elementasource/mock/infra/property/FileExtensionProperty.java index ed753d8..31c5dc2 100755 --- a/src/main/java/br/com/concrete/mock/infra/property/FileExtensionProperty.java +++ b/src/main/java/br/com/elementasource/mock/infra/property/FileExtensionProperty.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.property; +package br.com.elementasource.mock.infra.property; public interface FileExtensionProperty { diff --git a/src/main/java/br/com/concrete/mock/infra/property/FileProperty.java b/src/main/java/br/com/elementasource/mock/infra/property/FileProperty.java similarity index 55% rename from src/main/java/br/com/concrete/mock/infra/property/FileProperty.java rename to src/main/java/br/com/elementasource/mock/infra/property/FileProperty.java index ffe10e5..6fbcf46 100755 --- a/src/main/java/br/com/concrete/mock/infra/property/FileProperty.java +++ b/src/main/java/br/com/elementasource/mock/infra/property/FileProperty.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.property; +package br.com.elementasource.mock.infra.property; public interface FileProperty { diff --git a/src/main/java/br/com/concrete/mock/infra/property/impl/FileExtensionPropertyImpl.java b/src/main/java/br/com/elementasource/mock/infra/property/impl/FileExtensionPropertyImpl.java similarity index 78% rename from src/main/java/br/com/concrete/mock/infra/property/impl/FileExtensionPropertyImpl.java rename to src/main/java/br/com/elementasource/mock/infra/property/impl/FileExtensionPropertyImpl.java index 47f6dd0..0dbbc1f 100755 --- a/src/main/java/br/com/concrete/mock/infra/property/impl/FileExtensionPropertyImpl.java +++ b/src/main/java/br/com/elementasource/mock/infra/property/impl/FileExtensionPropertyImpl.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.property.impl; +package br.com.elementasource.mock.infra.property.impl; -import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.elementasource.mock.infra.property.FileExtensionProperty; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyBackup.java b/src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyBackup.java similarity index 78% rename from src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyBackup.java rename to src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyBackup.java index b4542c9..913f88a 100755 --- a/src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyBackup.java +++ b/src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyBackup.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.property.impl; +package br.com.elementasource.mock.infra.property.impl; -import br.com.concrete.mock.infra.property.FileProperty; +import br.com.elementasource.mock.infra.property.FileProperty; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyModel.java b/src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyModel.java similarity index 77% rename from src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyModel.java rename to src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyModel.java index de4ee0b..402f146 100755 --- a/src/main/java/br/com/concrete/mock/infra/property/impl/FilePropertyModel.java +++ b/src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyModel.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.property.impl; +package br.com.elementasource.mock.infra.property.impl; -import br.com.concrete.mock.infra.property.FileProperty; +import br.com.elementasource.mock.infra.property.FileProperty; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f110dbd..a65e4c1 100755 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,48 +1,54 @@ -# vmoptions: -Dspring.profiles.active=test - server.port: 9090 - api: - # Requests accept just this headers (optinal property). If property not exists, all headers are accepted -# acceptedHeaders: -# - "accept" -# - "Content-Type" - - # When is not find in repository, then will try to do a request in this host - host: "http://www.mocky.io" - - # Default headers to do a request + host: "http://api.itau/apiitau" # "http://api-des.itau/" + acceptedHeaders: + - "execute" + - "Content-Type" defaultHeaders: + - + headerName: "Server" + headerValues: + - "Microsoft-IIS/8.5" + - + headerName: "X-Powered-By" + headerValues: + - "Express,ASP.NET" + - + headerName: "Access-Control-Allow-Headers" + headerValues: + - "Content-Type" + - + headerName: "Access-Control-Allow-Methods" + headerValues: + - "GET,PUT,POST,DELETE,PATCH" - headerName: "Access-Control-Allow-Origin" headerValues: - - "Connection" + - "*" + - + headerName: "Connection" + headerValues: - "Keep-Alive" - headerName: "Content-Type" headerValues: - - "application/json;charset=UTF-8" - - # Alternative hosts - # When a request uri match with some pattern, than this host will be used + - "application/json;charset=utf-8" uriConfigurations: - - host: "http://www.mocky2.io" - pattern: "begin-of-uri/|another-pattern/" - backup: false + host: "http://api.itau/apiitau" + pattern: "seguranca/token" + backup: true + - + host: "http://api.itau/apiitau" + pattern: "v2/pagamento" + backup: true - - host: "http://www.mocky3.io" - pattern: "teste/|test/" - -# Paths of json + host: "http://api.itau/apiitau" + pattern: "^(seguranca|limites_seguranca)\\/" + backup: false file: - # Look for this path to find json with a request - base: "${MOCK_API_FILE_BASE}" + base: "/home/luis/dev/itau/ws/mobile-teste-integrado/server/fake-api-data" extension: ".json" - # Save request (cache) in this path - backup.path: "${MOCK_BACKUP_FILE_BASE}" - -# Initialize app in capture mode. All requests will be saved + backup.path: "/home/luis/dev/itau/ws/mobile-teste-integrado/server/fake-api-data-backup" captureState: true - debug: true diff --git a/src/test/java/br/com/concrete/mock/ApiApplicationTests.java b/src/test/java/br/com/elementasource/mock/ApiApplicationTests.java similarity index 89% rename from src/test/java/br/com/concrete/mock/ApiApplicationTests.java rename to src/test/java/br/com/elementasource/mock/ApiApplicationTests.java index c29a56b..133dcfd 100755 --- a/src/test/java/br/com/concrete/mock/ApiApplicationTests.java +++ b/src/test/java/br/com/elementasource/mock/ApiApplicationTests.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock; +package br.com.elementasource.mock; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java b/src/test/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java similarity index 91% rename from src/test/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java rename to src/test/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java index 4085d82..03f669d 100755 --- a/src/test/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java +++ b/src/test/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java @@ -1,8 +1,8 @@ -package br.com.concrete.mock.configuration.api.v1.controller; +package br.com.elementasource.mock.configuration.api.v1.controller; -import br.com.concrete.mock.configuration.api.v1.mapper.CaptureStateDto; -import br.com.concrete.mock.configuration.model.CaptureState; -import br.com.concrete.mock.configuration.service.CaptureStateService; +import br.com.elementasource.mock.configuration.api.v1.mapper.CaptureStateDto; +import br.com.elementasource.mock.configuration.model.CaptureState; +import br.com.elementasource.mock.configuration.service.CaptureStateService; import com.google.gson.Gson; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java b/src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java similarity index 96% rename from src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java rename to src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java index e66311c..e6819ff 100755 --- a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.generic.api.v1.controller; +package br.com.elementasource.mock.generic.api.v1.controller; -import br.com.concrete.mock.generic.mapper.EndpointDto; +import br.com.elementasource.mock.generic.mapper.EndpointDto; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import org.json.JSONException; diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java b/src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java similarity index 97% rename from src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java rename to src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java index 6684b80..14fad02 100755 --- a/src/test/java/br/com/concrete/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java @@ -1,8 +1,8 @@ -package br.com.concrete.mock.generic.api.v1.controller; +package br.com.elementasource.mock.generic.api.v1.controller; -import br.com.concrete.mock.infra.component.QueryStringBuilder; -import br.com.concrete.mock.generic.mapper.EndpointDto; -import br.com.concrete.mock.generic.model.Endpoint; +import br.com.elementasource.mock.infra.component.QueryStringBuilder; +import br.com.elementasource.mock.generic.mapper.EndpointDto; +import br.com.elementasource.mock.generic.model.Endpoint; import com.google.gson.Gson; import org.json.JSONException; import org.junit.Before; @@ -20,7 +20,6 @@ import java.io.File; import java.io.IOException; import java.net.URISyntaxException; -import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; diff --git a/src/test/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapperTest.java b/src/test/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapperTest.java similarity index 95% rename from src/test/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapperTest.java rename to src/test/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapperTest.java index ca75061..e730a03 100755 --- a/src/test/java/br/com/concrete/mock/generic/api/v1/mapper/RequestMapperTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapperTest.java @@ -1,8 +1,8 @@ -package br.com.concrete.mock.generic.api.v1.mapper; +package br.com.elementasource.mock.generic.api.v1.mapper; -import br.com.concrete.mock.generic.mapper.HeaderMapper; -import br.com.concrete.mock.generic.mapper.QueryMapper; -import br.com.concrete.mock.generic.model.Request; +import br.com.elementasource.mock.generic.mapper.HeaderMapper; +import br.com.elementasource.mock.generic.mapper.QueryMapper; +import br.com.elementasource.mock.generic.model.Request; import com.google.common.collect.ImmutableMap; import org.json.JSONException; import org.junit.Test; diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java b/src/test/java/br/com/elementasource/mock/generic/mapper/EndpointDtoTest.java similarity index 95% rename from src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java rename to src/test/java/br/com/elementasource/mock/generic/mapper/EndpointDtoTest.java index b49cedb..86ff99d 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointDtoTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/mapper/EndpointDtoTest.java @@ -1,8 +1,8 @@ -package br.com.concrete.mock.generic.mapper; +package br.com.elementasource.mock.generic.mapper; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.template.EndpointTemplate; -import br.com.concrete.mock.infra.component.impl.FromJsonStringToObjectConverterImpl; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.template.EndpointTemplate; +import br.com.elementasource.mock.infra.component.impl.FromJsonStringToObjectConverterImpl; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import com.google.gson.Gson; diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointMapperTest.java b/src/test/java/br/com/elementasource/mock/generic/mapper/EndpointMapperTest.java similarity index 91% rename from src/test/java/br/com/concrete/mock/generic/mapper/EndpointMapperTest.java rename to src/test/java/br/com/elementasource/mock/generic/mapper/EndpointMapperTest.java index 7447bcc..2388717 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/EndpointMapperTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/mapper/EndpointMapperTest.java @@ -1,7 +1,7 @@ -package br.com.concrete.mock.generic.mapper; +package br.com.elementasource.mock.generic.mapper; -import br.com.concrete.mock.infra.component.file.FileJsonReader; -import br.com.concrete.mock.generic.model.Endpoint; +import br.com.elementasource.mock.infra.component.file.FileJsonReader; +import br.com.elementasource.mock.generic.model.Endpoint; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/HeaderMapperTest.java b/src/test/java/br/com/elementasource/mock/generic/mapper/HeaderMapperTest.java similarity index 95% rename from src/test/java/br/com/concrete/mock/generic/mapper/HeaderMapperTest.java rename to src/test/java/br/com/elementasource/mock/generic/mapper/HeaderMapperTest.java index 3ee0c9a..3823f58 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/HeaderMapperTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/mapper/HeaderMapperTest.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.generic.mapper; +package br.com.elementasource.mock.generic.mapper; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/QueryMapperTest.java b/src/test/java/br/com/elementasource/mock/generic/mapper/QueryMapperTest.java similarity index 97% rename from src/test/java/br/com/concrete/mock/generic/mapper/QueryMapperTest.java rename to src/test/java/br/com/elementasource/mock/generic/mapper/QueryMapperTest.java index 6a59266..a23aee2 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/QueryMapperTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/mapper/QueryMapperTest.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.generic.mapper; +package br.com.elementasource.mock.generic.mapper; import com.google.common.collect.ImmutableMap; import org.junit.Test; diff --git a/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java b/src/test/java/br/com/elementasource/mock/generic/mapper/ResponseDtoTest.java similarity index 90% rename from src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java rename to src/test/java/br/com/elementasource/mock/generic/mapper/ResponseDtoTest.java index fbeda82..30a3b17 100755 --- a/src/test/java/br/com/concrete/mock/generic/mapper/ResponseDtoTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/mapper/ResponseDtoTest.java @@ -1,8 +1,8 @@ -package br.com.concrete.mock.generic.mapper; +package br.com.elementasource.mock.generic.mapper; -import br.com.concrete.mock.generic.model.Response; -import br.com.concrete.mock.generic.model.template.ResponseTemplate; -import br.com.concrete.mock.infra.component.impl.FromJsonStringToObjectConverterImpl; +import br.com.elementasource.mock.generic.model.Response; +import br.com.elementasource.mock.generic.model.template.ResponseTemplate; +import br.com.elementasource.mock.infra.component.impl.FromJsonStringToObjectConverterImpl; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import com.google.gson.Gson; diff --git a/src/test/java/br/com/concrete/mock/generic/model/RequestTest.java b/src/test/java/br/com/elementasource/mock/generic/model/RequestTest.java similarity index 93% rename from src/test/java/br/com/concrete/mock/generic/model/RequestTest.java rename to src/test/java/br/com/elementasource/mock/generic/model/RequestTest.java index b039b0b..608b7d6 100755 --- a/src/test/java/br/com/concrete/mock/generic/model/RequestTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/model/RequestTest.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.generic.model; +package br.com.elementasource.mock.generic.model; -import br.com.concrete.mock.generic.model.template.RequestTemplate; +import br.com.elementasource.mock.generic.model.template.RequestTemplate; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.junit.BeforeClass; diff --git a/src/test/java/br/com/concrete/mock/generic/model/template/EndpointTemplate.java b/src/test/java/br/com/elementasource/mock/generic/model/template/EndpointTemplate.java similarity index 91% rename from src/test/java/br/com/concrete/mock/generic/model/template/EndpointTemplate.java rename to src/test/java/br/com/elementasource/mock/generic/model/template/EndpointTemplate.java index d7a5319..365ebd3 100755 --- a/src/test/java/br/com/concrete/mock/generic/model/template/EndpointTemplate.java +++ b/src/test/java/br/com/elementasource/mock/generic/model/template/EndpointTemplate.java @@ -1,8 +1,8 @@ -package br.com.concrete.mock.generic.model.template; +package br.com.elementasource.mock.generic.model.template; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.generic.model.Response; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.generic.model.Response; import br.com.six2six.fixturefactory.Rule; import br.com.six2six.fixturefactory.loader.TemplateLoader; diff --git a/src/test/java/br/com/concrete/mock/generic/model/template/RequestTemplate.java b/src/test/java/br/com/elementasource/mock/generic/model/template/RequestTemplate.java similarity index 96% rename from src/test/java/br/com/concrete/mock/generic/model/template/RequestTemplate.java rename to src/test/java/br/com/elementasource/mock/generic/model/template/RequestTemplate.java index 6dbbfa9..7a4baca 100755 --- a/src/test/java/br/com/concrete/mock/generic/model/template/RequestTemplate.java +++ b/src/test/java/br/com/elementasource/mock/generic/model/template/RequestTemplate.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.generic.model.template; +package br.com.elementasource.mock.generic.model.template; -import br.com.concrete.mock.generic.model.Request; +import br.com.elementasource.mock.generic.model.Request; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.Rule; import br.com.six2six.fixturefactory.loader.TemplateLoader; diff --git a/src/test/java/br/com/concrete/mock/generic/model/template/ResponseTemplate.java b/src/test/java/br/com/elementasource/mock/generic/model/template/ResponseTemplate.java similarity index 92% rename from src/test/java/br/com/concrete/mock/generic/model/template/ResponseTemplate.java rename to src/test/java/br/com/elementasource/mock/generic/model/template/ResponseTemplate.java index b31a8e7..5650af4 100755 --- a/src/test/java/br/com/concrete/mock/generic/model/template/ResponseTemplate.java +++ b/src/test/java/br/com/elementasource/mock/generic/model/template/ResponseTemplate.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.generic.model.template; +package br.com.elementasource.mock.generic.model.template; -import br.com.concrete.mock.generic.model.Response; +import br.com.elementasource.mock.generic.model.Response; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.Rule; import br.com.six2six.fixturefactory.loader.TemplateLoader; diff --git a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBodyTest.java b/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBodyTest.java similarity index 87% rename from src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBodyTest.java rename to src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBodyTest.java index 0a98b87..9e784b7 100755 --- a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterBodyTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBodyTest.java @@ -1,9 +1,9 @@ -package br.com.concrete.mock.generic.repository.impl; +package br.com.elementasource.mock.generic.repository.impl; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.generic.model.template.EndpointTemplate; -import br.com.concrete.mock.generic.model.template.RequestTemplate; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.generic.model.template.EndpointTemplate; +import br.com.elementasource.mock.generic.model.template.RequestTemplate; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.junit.BeforeClass; diff --git a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQueryTest.java b/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQueryTest.java similarity index 87% rename from src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQueryTest.java rename to src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQueryTest.java index 06f0fbc..c537924 100755 --- a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointFileFilterQueryTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQueryTest.java @@ -1,9 +1,9 @@ -package br.com.concrete.mock.generic.repository.impl; +package br.com.elementasource.mock.generic.repository.impl; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.generic.model.template.EndpointTemplate; -import br.com.concrete.mock.generic.model.template.RequestTemplate; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.generic.model.template.EndpointTemplate; +import br.com.elementasource.mock.generic.model.template.RequestTemplate; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.junit.BeforeClass; diff --git a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java b/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModelTest.java similarity index 89% rename from src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java rename to src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModelTest.java index 4f882ce..4abb9c7 100755 --- a/src/test/java/br/com/concrete/mock/generic/repository/impl/EndpointRepositoryModelTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModelTest.java @@ -1,12 +1,12 @@ -package br.com.concrete.mock.generic.repository.impl; - -import br.com.concrete.mock.generic.mapper.EndpointMapper; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.generic.model.template.EndpointTemplate; -import br.com.concrete.mock.infra.component.file.BaseFileNameBuilderModel; -import br.com.concrete.mock.infra.property.FileExtensionProperty; -import br.com.concrete.mock.infra.property.FileProperty; +package br.com.elementasource.mock.generic.repository.impl; + +import br.com.elementasource.mock.generic.mapper.EndpointMapper; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.generic.model.template.EndpointTemplate; +import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilderModel; +import br.com.elementasource.mock.infra.property.FileExtensionProperty; +import br.com.elementasource.mock.infra.property.FileProperty; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.junit.Before; diff --git a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java b/src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java similarity index 91% rename from src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java rename to src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java index cdb265a..5130065 100755 --- a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java @@ -1,10 +1,10 @@ -package br.com.concrete.mock.generic.service.impl; +package br.com.elementasource.mock.generic.service.impl; -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.template.EndpointTemplate; -import br.com.concrete.mock.generic.service.EndpointBackupService; -import br.com.concrete.mock.infra.property.FileExtensionProperty; -import br.com.concrete.mock.infra.property.FileProperty; +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.template.EndpointTemplate; +import br.com.elementasource.mock.generic.service.EndpointBackupService; +import br.com.elementasource.mock.infra.property.FileExtensionProperty; +import br.com.elementasource.mock.infra.property.FileProperty; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.json.JSONException; diff --git a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileTest.java b/src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileTest.java similarity index 84% rename from src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileTest.java rename to src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileTest.java index ffa5166..e7336ec 100755 --- a/src/test/java/br/com/concrete/mock/generic/service/impl/EndpointBackupServiceFileTest.java +++ b/src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileTest.java @@ -1,15 +1,15 @@ -package br.com.concrete.mock.generic.service.impl; - -import br.com.concrete.mock.generic.model.Endpoint; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.generic.model.template.EndpointTemplate; -import br.com.concrete.mock.generic.repository.EndpointRepository; -import br.com.concrete.mock.infra.component.FromJsonStringToObjectConverter; -import br.com.concrete.mock.infra.component.file.BaseFileNameBuilderModel; -import br.com.concrete.mock.infra.component.file.FileNameGenerator; -import br.com.concrete.mock.infra.component.impl.JsonFormatterPretty; -import br.com.concrete.mock.infra.property.FileExtensionProperty; -import br.com.concrete.mock.infra.property.FileProperty; +package br.com.elementasource.mock.generic.service.impl; + +import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.generic.model.template.EndpointTemplate; +import br.com.elementasource.mock.generic.repository.EndpointRepository; +import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilderModel; +import br.com.elementasource.mock.infra.component.file.FileNameGenerator; +import br.com.elementasource.mock.infra.component.impl.JsonFormatterPretty; +import br.com.elementasource.mock.infra.property.FileExtensionProperty; +import br.com.elementasource.mock.infra.property.FileProperty; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.junit.BeforeClass; diff --git a/src/test/java/br/com/concrete/mock/infra/component/ApiPropertyTest.java b/src/test/java/br/com/elementasource/mock/infra/component/ApiPropertyTest.java similarity index 89% rename from src/test/java/br/com/concrete/mock/infra/component/ApiPropertyTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/ApiPropertyTest.java index c381d1e..74ce1c5 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/ApiPropertyTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/ApiPropertyTest.java @@ -1,8 +1,8 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; -import br.com.concrete.mock.infra.model.DefaultHeader; -import br.com.concrete.mock.infra.model.UriConfiguration; -import br.com.concrete.mock.infra.property.ApiProperty; +import br.com.elementasource.mock.infra.model.DefaultHeader; +import br.com.elementasource.mock.infra.model.UriConfiguration; +import br.com.elementasource.mock.infra.property.ApiProperty; import com.google.common.collect.ImmutableList; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/concrete/mock/infra/component/CompareJsonTest.java b/src/test/java/br/com/elementasource/mock/infra/component/CompareJsonTest.java similarity index 95% rename from src/test/java/br/com/concrete/mock/infra/component/CompareJsonTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/CompareJsonTest.java index edb8ca7..463d1db 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/CompareJsonTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/CompareJsonTest.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; -import br.com.concrete.mock.infra.component.impl.ConvertJsonImpl; +import br.com.elementasource.mock.infra.component.impl.ConvertJsonImpl; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/concrete/mock/infra/component/CompareMapTest.java b/src/test/java/br/com/elementasource/mock/infra/component/CompareMapTest.java similarity index 98% rename from src/test/java/br/com/concrete/mock/infra/component/CompareMapTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/CompareMapTest.java index db70515..a60e1ab 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/CompareMapTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/CompareMapTest.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; import com.google.common.collect.ImmutableMap; import org.junit.Test; diff --git a/src/test/java/br/com/concrete/mock/infra/component/ExternalApiTest.java b/src/test/java/br/com/elementasource/mock/infra/component/ExternalApiTest.java similarity index 90% rename from src/test/java/br/com/concrete/mock/infra/component/ExternalApiTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/ExternalApiTest.java index b501d05..2f6c340 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/ExternalApiTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/ExternalApiTest.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component; +package br.com.elementasource.mock.infra.component; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.anyString; @@ -6,6 +6,7 @@ import java.util.Optional; +import br.com.elementasource.mock.infra.model.UriConfiguration; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -14,10 +15,9 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.bind.annotation.RequestMethod; -import br.com.concrete.mock.generic.model.ExternalApiResult; -import br.com.concrete.mock.generic.model.Request; -import br.com.concrete.mock.infra.property.ApiProperty; -import br.com.concrete.mock.infra.model.UriConfiguration; +import br.com.elementasource.mock.generic.model.ExternalApiResult; +import br.com.elementasource.mock.generic.model.Request; +import br.com.elementasource.mock.infra.property.ApiProperty; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) diff --git a/src/test/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModelTest.java b/src/test/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModelTest.java similarity index 93% rename from src/test/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModelTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModelTest.java index 0af8195..cb77002 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/file/BaseFileNameBuilderModelTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModelTest.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component.file; +package br.com.elementasource.mock.infra.component.file; -import br.com.concrete.mock.infra.property.FileProperty; +import br.com.elementasource.mock.infra.property.FileProperty; import org.hamcrest.CoreMatchers; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java b/src/test/java/br/com/elementasource/mock/infra/component/file/FileJsonReaderTest.java similarity index 97% rename from src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/file/FileJsonReaderTest.java index 76abdaa..e81e4be 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/file/FileJsonReaderTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/file/FileJsonReaderTest.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component.file; +package br.com.elementasource.mock.infra.component.file; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java b/src/test/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImplTest.java similarity index 95% rename from src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImplTest.java index 9fded17..9756112 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/file/FileNameGeneratorImplTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImplTest.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component.file; +package br.com.elementasource.mock.infra.component.file; -import br.com.concrete.mock.infra.property.FileExtensionProperty; +import br.com.elementasource.mock.infra.property.FileExtensionProperty; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImplTest.java b/src/test/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImplTest.java similarity index 92% rename from src/test/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImplTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImplTest.java index f1f7ce8..b2f7d7b 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/impl/ConvertJsonImplTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImplTest.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component.impl; +package br.com.elementasource.mock.infra.component.impl; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java b/src/test/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java similarity index 96% rename from src/test/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java index a08f67a..724ccd4 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component.impl; +package br.com.elementasource.mock.infra.component.impl; import com.google.gson.Gson; diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPrettyTest.java b/src/test/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPrettyTest.java similarity index 95% rename from src/test/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPrettyTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPrettyTest.java index 7a166e4..437903a 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/impl/JsonFormatterPrettyTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPrettyTest.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component.impl; +package br.com.elementasource.mock.infra.component.impl; import com.google.gson.JsonParseException; import org.junit.Assert; diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImplTest.java b/src/test/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImplTest.java similarity index 98% rename from src/test/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImplTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImplTest.java index 91bee45..5c03c7a 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/impl/JsonValueCompilerImplTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImplTest.java @@ -1,4 +1,4 @@ -package br.com.concrete.mock.infra.component.impl; +package br.com.elementasource.mock.infra.component.impl; import org.json.JSONException; import org.junit.Test; diff --git a/src/test/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImplTest.java b/src/test/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImplTest.java similarity index 93% rename from src/test/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImplTest.java rename to src/test/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImplTest.java index c8223c5..3c55143 100755 --- a/src/test/java/br/com/concrete/mock/infra/component/impl/QueryStringBuilderImplTest.java +++ b/src/test/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImplTest.java @@ -1,6 +1,6 @@ -package br.com.concrete.mock.infra.component.impl; +package br.com.elementasource.mock.infra.component.impl; -import br.com.concrete.mock.infra.component.ConvertJson; +import br.com.elementasource.mock.infra.component.ConvertJson; import com.google.common.collect.ImmutableMap; import org.junit.Test; import org.junit.runner.RunWith; From 5e4aeb5085443ded0630715655530e178745f685 Mon Sep 17 00:00:00 2001 From: Luis Moro Date: Fri, 27 Oct 2017 14:32:30 -0200 Subject: [PATCH 51/54] Altera o package name para condizer com a finalidade do projeto --- .../mock/ApiApplication.java | 2 +- .../v1/controller/CaptureStateController.java | 6 ++--- .../api/v1/mapper/CaptureStateDto.java | 4 +-- .../configuration/model/CaptureState.java | 2 +- .../repository/CaptureStateRepository.java | 4 +-- .../impl/CaptureStateRepositoryImpl.java | 6 ++--- .../service/CaptureExecutor.java | 11 ++++++++ .../service/CaptureStateService.java | 4 +-- .../service/impl/CaptureExecutorImpl.java | 11 ++++---- .../service/impl/CaptureStateServiceImpl.java | 10 +++---- .../v1/controller/GenericApiController.java | 10 +++---- .../generic/api/v1/mapper/RequestMapper.java | 8 +++--- .../mock/generic/mapper/EndpointDto.java | 12 ++++----- .../mock/generic/mapper/EndpointMapper.java | 6 ++--- .../mock/generic/mapper/HeaderMapper.java | 2 +- .../mock/generic/mapper/QueryMapper.java | 4 +-- .../mock/generic/mapper/RequestDto.java | 6 ++--- .../mock/generic/mapper/ResponseDto.java | 8 +++--- .../mock/generic/model/Endpoint.java | 2 +- .../mock/generic/model/Error.java | 2 +- .../mock/generic/model/ExternalApiResult.java | 4 +-- .../mock/generic/model/Request.java | 8 +++--- .../mock/generic/model/Response.java | 2 +- .../repository/EndpointRepository.java | 6 ++--- .../repository/impl/EndpointFileFilter.java | 10 +++++++ .../impl/EndpointFileFilterBody.java | 6 ++--- .../impl/EndpointFileFilterQuery.java | 6 ++--- .../impl/EndpointFileFilterRequest.java | 6 ++--- .../impl/EndpointRepositoryBackup.java | 10 +++---- .../impl/EndpointRepositoryBase.java | 14 +++++----- .../impl/EndpointRepositoryModel.java | 10 +++---- .../service/EndpointBackupService.java | 4 +-- .../generic/service/GenericApiService.java | 4 +-- .../impl/EndpointBackupServiceFile.java | 24 ++++++++--------- .../service/impl/GenericApiServiceImpl.java | 20 +++++++------- .../mock/infra/component/CompareJson.java | 2 +- .../mock/infra/component/CompareMap.java | 2 +- .../mock/infra/component/ConvertJson.java | 2 +- .../mock/infra/component/ExternalApi.java | 16 ++++++------ .../FromJsonStringToObjectConverter.java | 2 +- .../mock/infra/component/HeaderFilter.java | 4 +-- .../mock/infra/component/JsonFormatter.java | 2 +- .../infra/component/JsonValueCompiler.java | 2 +- .../infra/component/QueryStringBuilder.java | 2 +- .../infra/component/RequestFormatter.java | 2 +- .../component/file/BaseFileNameBuilder.java | 2 +- .../file/BaseFileNameBuilderBackup.java | 4 +-- .../file/BaseFileNameBuilderBase.java | 4 +-- .../file/BaseFileNameBuilderModel.java | 4 +-- .../infra/component/file/FileJsonReader.java | 2 +- .../component/file/FileNameGenerator.java | 2 +- .../component/file/FileNameGeneratorImpl.java | 4 +-- .../infra/component/impl/ConvertJsonImpl.java | 6 ++--- .../FromJsonStringToObjectConverterImpl.java | 4 +-- .../component/impl/JsonFormatterPretty.java | 4 +-- .../component/impl/JsonValueCompilerImpl.java | 4 +-- .../impl/QueryStringBuilderImpl.java | 6 ++--- .../component/impl/RequestFormatterImpl.java | 4 +-- .../infra/controller/ShutdownController.java | 2 +- .../infra/exception/ApplicationException.java | 2 +- .../ApplicationExceptionHandler.java | 10 +++---- .../ApplicationExceptionMessage.java | 2 +- .../impl/ApiApplicationException.java | 4 +-- .../impl/ApplicationExceptionImpl.java | 6 ++--- .../impl/ApplicationExceptionMessageImpl.java | 4 +-- .../impl/ErrorApplicationException.java | 4 +-- .../impl/JsonApiApplicationException.java | 4 +-- .../mock/infra/model/DefaultHeader.java | 2 +- .../mock/infra/model/UriConfiguration.java | 2 +- .../mock/infra/property/ApiProperty.java | 6 ++--- .../infra/property/FileExtensionProperty.java | 2 +- .../mock/infra/property/FileProperty.java | 2 +- .../impl/FileExtensionPropertyImpl.java | 4 +-- .../property/impl/FilePropertyBackup.java | 4 +-- .../property/impl/FilePropertyModel.java | 4 +-- .../service/CaptureExecutor.java | 11 -------- .../repository/impl/EndpointFileFilter.java | 10 ------- .../mock/ApiApplicationTests.java | 2 +- ...CaptureStateControllerIntegrationTest.java | 8 +++--- ...cApiControllerExternalIntegrationTest.java | 4 +-- .../GenericApiControllerIntegrationTest.java | 8 +++--- .../api/v1/mapper/RequestMapperTest.java | 8 +++--- .../mock/generic/mapper/EndpointDtoTest.java | 10 +++---- .../generic/mapper/EndpointMapperTest.java | 6 ++--- .../mock/generic/mapper/HeaderMapperTest.java | 2 +- .../mock/generic/mapper/QueryMapperTest.java | 2 +- .../mock/generic/mapper/ResponseDtoTest.java | 10 +++---- .../mock/generic/model/RequestTest.java | 6 ++--- .../model/template/EndpointTemplate.java | 8 +++--- .../model/template/RequestTemplate.java | 4 +-- .../model/template/ResponseTemplate.java | 4 +-- .../impl/EndpointFileFilterBodyTest.java | 12 ++++----- .../impl/EndpointFileFilterQueryTest.java | 12 ++++----- .../impl/EndpointRepositoryModelTest.java | 20 +++++++------- ...pointBackupServiceFileIntegrarionTest.java | 14 +++++----- .../impl/EndpointBackupServiceFileTest.java | 26 +++++++++---------- .../mock/infra/component/ApiPropertyTest.java | 8 +++--- .../mock/infra/component/CompareJsonTest.java | 4 +-- .../mock/infra/component/CompareMapTest.java | 2 +- .../mock/infra/component/ExternalApiTest.java | 11 ++++---- .../file/BaseFileNameBuilderModelTest.java | 4 +-- .../component/file/FileJsonReaderTest.java | 2 +- .../file/FileNameGeneratorImplTest.java | 4 +-- .../component/impl/ConvertJsonImplTest.java | 2 +- ...omJsonStringToObjectConverterImplTest.java | 2 +- .../impl/JsonFormatterPrettyTest.java | 2 +- .../impl/JsonValueCompilerImplTest.java | 2 +- .../impl/QueryStringBuilderImplTest.java | 4 +-- 108 files changed, 318 insertions(+), 320 deletions(-) rename src/main/java/br/com/{elementasource => elementalsource}/mock/ApiApplication.java (96%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/configuration/api/v1/controller/CaptureStateController.java (88%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/configuration/api/v1/mapper/CaptureStateDto.java (85%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/configuration/model/CaptureState.java (78%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/configuration/repository/CaptureStateRepository.java (58%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java (80%) create mode 100755 src/main/java/br/com/elementalsource/mock/configuration/service/CaptureExecutor.java rename src/main/java/br/com/{elementasource => elementalsource}/mock/configuration/service/CaptureStateService.java (55%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/configuration/service/impl/CaptureExecutorImpl.java (62%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/configuration/service/impl/CaptureStateServiceImpl.java (75%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/api/v1/controller/GenericApiController.java (91%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/api/v1/mapper/RequestMapper.java (86%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/mapper/EndpointDto.java (80%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/mapper/EndpointMapper.java (87%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/mapper/HeaderMapper.java (93%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/mapper/QueryMapper.java (92%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/mapper/RequestDto.java (89%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/mapper/ResponseDto.java (84%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/model/Endpoint.java (98%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/model/Error.java (88%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/model/ExternalApiResult.java (81%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/model/Request.java (94%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/model/Response.java (90%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/repository/EndpointRepository.java (64%) create mode 100755 src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilter.java rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/repository/impl/EndpointFileFilterBody.java (83%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/repository/impl/EndpointFileFilterQuery.java (84%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/repository/impl/EndpointFileFilterRequest.java (83%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/repository/impl/EndpointRepositoryBackup.java (68%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/repository/impl/EndpointRepositoryBase.java (86%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/repository/impl/EndpointRepositoryModel.java (68%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/service/EndpointBackupService.java (53%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/service/GenericApiService.java (80%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/service/impl/EndpointBackupServiceFile.java (82%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/generic/service/impl/GenericApiServiceImpl.java (89%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/CompareJson.java (95%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/CompareMap.java (91%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/ConvertJson.java (71%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/ExternalApi.java (91%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/FromJsonStringToObjectConverter.java (78%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/HeaderFilter.java (92%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/JsonFormatter.java (60%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/JsonValueCompiler.java (65%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/QueryStringBuilder.java (68%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/RequestFormatter.java (79%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/file/BaseFileNameBuilder.java (81%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/file/BaseFileNameBuilderBackup.java (79%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/file/BaseFileNameBuilderBase.java (86%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/file/BaseFileNameBuilderModel.java (79%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/file/FileJsonReader.java (94%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/file/FileNameGenerator.java (58%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/file/FileNameGeneratorImpl.java (90%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/impl/ConvertJsonImpl.java (78%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java (84%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/impl/JsonFormatterPretty.java (81%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/impl/JsonValueCompilerImpl.java (88%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/impl/QueryStringBuilderImpl.java (79%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/component/impl/RequestFormatterImpl.java (82%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/controller/ShutdownController.java (92%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/exception/ApplicationException.java (68%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/exception/ApplicationExceptionHandler.java (87%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/exception/ApplicationExceptionMessage.java (66%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/exception/impl/ApiApplicationException.java (71%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/exception/impl/ApplicationExceptionImpl.java (67%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java (78%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/exception/impl/ErrorApplicationException.java (62%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/exception/impl/JsonApiApplicationException.java (73%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/model/DefaultHeader.java (96%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/model/UriConfiguration.java (97%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/property/ApiProperty.java (91%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/property/FileExtensionProperty.java (59%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/property/FileProperty.java (54%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/property/impl/FileExtensionPropertyImpl.java (77%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/property/impl/FilePropertyBackup.java (77%) rename src/main/java/br/com/{elementasource => elementalsource}/mock/infra/property/impl/FilePropertyModel.java (77%) delete mode 100755 src/main/java/br/com/elementasource/mock/configuration/service/CaptureExecutor.java delete mode 100755 src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilter.java rename src/test/java/br/com/{elementasource => elementalsource}/mock/ApiApplicationTests.java (89%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java (91%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java (96%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java (97%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/api/v1/mapper/RequestMapperTest.java (95%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/mapper/EndpointDtoTest.java (94%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/mapper/EndpointMapperTest.java (91%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/mapper/HeaderMapperTest.java (95%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/mapper/QueryMapperTest.java (97%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/mapper/ResponseDtoTest.java (87%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/model/RequestTest.java (89%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/model/template/EndpointTemplate.java (91%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/model/template/RequestTemplate.java (96%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/model/template/ResponseTemplate.java (92%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/repository/impl/EndpointFileFilterBodyTest.java (83%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/repository/impl/EndpointFileFilterQueryTest.java (83%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/repository/impl/EndpointRepositoryModelTest.java (87%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java (89%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/generic/service/impl/EndpointBackupServiceFileTest.java (82%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/ApiPropertyTest.java (88%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/CompareJsonTest.java (95%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/CompareMapTest.java (98%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/ExternalApiTest.java (90%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/file/BaseFileNameBuilderModelTest.java (93%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/file/FileJsonReaderTest.java (97%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/file/FileNameGeneratorImplTest.java (95%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/impl/ConvertJsonImplTest.java (92%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java (96%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/impl/JsonFormatterPrettyTest.java (95%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/impl/JsonValueCompilerImplTest.java (98%) rename src/test/java/br/com/{elementasource => elementalsource}/mock/infra/component/impl/QueryStringBuilderImplTest.java (93%) diff --git a/src/main/java/br/com/elementasource/mock/ApiApplication.java b/src/main/java/br/com/elementalsource/mock/ApiApplication.java similarity index 96% rename from src/main/java/br/com/elementasource/mock/ApiApplication.java rename to src/main/java/br/com/elementalsource/mock/ApiApplication.java index 9274e0f..6a98ed9 100755 --- a/src/main/java/br/com/elementasource/mock/ApiApplication.java +++ b/src/main/java/br/com/elementalsource/mock/ApiApplication.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock; +package br.com.elementalsource.mock; import okhttp3.OkHttpClient; import org.apache.http.client.HttpClient; diff --git a/src/main/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateController.java b/src/main/java/br/com/elementalsource/mock/configuration/api/v1/controller/CaptureStateController.java similarity index 88% rename from src/main/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateController.java rename to src/main/java/br/com/elementalsource/mock/configuration/api/v1/controller/CaptureStateController.java index f290dd9..12c40ed 100755 --- a/src/main/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateController.java +++ b/src/main/java/br/com/elementalsource/mock/configuration/api/v1/controller/CaptureStateController.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.configuration.api.v1.controller; +package br.com.elementalsource.mock.configuration.api.v1.controller; -import br.com.elementasource.mock.configuration.api.v1.mapper.CaptureStateDto; -import br.com.elementasource.mock.configuration.service.CaptureStateService; +import br.com.elementalsource.mock.configuration.api.v1.mapper.CaptureStateDto; +import br.com.elementalsource.mock.configuration.service.CaptureStateService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/br/com/elementasource/mock/configuration/api/v1/mapper/CaptureStateDto.java b/src/main/java/br/com/elementalsource/mock/configuration/api/v1/mapper/CaptureStateDto.java similarity index 85% rename from src/main/java/br/com/elementasource/mock/configuration/api/v1/mapper/CaptureStateDto.java rename to src/main/java/br/com/elementalsource/mock/configuration/api/v1/mapper/CaptureStateDto.java index 8dd014c..457aa25 100755 --- a/src/main/java/br/com/elementasource/mock/configuration/api/v1/mapper/CaptureStateDto.java +++ b/src/main/java/br/com/elementalsource/mock/configuration/api/v1/mapper/CaptureStateDto.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.configuration.api.v1.mapper; +package br.com.elementalsource.mock.configuration.api.v1.mapper; -import br.com.elementasource.mock.configuration.model.CaptureState; +import br.com.elementalsource.mock.configuration.model.CaptureState; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/br/com/elementasource/mock/configuration/model/CaptureState.java b/src/main/java/br/com/elementalsource/mock/configuration/model/CaptureState.java similarity index 78% rename from src/main/java/br/com/elementasource/mock/configuration/model/CaptureState.java rename to src/main/java/br/com/elementalsource/mock/configuration/model/CaptureState.java index f96e1cd..1d5ad15 100755 --- a/src/main/java/br/com/elementasource/mock/configuration/model/CaptureState.java +++ b/src/main/java/br/com/elementalsource/mock/configuration/model/CaptureState.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.configuration.model; +package br.com.elementalsource.mock.configuration.model; public class CaptureState { diff --git a/src/main/java/br/com/elementasource/mock/configuration/repository/CaptureStateRepository.java b/src/main/java/br/com/elementalsource/mock/configuration/repository/CaptureStateRepository.java similarity index 58% rename from src/main/java/br/com/elementasource/mock/configuration/repository/CaptureStateRepository.java rename to src/main/java/br/com/elementalsource/mock/configuration/repository/CaptureStateRepository.java index a29826c..a403a16 100755 --- a/src/main/java/br/com/elementasource/mock/configuration/repository/CaptureStateRepository.java +++ b/src/main/java/br/com/elementalsource/mock/configuration/repository/CaptureStateRepository.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.configuration.repository; +package br.com.elementalsource.mock.configuration.repository; -import br.com.elementasource.mock.configuration.model.CaptureState; +import br.com.elementalsource.mock.configuration.model.CaptureState; import java.util.Optional; diff --git a/src/main/java/br/com/elementasource/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java b/src/main/java/br/com/elementalsource/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java similarity index 80% rename from src/main/java/br/com/elementasource/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java rename to src/main/java/br/com/elementalsource/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java index 1e9cb3f..f02d591 100755 --- a/src/main/java/br/com/elementasource/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java +++ b/src/main/java/br/com/elementalsource/mock/configuration/repository/impl/CaptureStateRepositoryImpl.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.configuration.repository.impl; +package br.com.elementalsource.mock.configuration.repository.impl; -import br.com.elementasource.mock.configuration.model.CaptureState; -import br.com.elementasource.mock.configuration.repository.CaptureStateRepository; +import br.com.elementalsource.mock.configuration.model.CaptureState; +import br.com.elementalsource.mock.configuration.repository.CaptureStateRepository; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; diff --git a/src/main/java/br/com/elementalsource/mock/configuration/service/CaptureExecutor.java b/src/main/java/br/com/elementalsource/mock/configuration/service/CaptureExecutor.java new file mode 100755 index 0000000..8722bfe --- /dev/null +++ b/src/main/java/br/com/elementalsource/mock/configuration/service/CaptureExecutor.java @@ -0,0 +1,11 @@ +package br.com.elementalsource.mock.configuration.service; + +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.ExternalApiResult; + +@FunctionalInterface +public interface CaptureExecutor { + + void execute(ExternalApiResult apiResult, Endpoint endpoint); + +} diff --git a/src/main/java/br/com/elementasource/mock/configuration/service/CaptureStateService.java b/src/main/java/br/com/elementalsource/mock/configuration/service/CaptureStateService.java similarity index 55% rename from src/main/java/br/com/elementasource/mock/configuration/service/CaptureStateService.java rename to src/main/java/br/com/elementalsource/mock/configuration/service/CaptureStateService.java index ccd615b..229a5b9 100755 --- a/src/main/java/br/com/elementasource/mock/configuration/service/CaptureStateService.java +++ b/src/main/java/br/com/elementalsource/mock/configuration/service/CaptureStateService.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.configuration.service; +package br.com.elementalsource.mock.configuration.service; -import br.com.elementasource.mock.configuration.model.CaptureState; +import br.com.elementalsource.mock.configuration.model.CaptureState; import java.util.Optional; diff --git a/src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureExecutorImpl.java b/src/main/java/br/com/elementalsource/mock/configuration/service/impl/CaptureExecutorImpl.java similarity index 62% rename from src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureExecutorImpl.java rename to src/main/java/br/com/elementalsource/mock/configuration/service/impl/CaptureExecutorImpl.java index 16935c3..6217e7c 100755 --- a/src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureExecutorImpl.java +++ b/src/main/java/br/com/elementalsource/mock/configuration/service/impl/CaptureExecutorImpl.java @@ -1,13 +1,12 @@ -package br.com.elementasource.mock.configuration.service.impl; +package br.com.elementalsource.mock.configuration.service.impl; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.ExternalApiResult; -import br.com.elementasource.mock.generic.service.EndpointBackupService; +import br.com.elementalsource.mock.configuration.service.CaptureExecutor; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.ExternalApiResult; +import br.com.elementalsource.mock.generic.service.EndpointBackupService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import br.com.elementasource.mock.configuration.service.CaptureExecutor; - @Service public class CaptureExecutorImpl implements CaptureExecutor { diff --git a/src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureStateServiceImpl.java b/src/main/java/br/com/elementalsource/mock/configuration/service/impl/CaptureStateServiceImpl.java similarity index 75% rename from src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureStateServiceImpl.java rename to src/main/java/br/com/elementalsource/mock/configuration/service/impl/CaptureStateServiceImpl.java index 0ef1cad..8fd549b 100755 --- a/src/main/java/br/com/elementasource/mock/configuration/service/impl/CaptureStateServiceImpl.java +++ b/src/main/java/br/com/elementalsource/mock/configuration/service/impl/CaptureStateServiceImpl.java @@ -1,9 +1,9 @@ -package br.com.elementasource.mock.configuration.service.impl; +package br.com.elementalsource.mock.configuration.service.impl; -import br.com.elementasource.mock.configuration.model.CaptureState; -import br.com.elementasource.mock.configuration.repository.CaptureStateRepository; -import br.com.elementasource.mock.configuration.service.CaptureStateService; -import br.com.elementasource.mock.infra.exception.impl.ApiApplicationException; +import br.com.elementalsource.mock.configuration.model.CaptureState; +import br.com.elementalsource.mock.configuration.service.CaptureStateService; +import br.com.elementalsource.mock.infra.exception.impl.ApiApplicationException; +import br.com.elementalsource.mock.configuration.repository.CaptureStateRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiController.java b/src/main/java/br/com/elementalsource/mock/generic/api/v1/controller/GenericApiController.java similarity index 91% rename from src/main/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiController.java rename to src/main/java/br/com/elementalsource/mock/generic/api/v1/controller/GenericApiController.java index f7401ba..ad4bcf5 100755 --- a/src/main/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiController.java +++ b/src/main/java/br/com/elementalsource/mock/generic/api/v1/controller/GenericApiController.java @@ -1,9 +1,9 @@ -package br.com.elementasource.mock.generic.api.v1.controller; +package br.com.elementalsource.mock.generic.api.v1.controller; -import br.com.elementasource.mock.generic.api.v1.mapper.RequestMapper; -import br.com.elementasource.mock.generic.service.GenericApiService; -import br.com.elementasource.mock.infra.component.JsonFormatter; -import br.com.elementasource.mock.infra.component.RequestFormatter; +import br.com.elementalsource.mock.generic.service.GenericApiService; +import br.com.elementalsource.mock.infra.component.JsonFormatter; +import br.com.elementalsource.mock.infra.component.RequestFormatter; +import br.com.elementalsource.mock.generic.api.v1.mapper.RequestMapper; import com.google.gson.Gson; import com.google.gson.JsonParseException; import org.slf4j.Logger; diff --git a/src/main/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapper.java b/src/main/java/br/com/elementalsource/mock/generic/api/v1/mapper/RequestMapper.java similarity index 86% rename from src/main/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapper.java rename to src/main/java/br/com/elementalsource/mock/generic/api/v1/mapper/RequestMapper.java index 158cfa7..9937eb3 100755 --- a/src/main/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapper.java +++ b/src/main/java/br/com/elementalsource/mock/generic/api/v1/mapper/RequestMapper.java @@ -1,8 +1,8 @@ -package br.com.elementasource.mock.generic.api.v1.mapper; +package br.com.elementalsource.mock.generic.api.v1.mapper; -import br.com.elementasource.mock.generic.mapper.HeaderMapper; -import br.com.elementasource.mock.generic.mapper.QueryMapper; -import br.com.elementasource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.mapper.HeaderMapper; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.mapper.QueryMapper; import com.google.gson.Gson; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/generic/mapper/EndpointDto.java b/src/main/java/br/com/elementalsource/mock/generic/mapper/EndpointDto.java similarity index 80% rename from src/main/java/br/com/elementasource/mock/generic/mapper/EndpointDto.java rename to src/main/java/br/com/elementalsource/mock/generic/mapper/EndpointDto.java index b2df748..e55c637 100755 --- a/src/main/java/br/com/elementasource/mock/generic/mapper/EndpointDto.java +++ b/src/main/java/br/com/elementalsource/mock/generic/mapper/EndpointDto.java @@ -1,10 +1,10 @@ -package br.com.elementasource.mock.generic.mapper; +package br.com.elementalsource.mock.generic.mapper; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.generic.model.Response; -import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; -import br.com.elementasource.mock.infra.exception.impl.ApiApplicationException; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.model.Response; +import br.com.elementalsource.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementalsource.mock.infra.exception.impl.ApiApplicationException; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/src/main/java/br/com/elementasource/mock/generic/mapper/EndpointMapper.java b/src/main/java/br/com/elementalsource/mock/generic/mapper/EndpointMapper.java similarity index 87% rename from src/main/java/br/com/elementasource/mock/generic/mapper/EndpointMapper.java rename to src/main/java/br/com/elementalsource/mock/generic/mapper/EndpointMapper.java index 0b5943e..89fbe0e 100755 --- a/src/main/java/br/com/elementasource/mock/generic/mapper/EndpointMapper.java +++ b/src/main/java/br/com/elementalsource/mock/generic/mapper/EndpointMapper.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.generic.mapper; +package br.com.elementalsource.mock.generic.mapper; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.infra.component.file.FileJsonReader; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.infra.component.file.FileJsonReader; import com.google.gson.Gson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/br/com/elementasource/mock/generic/mapper/HeaderMapper.java b/src/main/java/br/com/elementalsource/mock/generic/mapper/HeaderMapper.java similarity index 93% rename from src/main/java/br/com/elementasource/mock/generic/mapper/HeaderMapper.java rename to src/main/java/br/com/elementalsource/mock/generic/mapper/HeaderMapper.java index 7894c66..623548b 100755 --- a/src/main/java/br/com/elementasource/mock/generic/mapper/HeaderMapper.java +++ b/src/main/java/br/com/elementalsource/mock/generic/mapper/HeaderMapper.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.generic.mapper; +package br.com.elementalsource.mock.generic.mapper; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/generic/mapper/QueryMapper.java b/src/main/java/br/com/elementalsource/mock/generic/mapper/QueryMapper.java similarity index 92% rename from src/main/java/br/com/elementasource/mock/generic/mapper/QueryMapper.java rename to src/main/java/br/com/elementalsource/mock/generic/mapper/QueryMapper.java index b374821..a8b05d9 100755 --- a/src/main/java/br/com/elementasource/mock/generic/mapper/QueryMapper.java +++ b/src/main/java/br/com/elementalsource/mock/generic/mapper/QueryMapper.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.generic.mapper; +package br.com.elementalsource.mock.generic.mapper; -import br.com.elementasource.mock.infra.exception.impl.ApiApplicationException; +import br.com.elementalsource.mock.infra.exception.impl.ApiApplicationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/generic/mapper/RequestDto.java b/src/main/java/br/com/elementalsource/mock/generic/mapper/RequestDto.java similarity index 89% rename from src/main/java/br/com/elementasource/mock/generic/mapper/RequestDto.java rename to src/main/java/br/com/elementalsource/mock/generic/mapper/RequestDto.java index a517990..d248f10 100755 --- a/src/main/java/br/com/elementasource/mock/generic/mapper/RequestDto.java +++ b/src/main/java/br/com/elementalsource/mock/generic/mapper/RequestDto.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.generic.mapper; +package br.com.elementalsource.mock.generic.mapper; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.infra.component.FromJsonStringToObjectConverter; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.Gson; diff --git a/src/main/java/br/com/elementasource/mock/generic/mapper/ResponseDto.java b/src/main/java/br/com/elementalsource/mock/generic/mapper/ResponseDto.java similarity index 84% rename from src/main/java/br/com/elementasource/mock/generic/mapper/ResponseDto.java rename to src/main/java/br/com/elementalsource/mock/generic/mapper/ResponseDto.java index 636020a..f250b6b 100755 --- a/src/main/java/br/com/elementasource/mock/generic/mapper/ResponseDto.java +++ b/src/main/java/br/com/elementalsource/mock/generic/mapper/ResponseDto.java @@ -1,8 +1,8 @@ -package br.com.elementasource.mock.generic.mapper; +package br.com.elementalsource.mock.generic.mapper; -import br.com.elementasource.mock.generic.model.Response; -import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; -import br.com.elementasource.mock.infra.exception.impl.ApiApplicationException; +import br.com.elementalsource.mock.generic.model.Response; +import br.com.elementalsource.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementalsource.mock.infra.exception.impl.ApiApplicationException; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.Gson; diff --git a/src/main/java/br/com/elementasource/mock/generic/model/Endpoint.java b/src/main/java/br/com/elementalsource/mock/generic/model/Endpoint.java similarity index 98% rename from src/main/java/br/com/elementasource/mock/generic/model/Endpoint.java rename to src/main/java/br/com/elementalsource/mock/generic/model/Endpoint.java index d821494..f06a96b 100755 --- a/src/main/java/br/com/elementasource/mock/generic/model/Endpoint.java +++ b/src/main/java/br/com/elementalsource/mock/generic/model/Endpoint.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.generic.model; +package br.com.elementalsource.mock.generic.model; import java.util.Map; import java.util.Objects; diff --git a/src/main/java/br/com/elementasource/mock/generic/model/Error.java b/src/main/java/br/com/elementalsource/mock/generic/model/Error.java similarity index 88% rename from src/main/java/br/com/elementasource/mock/generic/model/Error.java rename to src/main/java/br/com/elementalsource/mock/generic/model/Error.java index e5afa1e..1bac436 100755 --- a/src/main/java/br/com/elementasource/mock/generic/model/Error.java +++ b/src/main/java/br/com/elementalsource/mock/generic/model/Error.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.generic.model; +package br.com.elementalsource.mock.generic.model; import java.io.Serializable; diff --git a/src/main/java/br/com/elementasource/mock/generic/model/ExternalApiResult.java b/src/main/java/br/com/elementalsource/mock/generic/model/ExternalApiResult.java similarity index 81% rename from src/main/java/br/com/elementasource/mock/generic/model/ExternalApiResult.java rename to src/main/java/br/com/elementalsource/mock/generic/model/ExternalApiResult.java index 5488cf1..c63b2ce 100644 --- a/src/main/java/br/com/elementasource/mock/generic/model/ExternalApiResult.java +++ b/src/main/java/br/com/elementalsource/mock/generic/model/ExternalApiResult.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.generic.model; +package br.com.elementalsource.mock.generic.model; -import br.com.elementasource.mock.infra.model.UriConfiguration; +import br.com.elementalsource.mock.infra.model.UriConfiguration; import org.springframework.http.ResponseEntity; public class ExternalApiResult { diff --git a/src/main/java/br/com/elementasource/mock/generic/model/Request.java b/src/main/java/br/com/elementalsource/mock/generic/model/Request.java similarity index 94% rename from src/main/java/br/com/elementasource/mock/generic/model/Request.java rename to src/main/java/br/com/elementalsource/mock/generic/model/Request.java index 238a125..e0afc58 100755 --- a/src/main/java/br/com/elementasource/mock/generic/model/Request.java +++ b/src/main/java/br/com/elementalsource/mock/generic/model/Request.java @@ -1,8 +1,8 @@ -package br.com.elementasource.mock.generic.model; +package br.com.elementalsource.mock.generic.model; -import br.com.elementasource.mock.infra.component.ConvertJson; -import br.com.elementasource.mock.infra.component.impl.ConvertJsonImpl; -import br.com.elementasource.mock.infra.exception.impl.JsonApiApplicationException; +import br.com.elementalsource.mock.infra.component.ConvertJson; +import br.com.elementalsource.mock.infra.component.impl.ConvertJsonImpl; +import br.com.elementalsource.mock.infra.exception.impl.JsonApiApplicationException; import org.springframework.http.HttpHeaders; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/src/main/java/br/com/elementasource/mock/generic/model/Response.java b/src/main/java/br/com/elementalsource/mock/generic/model/Response.java similarity index 90% rename from src/main/java/br/com/elementasource/mock/generic/model/Response.java rename to src/main/java/br/com/elementalsource/mock/generic/model/Response.java index cb3fb0f..73ed365 100755 --- a/src/main/java/br/com/elementasource/mock/generic/model/Response.java +++ b/src/main/java/br/com/elementalsource/mock/generic/model/Response.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.generic.model; +package br.com.elementalsource.mock.generic.model; import org.springframework.http.HttpStatus; diff --git a/src/main/java/br/com/elementasource/mock/generic/repository/EndpointRepository.java b/src/main/java/br/com/elementalsource/mock/generic/repository/EndpointRepository.java similarity index 64% rename from src/main/java/br/com/elementasource/mock/generic/repository/EndpointRepository.java rename to src/main/java/br/com/elementalsource/mock/generic/repository/EndpointRepository.java index ca05792..14b7bd2 100755 --- a/src/main/java/br/com/elementasource/mock/generic/repository/EndpointRepository.java +++ b/src/main/java/br/com/elementalsource/mock/generic/repository/EndpointRepository.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.generic.repository; +package br.com.elementalsource.mock.generic.repository; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Request; import org.springframework.web.bind.annotation.RequestMethod; import java.util.Collection; diff --git a/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilter.java b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilter.java new file mode 100755 index 0000000..5e1220f --- /dev/null +++ b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilter.java @@ -0,0 +1,10 @@ +package br.com.elementalsource.mock.generic.repository.impl; + +import br.com.elementalsource.mock.generic.model.Endpoint; + +@FunctionalInterface +interface EndpointFileFilter { + + Boolean apply(Endpoint endpoint, T request); + +} diff --git a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBody.java b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterBody.java similarity index 83% rename from src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBody.java rename to src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterBody.java index fc80f66..92f547c 100755 --- a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBody.java +++ b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterBody.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.generic.repository.impl; +package br.com.elementalsource.mock.generic.repository.impl; -import br.com.elementasource.mock.infra.component.CompareJson; -import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.infra.component.CompareJson; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQuery.java b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterQuery.java similarity index 84% rename from src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQuery.java rename to src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterQuery.java index a4b3968..9ba847c 100755 --- a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQuery.java +++ b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterQuery.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.generic.repository.impl; +package br.com.elementalsource.mock.generic.repository.impl; -import br.com.elementasource.mock.infra.component.CompareMap; -import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.infra.component.CompareMap; +import br.com.elementalsource.mock.generic.model.Endpoint; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterRequest.java b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterRequest.java similarity index 83% rename from src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterRequest.java rename to src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterRequest.java index e4d040b..dc3d867 100755 --- a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterRequest.java +++ b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterRequest.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.generic.repository.impl; +package br.com.elementalsource.mock.generic.repository.impl; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Request; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBackup.java b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryBackup.java similarity index 68% rename from src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBackup.java rename to src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryBackup.java index 39a2e76..70f8d04 100755 --- a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBackup.java +++ b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryBackup.java @@ -1,9 +1,9 @@ -package br.com.elementasource.mock.generic.repository.impl; +package br.com.elementalsource.mock.generic.repository.impl; -import br.com.elementasource.mock.generic.mapper.EndpointMapper; -import br.com.elementasource.mock.generic.repository.EndpointRepository; -import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilder; -import br.com.elementasource.mock.infra.property.FileExtensionProperty; +import br.com.elementalsource.mock.infra.component.file.BaseFileNameBuilder; +import br.com.elementalsource.mock.infra.property.FileExtensionProperty; +import br.com.elementalsource.mock.generic.mapper.EndpointMapper; +import br.com.elementalsource.mock.generic.repository.EndpointRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; diff --git a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBase.java b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryBase.java similarity index 86% rename from src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBase.java rename to src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryBase.java index ce2a504..208da6d 100755 --- a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryBase.java +++ b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryBase.java @@ -1,11 +1,11 @@ -package br.com.elementasource.mock.generic.repository.impl; +package br.com.elementalsource.mock.generic.repository.impl; -import br.com.elementasource.mock.generic.mapper.EndpointMapper; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.generic.repository.EndpointRepository; -import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilder; -import br.com.elementasource.mock.infra.property.FileExtensionProperty; +import br.com.elementalsource.mock.generic.mapper.EndpointMapper; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.repository.EndpointRepository; +import br.com.elementalsource.mock.infra.component.file.BaseFileNameBuilder; +import br.com.elementalsource.mock.infra.property.FileExtensionProperty; import com.google.common.collect.ImmutableList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModel.java b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryModel.java similarity index 68% rename from src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModel.java rename to src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryModel.java index 28cdbb2..e0ae98e 100755 --- a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModel.java +++ b/src/main/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryModel.java @@ -1,9 +1,9 @@ -package br.com.elementasource.mock.generic.repository.impl; +package br.com.elementalsource.mock.generic.repository.impl; -import br.com.elementasource.mock.generic.mapper.EndpointMapper; -import br.com.elementasource.mock.generic.repository.EndpointRepository; -import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilder; -import br.com.elementasource.mock.infra.property.FileExtensionProperty; +import br.com.elementalsource.mock.generic.mapper.EndpointMapper; +import br.com.elementalsource.mock.generic.repository.EndpointRepository; +import br.com.elementalsource.mock.infra.component.file.BaseFileNameBuilder; +import br.com.elementalsource.mock.infra.property.FileExtensionProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; diff --git a/src/main/java/br/com/elementasource/mock/generic/service/EndpointBackupService.java b/src/main/java/br/com/elementalsource/mock/generic/service/EndpointBackupService.java similarity index 53% rename from src/main/java/br/com/elementasource/mock/generic/service/EndpointBackupService.java rename to src/main/java/br/com/elementalsource/mock/generic/service/EndpointBackupService.java index f284797..a118f8e 100755 --- a/src/main/java/br/com/elementasource/mock/generic/service/EndpointBackupService.java +++ b/src/main/java/br/com/elementalsource/mock/generic/service/EndpointBackupService.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.generic.service; +package br.com.elementalsource.mock.generic.service; -import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Endpoint; public interface EndpointBackupService { diff --git a/src/main/java/br/com/elementasource/mock/generic/service/GenericApiService.java b/src/main/java/br/com/elementalsource/mock/generic/service/GenericApiService.java similarity index 80% rename from src/main/java/br/com/elementasource/mock/generic/service/GenericApiService.java rename to src/main/java/br/com/elementalsource/mock/generic/service/GenericApiService.java index 5fb87db..48c5b29 100755 --- a/src/main/java/br/com/elementasource/mock/generic/service/GenericApiService.java +++ b/src/main/java/br/com/elementalsource/mock/generic/service/GenericApiService.java @@ -1,11 +1,11 @@ -package br.com.elementasource.mock.generic.service; +package br.com.elementalsource.mock.generic.service; import java.util.Map; import java.util.Optional; import javax.servlet.http.HttpServletRequest; -import br.com.elementasource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.model.Request; import org.springframework.http.ResponseEntity; public interface GenericApiService { diff --git a/src/main/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFile.java b/src/main/java/br/com/elementalsource/mock/generic/service/impl/EndpointBackupServiceFile.java similarity index 82% rename from src/main/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFile.java rename to src/main/java/br/com/elementalsource/mock/generic/service/impl/EndpointBackupServiceFile.java index 74d848b..8013d49 100755 --- a/src/main/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFile.java +++ b/src/main/java/br/com/elementalsource/mock/generic/service/impl/EndpointBackupServiceFile.java @@ -1,16 +1,16 @@ -package br.com.elementasource.mock.generic.service.impl; +package br.com.elementalsource.mock.generic.service.impl; -import br.com.elementasource.mock.generic.mapper.EndpointDto; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.generic.repository.EndpointRepository; -import br.com.elementasource.mock.generic.service.EndpointBackupService; -import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; -import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilder; -import br.com.elementasource.mock.infra.component.file.FileNameGenerator; -import br.com.elementasource.mock.infra.component.impl.JsonFormatterPretty; -import br.com.elementasource.mock.infra.property.FileExtensionProperty; -import br.com.elementasource.mock.infra.property.FileProperty; +import br.com.elementalsource.mock.generic.mapper.EndpointDto; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.infra.component.file.BaseFileNameBuilder; +import br.com.elementalsource.mock.infra.component.file.FileNameGenerator; +import br.com.elementalsource.mock.infra.component.impl.JsonFormatterPretty; +import br.com.elementalsource.mock.infra.property.FileExtensionProperty; +import br.com.elementalsource.mock.generic.repository.EndpointRepository; +import br.com.elementalsource.mock.generic.service.EndpointBackupService; +import br.com.elementalsource.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementalsource.mock.infra.property.FileProperty; import com.google.gson.Gson; import java.nio.charset.Charset; import java.util.Arrays; diff --git a/src/main/java/br/com/elementasource/mock/generic/service/impl/GenericApiServiceImpl.java b/src/main/java/br/com/elementalsource/mock/generic/service/impl/GenericApiServiceImpl.java similarity index 89% rename from src/main/java/br/com/elementasource/mock/generic/service/impl/GenericApiServiceImpl.java rename to src/main/java/br/com/elementalsource/mock/generic/service/impl/GenericApiServiceImpl.java index 7c2ad95..5c99a17 100755 --- a/src/main/java/br/com/elementasource/mock/generic/service/impl/GenericApiServiceImpl.java +++ b/src/main/java/br/com/elementalsource/mock/generic/service/impl/GenericApiServiceImpl.java @@ -1,13 +1,13 @@ -package br.com.elementasource.mock.generic.service.impl; - -import br.com.elementasource.mock.configuration.service.CaptureExecutor; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.generic.repository.EndpointRepository; -import br.com.elementasource.mock.generic.service.GenericApiService; -import br.com.elementasource.mock.infra.component.ExternalApi; -import br.com.elementasource.mock.infra.component.JsonValueCompiler; -import br.com.elementasource.mock.infra.property.ApiProperty; +package br.com.elementalsource.mock.generic.service.impl; + +import br.com.elementalsource.mock.configuration.service.CaptureExecutor; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.infra.component.ExternalApi; +import br.com.elementalsource.mock.infra.component.JsonValueCompiler; +import br.com.elementalsource.mock.infra.property.ApiProperty; +import br.com.elementalsource.mock.generic.repository.EndpointRepository; +import br.com.elementalsource.mock.generic.service.GenericApiService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/CompareJson.java b/src/main/java/br/com/elementalsource/mock/infra/component/CompareJson.java similarity index 95% rename from src/main/java/br/com/elementasource/mock/infra/component/CompareJson.java rename to src/main/java/br/com/elementalsource/mock/infra/component/CompareJson.java index e57e05a..e356190 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/CompareJson.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/CompareJson.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/CompareMap.java b/src/main/java/br/com/elementalsource/mock/infra/component/CompareMap.java similarity index 91% rename from src/main/java/br/com/elementasource/mock/infra/component/CompareMap.java rename to src/main/java/br/com/elementalsource/mock/infra/component/CompareMap.java index 9caef24..ef1aa46 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/CompareMap.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/CompareMap.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/ConvertJson.java b/src/main/java/br/com/elementalsource/mock/infra/component/ConvertJson.java similarity index 71% rename from src/main/java/br/com/elementasource/mock/infra/component/ConvertJson.java rename to src/main/java/br/com/elementalsource/mock/infra/component/ConvertJson.java index 6d36e96..b2df8c2 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/ConvertJson.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/ConvertJson.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; import java.util.HashMap; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/ExternalApi.java b/src/main/java/br/com/elementalsource/mock/infra/component/ExternalApi.java similarity index 91% rename from src/main/java/br/com/elementasource/mock/infra/component/ExternalApi.java rename to src/main/java/br/com/elementalsource/mock/infra/component/ExternalApi.java index baf4311..d669ac9 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/ExternalApi.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/ExternalApi.java @@ -1,11 +1,11 @@ -package br.com.elementasource.mock.infra.component; - -import br.com.elementasource.mock.configuration.model.CaptureState; -import br.com.elementasource.mock.configuration.repository.CaptureStateRepository; -import br.com.elementasource.mock.generic.model.ExternalApiResult; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.infra.model.UriConfiguration; -import br.com.elementasource.mock.infra.property.ApiProperty; +package br.com.elementalsource.mock.infra.component; + +import br.com.elementalsource.mock.configuration.model.CaptureState; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.configuration.repository.CaptureStateRepository; +import br.com.elementalsource.mock.generic.model.ExternalApiResult; +import br.com.elementalsource.mock.infra.model.UriConfiguration; +import br.com.elementalsource.mock.infra.property.ApiProperty; import okhttp3.Headers; import okhttp3.OkHttpClient; import okhttp3.Response; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/FromJsonStringToObjectConverter.java b/src/main/java/br/com/elementalsource/mock/infra/component/FromJsonStringToObjectConverter.java similarity index 78% rename from src/main/java/br/com/elementasource/mock/infra/component/FromJsonStringToObjectConverter.java rename to src/main/java/br/com/elementalsource/mock/infra/component/FromJsonStringToObjectConverter.java index 427f1ee..b8a7303 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/FromJsonStringToObjectConverter.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/FromJsonStringToObjectConverter.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; import com.google.gson.JsonElement; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/HeaderFilter.java b/src/main/java/br/com/elementalsource/mock/infra/component/HeaderFilter.java similarity index 92% rename from src/main/java/br/com/elementasource/mock/infra/component/HeaderFilter.java rename to src/main/java/br/com/elementalsource/mock/infra/component/HeaderFilter.java index 3e074fe..4af786a 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/HeaderFilter.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/HeaderFilter.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; -import br.com.elementasource.mock.infra.property.ApiProperty; +import br.com.elementalsource.mock.infra.property.ApiProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/JsonFormatter.java b/src/main/java/br/com/elementalsource/mock/infra/component/JsonFormatter.java similarity index 60% rename from src/main/java/br/com/elementasource/mock/infra/component/JsonFormatter.java rename to src/main/java/br/com/elementalsource/mock/infra/component/JsonFormatter.java index ff896ee..bee5be6 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/JsonFormatter.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/JsonFormatter.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; public interface JsonFormatter { diff --git a/src/main/java/br/com/elementasource/mock/infra/component/JsonValueCompiler.java b/src/main/java/br/com/elementalsource/mock/infra/component/JsonValueCompiler.java similarity index 65% rename from src/main/java/br/com/elementasource/mock/infra/component/JsonValueCompiler.java rename to src/main/java/br/com/elementalsource/mock/infra/component/JsonValueCompiler.java index 7ef0893..56a7396 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/JsonValueCompiler.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/JsonValueCompiler.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; @FunctionalInterface public interface JsonValueCompiler { diff --git a/src/main/java/br/com/elementasource/mock/infra/component/QueryStringBuilder.java b/src/main/java/br/com/elementalsource/mock/infra/component/QueryStringBuilder.java similarity index 68% rename from src/main/java/br/com/elementasource/mock/infra/component/QueryStringBuilder.java rename to src/main/java/br/com/elementalsource/mock/infra/component/QueryStringBuilder.java index 452c9fb..e3abbbe 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/QueryStringBuilder.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/QueryStringBuilder.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; import java.util.Map; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/RequestFormatter.java b/src/main/java/br/com/elementalsource/mock/infra/component/RequestFormatter.java similarity index 79% rename from src/main/java/br/com/elementasource/mock/infra/component/RequestFormatter.java rename to src/main/java/br/com/elementalsource/mock/infra/component/RequestFormatter.java index 131e7ba..c76c1a1 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/RequestFormatter.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/RequestFormatter.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; import javax.servlet.http.HttpServletRequest; import java.util.Optional; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilder.java b/src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilder.java similarity index 81% rename from src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilder.java rename to src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilder.java index 59b7382..d92e280 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilder.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilder.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component.file; +package br.com.elementalsource.mock.infra.component.file; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBackup.java b/src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderBackup.java similarity index 79% rename from src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBackup.java rename to src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderBackup.java index ca2e1a5..b9e97f6 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBackup.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderBackup.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component.file; +package br.com.elementalsource.mock.infra.component.file; -import br.com.elementasource.mock.infra.property.FileProperty; +import br.com.elementalsource.mock.infra.property.FileProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBase.java b/src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderBase.java similarity index 86% rename from src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBase.java rename to src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderBase.java index 34d4278..308a285 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderBase.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderBase.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component.file; +package br.com.elementalsource.mock.infra.component.file; -import br.com.elementasource.mock.infra.property.FileProperty; +import br.com.elementalsource.mock.infra.property.FileProperty; import org.springframework.web.bind.annotation.RequestMethod; public class BaseFileNameBuilderBase implements BaseFileNameBuilder { diff --git a/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModel.java b/src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderModel.java similarity index 79% rename from src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModel.java rename to src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderModel.java index d000a56..d472935 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModel.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderModel.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component.file; +package br.com.elementalsource.mock.infra.component.file; -import br.com.elementasource.mock.infra.property.FileProperty; +import br.com.elementalsource.mock.infra.property.FileProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/file/FileJsonReader.java b/src/main/java/br/com/elementalsource/mock/infra/component/file/FileJsonReader.java similarity index 94% rename from src/main/java/br/com/elementasource/mock/infra/component/file/FileJsonReader.java rename to src/main/java/br/com/elementalsource/mock/infra/component/file/FileJsonReader.java index 30c9099..b083cf6 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/file/FileJsonReader.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/file/FileJsonReader.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component.file; +package br.com.elementalsource.mock.infra.component.file; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGenerator.java b/src/main/java/br/com/elementalsource/mock/infra/component/file/FileNameGenerator.java similarity index 58% rename from src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGenerator.java rename to src/main/java/br/com/elementalsource/mock/infra/component/file/FileNameGenerator.java index f50be83..d7363bb 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGenerator.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/file/FileNameGenerator.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component.file; +package br.com.elementalsource.mock.infra.component.file; public interface FileNameGenerator { diff --git a/src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImpl.java b/src/main/java/br/com/elementalsource/mock/infra/component/file/FileNameGeneratorImpl.java similarity index 90% rename from src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImpl.java rename to src/main/java/br/com/elementalsource/mock/infra/component/file/FileNameGeneratorImpl.java index 370179c..5595ad6 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImpl.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/file/FileNameGeneratorImpl.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component.file; +package br.com.elementalsource.mock.infra.component.file; -import br.com.elementasource.mock.infra.property.FileExtensionProperty; +import br.com.elementalsource.mock.infra.property.FileExtensionProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImpl.java b/src/main/java/br/com/elementalsource/mock/infra/component/impl/ConvertJsonImpl.java similarity index 78% rename from src/main/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImpl.java rename to src/main/java/br/com/elementalsource/mock/infra/component/impl/ConvertJsonImpl.java index a489dc7..d8f95a0 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImpl.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/impl/ConvertJsonImpl.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.infra.component.impl; +package br.com.elementalsource.mock.infra.component.impl; -import br.com.elementasource.mock.infra.component.ConvertJson; -import br.com.elementasource.mock.infra.exception.impl.JsonApiApplicationException; +import br.com.elementalsource.mock.infra.component.ConvertJson; +import br.com.elementalsource.mock.infra.exception.impl.JsonApiApplicationException; import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java b/src/main/java/br/com/elementalsource/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java similarity index 84% rename from src/main/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java rename to src/main/java/br/com/elementalsource/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java index ed42621..0fc653b 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/impl/FromJsonStringToObjectConverterImpl.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component.impl; +package br.com.elementalsource.mock.infra.component.impl; -import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementalsource.mock.infra.component.FromJsonStringToObjectConverter; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPretty.java b/src/main/java/br/com/elementalsource/mock/infra/component/impl/JsonFormatterPretty.java similarity index 81% rename from src/main/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPretty.java rename to src/main/java/br/com/elementalsource/mock/infra/component/impl/JsonFormatterPretty.java index 4853a9a..d939a54 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPretty.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/impl/JsonFormatterPretty.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component.impl; +package br.com.elementalsource.mock.infra.component.impl; -import br.com.elementasource.mock.infra.component.JsonFormatter; +import br.com.elementalsource.mock.infra.component.JsonFormatter; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImpl.java b/src/main/java/br/com/elementalsource/mock/infra/component/impl/JsonValueCompilerImpl.java similarity index 88% rename from src/main/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImpl.java rename to src/main/java/br/com/elementalsource/mock/infra/component/impl/JsonValueCompilerImpl.java index 5e3c48a..2aeb25a 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImpl.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/impl/JsonValueCompilerImpl.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component.impl; +package br.com.elementalsource.mock.infra.component.impl; -import br.com.elementasource.mock.infra.component.JsonValueCompiler; +import br.com.elementalsource.mock.infra.component.JsonValueCompiler; import org.springframework.stereotype.Component; import java.time.LocalDate; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImpl.java b/src/main/java/br/com/elementalsource/mock/infra/component/impl/QueryStringBuilderImpl.java similarity index 79% rename from src/main/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImpl.java rename to src/main/java/br/com/elementalsource/mock/infra/component/impl/QueryStringBuilderImpl.java index b03bf53..51c38fe 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImpl.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/impl/QueryStringBuilderImpl.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.infra.component.impl; +package br.com.elementalsource.mock.infra.component.impl; -import br.com.elementasource.mock.infra.component.ConvertJson; -import br.com.elementasource.mock.infra.component.QueryStringBuilder; +import br.com.elementalsource.mock.infra.component.ConvertJson; +import br.com.elementalsource.mock.infra.component.QueryStringBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/infra/component/impl/RequestFormatterImpl.java b/src/main/java/br/com/elementalsource/mock/infra/component/impl/RequestFormatterImpl.java similarity index 82% rename from src/main/java/br/com/elementasource/mock/infra/component/impl/RequestFormatterImpl.java rename to src/main/java/br/com/elementalsource/mock/infra/component/impl/RequestFormatterImpl.java index 477bbc0..9b7542b 100755 --- a/src/main/java/br/com/elementasource/mock/infra/component/impl/RequestFormatterImpl.java +++ b/src/main/java/br/com/elementalsource/mock/infra/component/impl/RequestFormatterImpl.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component.impl; +package br.com.elementalsource.mock.infra.component.impl; -import br.com.elementasource.mock.infra.component.RequestFormatter; +import br.com.elementalsource.mock.infra.component.RequestFormatter; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; diff --git a/src/main/java/br/com/elementasource/mock/infra/controller/ShutdownController.java b/src/main/java/br/com/elementalsource/mock/infra/controller/ShutdownController.java similarity index 92% rename from src/main/java/br/com/elementasource/mock/infra/controller/ShutdownController.java rename to src/main/java/br/com/elementalsource/mock/infra/controller/ShutdownController.java index 1d02211..cdacdad 100644 --- a/src/main/java/br/com/elementasource/mock/infra/controller/ShutdownController.java +++ b/src/main/java/br/com/elementalsource/mock/infra/controller/ShutdownController.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.controller; +package br.com.elementalsource.mock.infra.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; diff --git a/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationException.java b/src/main/java/br/com/elementalsource/mock/infra/exception/ApplicationException.java similarity index 68% rename from src/main/java/br/com/elementasource/mock/infra/exception/ApplicationException.java rename to src/main/java/br/com/elementalsource/mock/infra/exception/ApplicationException.java index 6fb4060..5f6b11e 100755 --- a/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationException.java +++ b/src/main/java/br/com/elementalsource/mock/infra/exception/ApplicationException.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.exception; +package br.com.elementalsource.mock.infra.exception; public interface ApplicationException { diff --git a/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionHandler.java b/src/main/java/br/com/elementalsource/mock/infra/exception/ApplicationExceptionHandler.java similarity index 87% rename from src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionHandler.java rename to src/main/java/br/com/elementalsource/mock/infra/exception/ApplicationExceptionHandler.java index c450412..70eabb7 100755 --- a/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionHandler.java +++ b/src/main/java/br/com/elementalsource/mock/infra/exception/ApplicationExceptionHandler.java @@ -1,9 +1,9 @@ -package br.com.elementasource.mock.infra.exception; +package br.com.elementalsource.mock.infra.exception; -import br.com.elementasource.mock.infra.exception.impl.ApiApplicationException; -import br.com.elementasource.mock.infra.exception.impl.ApplicationExceptionImpl; -import br.com.elementasource.mock.infra.exception.impl.ApplicationExceptionMessageImpl; -import br.com.elementasource.mock.infra.exception.impl.ErrorApplicationException; +import br.com.elementalsource.mock.infra.exception.impl.ApiApplicationException; +import br.com.elementalsource.mock.infra.exception.impl.ApplicationExceptionImpl; +import br.com.elementalsource.mock.infra.exception.impl.ApplicationExceptionMessageImpl; +import br.com.elementalsource.mock.infra.exception.impl.ErrorApplicationException; import com.google.gson.Gson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionMessage.java b/src/main/java/br/com/elementalsource/mock/infra/exception/ApplicationExceptionMessage.java similarity index 66% rename from src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionMessage.java rename to src/main/java/br/com/elementalsource/mock/infra/exception/ApplicationExceptionMessage.java index f6649a2..8208861 100755 --- a/src/main/java/br/com/elementasource/mock/infra/exception/ApplicationExceptionMessage.java +++ b/src/main/java/br/com/elementalsource/mock/infra/exception/ApplicationExceptionMessage.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.exception; +package br.com.elementalsource.mock.infra.exception; public interface ApplicationExceptionMessage { diff --git a/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApiApplicationException.java b/src/main/java/br/com/elementalsource/mock/infra/exception/impl/ApiApplicationException.java similarity index 71% rename from src/main/java/br/com/elementasource/mock/infra/exception/impl/ApiApplicationException.java rename to src/main/java/br/com/elementalsource/mock/infra/exception/impl/ApiApplicationException.java index 4be1db8..b6a0a68 100755 --- a/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApiApplicationException.java +++ b/src/main/java/br/com/elementalsource/mock/infra/exception/impl/ApiApplicationException.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.exception.impl; +package br.com.elementalsource.mock.infra.exception.impl; -import br.com.elementasource.mock.infra.exception.ApplicationException; +import br.com.elementalsource.mock.infra.exception.ApplicationException; import org.springframework.http.HttpStatus; public class ApiApplicationException extends ApplicationExceptionImpl implements ApplicationException { diff --git a/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionImpl.java b/src/main/java/br/com/elementalsource/mock/infra/exception/impl/ApplicationExceptionImpl.java similarity index 67% rename from src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionImpl.java rename to src/main/java/br/com/elementalsource/mock/infra/exception/impl/ApplicationExceptionImpl.java index 89b1352..9b807d9 100755 --- a/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionImpl.java +++ b/src/main/java/br/com/elementalsource/mock/infra/exception/impl/ApplicationExceptionImpl.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.infra.exception.impl; +package br.com.elementalsource.mock.infra.exception.impl; -import br.com.elementasource.mock.infra.exception.ApplicationException; -import br.com.elementasource.mock.infra.exception.ApplicationExceptionMessage; +import br.com.elementalsource.mock.infra.exception.ApplicationException; +import br.com.elementalsource.mock.infra.exception.ApplicationExceptionMessage; public class ApplicationExceptionImpl extends RuntimeException implements ApplicationException { diff --git a/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java b/src/main/java/br/com/elementalsource/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java similarity index 78% rename from src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java rename to src/main/java/br/com/elementalsource/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java index 5ddafc7..1c6398f 100755 --- a/src/main/java/br/com/elementasource/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java +++ b/src/main/java/br/com/elementalsource/mock/infra/exception/impl/ApplicationExceptionMessageImpl.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.exception.impl; +package br.com.elementalsource.mock.infra.exception.impl; -import br.com.elementasource.mock.infra.exception.ApplicationExceptionMessage; +import br.com.elementalsource.mock.infra.exception.ApplicationExceptionMessage; import java.io.Serializable; diff --git a/src/main/java/br/com/elementasource/mock/infra/exception/impl/ErrorApplicationException.java b/src/main/java/br/com/elementalsource/mock/infra/exception/impl/ErrorApplicationException.java similarity index 62% rename from src/main/java/br/com/elementasource/mock/infra/exception/impl/ErrorApplicationException.java rename to src/main/java/br/com/elementalsource/mock/infra/exception/impl/ErrorApplicationException.java index 6d55439..b0df8f0 100755 --- a/src/main/java/br/com/elementasource/mock/infra/exception/impl/ErrorApplicationException.java +++ b/src/main/java/br/com/elementalsource/mock/infra/exception/impl/ErrorApplicationException.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.exception.impl; +package br.com.elementalsource.mock.infra.exception.impl; -import br.com.elementasource.mock.infra.exception.ApplicationException; +import br.com.elementalsource.mock.infra.exception.ApplicationException; public class ErrorApplicationException extends ApplicationExceptionImpl implements ApplicationException { diff --git a/src/main/java/br/com/elementasource/mock/infra/exception/impl/JsonApiApplicationException.java b/src/main/java/br/com/elementalsource/mock/infra/exception/impl/JsonApiApplicationException.java similarity index 73% rename from src/main/java/br/com/elementasource/mock/infra/exception/impl/JsonApiApplicationException.java rename to src/main/java/br/com/elementalsource/mock/infra/exception/impl/JsonApiApplicationException.java index 16853ce..b523071 100755 --- a/src/main/java/br/com/elementasource/mock/infra/exception/impl/JsonApiApplicationException.java +++ b/src/main/java/br/com/elementalsource/mock/infra/exception/impl/JsonApiApplicationException.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.exception.impl; +package br.com.elementalsource.mock.infra.exception.impl; -import br.com.elementasource.mock.infra.exception.ApplicationException; +import br.com.elementalsource.mock.infra.exception.ApplicationException; import org.springframework.http.HttpStatus; public class JsonApiApplicationException extends ApplicationExceptionImpl implements ApplicationException { diff --git a/src/main/java/br/com/elementasource/mock/infra/model/DefaultHeader.java b/src/main/java/br/com/elementalsource/mock/infra/model/DefaultHeader.java similarity index 96% rename from src/main/java/br/com/elementasource/mock/infra/model/DefaultHeader.java rename to src/main/java/br/com/elementalsource/mock/infra/model/DefaultHeader.java index 4c76709..26bc498 100644 --- a/src/main/java/br/com/elementasource/mock/infra/model/DefaultHeader.java +++ b/src/main/java/br/com/elementalsource/mock/infra/model/DefaultHeader.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.model; +package br.com.elementalsource.mock.infra.model; import java.io.Serializable; import java.util.List; diff --git a/src/main/java/br/com/elementasource/mock/infra/model/UriConfiguration.java b/src/main/java/br/com/elementalsource/mock/infra/model/UriConfiguration.java similarity index 97% rename from src/main/java/br/com/elementasource/mock/infra/model/UriConfiguration.java rename to src/main/java/br/com/elementalsource/mock/infra/model/UriConfiguration.java index f079867..3a7f19f 100644 --- a/src/main/java/br/com/elementasource/mock/infra/model/UriConfiguration.java +++ b/src/main/java/br/com/elementalsource/mock/infra/model/UriConfiguration.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.model; +package br.com.elementalsource.mock.infra.model; import java.io.Serializable; import java.util.Objects; diff --git a/src/main/java/br/com/elementasource/mock/infra/property/ApiProperty.java b/src/main/java/br/com/elementalsource/mock/infra/property/ApiProperty.java similarity index 91% rename from src/main/java/br/com/elementasource/mock/infra/property/ApiProperty.java rename to src/main/java/br/com/elementalsource/mock/infra/property/ApiProperty.java index a3abb35..2c2d201 100755 --- a/src/main/java/br/com/elementasource/mock/infra/property/ApiProperty.java +++ b/src/main/java/br/com/elementalsource/mock/infra/property/ApiProperty.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.infra.property; +package br.com.elementalsource.mock.infra.property; -import br.com.elementasource.mock.infra.model.DefaultHeader; -import br.com.elementasource.mock.infra.model.UriConfiguration; +import br.com.elementalsource.mock.infra.model.DefaultHeader; +import br.com.elementalsource.mock.infra.model.UriConfiguration; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/infra/property/FileExtensionProperty.java b/src/main/java/br/com/elementalsource/mock/infra/property/FileExtensionProperty.java similarity index 59% rename from src/main/java/br/com/elementasource/mock/infra/property/FileExtensionProperty.java rename to src/main/java/br/com/elementalsource/mock/infra/property/FileExtensionProperty.java index 31c5dc2..cd59a3e 100755 --- a/src/main/java/br/com/elementasource/mock/infra/property/FileExtensionProperty.java +++ b/src/main/java/br/com/elementalsource/mock/infra/property/FileExtensionProperty.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.property; +package br.com.elementalsource.mock.infra.property; public interface FileExtensionProperty { diff --git a/src/main/java/br/com/elementasource/mock/infra/property/FileProperty.java b/src/main/java/br/com/elementalsource/mock/infra/property/FileProperty.java similarity index 54% rename from src/main/java/br/com/elementasource/mock/infra/property/FileProperty.java rename to src/main/java/br/com/elementalsource/mock/infra/property/FileProperty.java index 6fbcf46..8eb75df 100755 --- a/src/main/java/br/com/elementasource/mock/infra/property/FileProperty.java +++ b/src/main/java/br/com/elementalsource/mock/infra/property/FileProperty.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.property; +package br.com.elementalsource.mock.infra.property; public interface FileProperty { diff --git a/src/main/java/br/com/elementasource/mock/infra/property/impl/FileExtensionPropertyImpl.java b/src/main/java/br/com/elementalsource/mock/infra/property/impl/FileExtensionPropertyImpl.java similarity index 77% rename from src/main/java/br/com/elementasource/mock/infra/property/impl/FileExtensionPropertyImpl.java rename to src/main/java/br/com/elementalsource/mock/infra/property/impl/FileExtensionPropertyImpl.java index 0dbbc1f..1932499 100755 --- a/src/main/java/br/com/elementasource/mock/infra/property/impl/FileExtensionPropertyImpl.java +++ b/src/main/java/br/com/elementalsource/mock/infra/property/impl/FileExtensionPropertyImpl.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.property.impl; +package br.com.elementalsource.mock.infra.property.impl; -import br.com.elementasource.mock.infra.property.FileExtensionProperty; +import br.com.elementalsource.mock.infra.property.FileExtensionProperty; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyBackup.java b/src/main/java/br/com/elementalsource/mock/infra/property/impl/FilePropertyBackup.java similarity index 77% rename from src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyBackup.java rename to src/main/java/br/com/elementalsource/mock/infra/property/impl/FilePropertyBackup.java index 913f88a..33aad82 100755 --- a/src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyBackup.java +++ b/src/main/java/br/com/elementalsource/mock/infra/property/impl/FilePropertyBackup.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.property.impl; +package br.com.elementalsource.mock.infra.property.impl; -import br.com.elementasource.mock.infra.property.FileProperty; +import br.com.elementalsource.mock.infra.property.FileProperty; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyModel.java b/src/main/java/br/com/elementalsource/mock/infra/property/impl/FilePropertyModel.java similarity index 77% rename from src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyModel.java rename to src/main/java/br/com/elementalsource/mock/infra/property/impl/FilePropertyModel.java index 402f146..d34f8ed 100755 --- a/src/main/java/br/com/elementasource/mock/infra/property/impl/FilePropertyModel.java +++ b/src/main/java/br/com/elementalsource/mock/infra/property/impl/FilePropertyModel.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.property.impl; +package br.com.elementalsource.mock.infra.property.impl; -import br.com.elementasource.mock.infra.property.FileProperty; +import br.com.elementalsource.mock.infra.property.FileProperty; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/src/main/java/br/com/elementasource/mock/configuration/service/CaptureExecutor.java b/src/main/java/br/com/elementasource/mock/configuration/service/CaptureExecutor.java deleted file mode 100755 index dbfc427..0000000 --- a/src/main/java/br/com/elementasource/mock/configuration/service/CaptureExecutor.java +++ /dev/null @@ -1,11 +0,0 @@ -package br.com.elementasource.mock.configuration.service; - -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.ExternalApiResult; - -@FunctionalInterface -public interface CaptureExecutor { - - void execute(ExternalApiResult apiResult, Endpoint endpoint); - -} diff --git a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilter.java b/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilter.java deleted file mode 100755 index 3ae0e9a..0000000 --- a/src/main/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilter.java +++ /dev/null @@ -1,10 +0,0 @@ -package br.com.elementasource.mock.generic.repository.impl; - -import br.com.elementasource.mock.generic.model.Endpoint; - -@FunctionalInterface -interface EndpointFileFilter { - - Boolean apply(Endpoint endpoint, T request); - -} diff --git a/src/test/java/br/com/elementasource/mock/ApiApplicationTests.java b/src/test/java/br/com/elementalsource/mock/ApiApplicationTests.java similarity index 89% rename from src/test/java/br/com/elementasource/mock/ApiApplicationTests.java rename to src/test/java/br/com/elementalsource/mock/ApiApplicationTests.java index 133dcfd..6b7f78e 100755 --- a/src/test/java/br/com/elementasource/mock/ApiApplicationTests.java +++ b/src/test/java/br/com/elementalsource/mock/ApiApplicationTests.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock; +package br.com.elementalsource.mock; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java b/src/test/java/br/com/elementalsource/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java similarity index 91% rename from src/test/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java rename to src/test/java/br/com/elementalsource/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java index 03f669d..62e353e 100755 --- a/src/test/java/br/com/elementasource/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java +++ b/src/test/java/br/com/elementalsource/mock/configuration/api/v1/controller/CaptureStateControllerIntegrationTest.java @@ -1,8 +1,8 @@ -package br.com.elementasource.mock.configuration.api.v1.controller; +package br.com.elementalsource.mock.configuration.api.v1.controller; -import br.com.elementasource.mock.configuration.api.v1.mapper.CaptureStateDto; -import br.com.elementasource.mock.configuration.model.CaptureState; -import br.com.elementasource.mock.configuration.service.CaptureStateService; +import br.com.elementalsource.mock.configuration.model.CaptureState; +import br.com.elementalsource.mock.configuration.api.v1.mapper.CaptureStateDto; +import br.com.elementalsource.mock.configuration.service.CaptureStateService; import com.google.gson.Gson; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java b/src/test/java/br/com/elementalsource/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java similarity index 96% rename from src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java rename to src/test/java/br/com/elementalsource/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java index e6819ff..ce2dd68 100755 --- a/src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/api/v1/controller/GenericApiControllerExternalIntegrationTest.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.generic.api.v1.controller; +package br.com.elementalsource.mock.generic.api.v1.controller; -import br.com.elementasource.mock.generic.mapper.EndpointDto; +import br.com.elementalsource.mock.generic.mapper.EndpointDto; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import org.json.JSONException; diff --git a/src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java b/src/test/java/br/com/elementalsource/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java similarity index 97% rename from src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java rename to src/test/java/br/com/elementalsource/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java index 14fad02..3a9f406 100755 --- a/src/test/java/br/com/elementasource/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/api/v1/controller/GenericApiControllerIntegrationTest.java @@ -1,8 +1,8 @@ -package br.com.elementasource.mock.generic.api.v1.controller; +package br.com.elementalsource.mock.generic.api.v1.controller; -import br.com.elementasource.mock.infra.component.QueryStringBuilder; -import br.com.elementasource.mock.generic.mapper.EndpointDto; -import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.mapper.EndpointDto; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.infra.component.QueryStringBuilder; import com.google.gson.Gson; import org.json.JSONException; import org.junit.Before; diff --git a/src/test/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapperTest.java b/src/test/java/br/com/elementalsource/mock/generic/api/v1/mapper/RequestMapperTest.java similarity index 95% rename from src/test/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapperTest.java rename to src/test/java/br/com/elementalsource/mock/generic/api/v1/mapper/RequestMapperTest.java index e730a03..af7cca8 100755 --- a/src/test/java/br/com/elementasource/mock/generic/api/v1/mapper/RequestMapperTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/api/v1/mapper/RequestMapperTest.java @@ -1,8 +1,8 @@ -package br.com.elementasource.mock.generic.api.v1.mapper; +package br.com.elementalsource.mock.generic.api.v1.mapper; -import br.com.elementasource.mock.generic.mapper.HeaderMapper; -import br.com.elementasource.mock.generic.mapper.QueryMapper; -import br.com.elementasource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.mapper.HeaderMapper; +import br.com.elementalsource.mock.generic.mapper.QueryMapper; import com.google.common.collect.ImmutableMap; import org.json.JSONException; import org.junit.Test; diff --git a/src/test/java/br/com/elementasource/mock/generic/mapper/EndpointDtoTest.java b/src/test/java/br/com/elementalsource/mock/generic/mapper/EndpointDtoTest.java similarity index 94% rename from src/test/java/br/com/elementasource/mock/generic/mapper/EndpointDtoTest.java rename to src/test/java/br/com/elementalsource/mock/generic/mapper/EndpointDtoTest.java index 86ff99d..1f0c4c4 100755 --- a/src/test/java/br/com/elementasource/mock/generic/mapper/EndpointDtoTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/mapper/EndpointDtoTest.java @@ -1,8 +1,8 @@ -package br.com.elementasource.mock.generic.mapper; +package br.com.elementalsource.mock.generic.mapper; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.template.EndpointTemplate; -import br.com.elementasource.mock.infra.component.impl.FromJsonStringToObjectConverterImpl; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.infra.component.impl.FromJsonStringToObjectConverterImpl; +import br.com.elementalsource.mock.generic.model.template.EndpointTemplate; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import com.google.gson.Gson; @@ -18,7 +18,7 @@ public class EndpointDtoTest { @BeforeClass public static void initClass() { - FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + FixtureFactoryLoader.loadTemplates("br.com.elementalsource.mock.generic.model.template"); } @Test diff --git a/src/test/java/br/com/elementasource/mock/generic/mapper/EndpointMapperTest.java b/src/test/java/br/com/elementalsource/mock/generic/mapper/EndpointMapperTest.java similarity index 91% rename from src/test/java/br/com/elementasource/mock/generic/mapper/EndpointMapperTest.java rename to src/test/java/br/com/elementalsource/mock/generic/mapper/EndpointMapperTest.java index 2388717..c61a1a8 100755 --- a/src/test/java/br/com/elementasource/mock/generic/mapper/EndpointMapperTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/mapper/EndpointMapperTest.java @@ -1,7 +1,7 @@ -package br.com.elementasource.mock.generic.mapper; +package br.com.elementalsource.mock.generic.mapper; -import br.com.elementasource.mock.infra.component.file.FileJsonReader; -import br.com.elementasource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.infra.component.file.FileJsonReader; +import br.com.elementalsource.mock.generic.model.Endpoint; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/elementasource/mock/generic/mapper/HeaderMapperTest.java b/src/test/java/br/com/elementalsource/mock/generic/mapper/HeaderMapperTest.java similarity index 95% rename from src/test/java/br/com/elementasource/mock/generic/mapper/HeaderMapperTest.java rename to src/test/java/br/com/elementalsource/mock/generic/mapper/HeaderMapperTest.java index 3823f58..af16b73 100755 --- a/src/test/java/br/com/elementasource/mock/generic/mapper/HeaderMapperTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/mapper/HeaderMapperTest.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.generic.mapper; +package br.com.elementalsource.mock.generic.mapper; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/elementasource/mock/generic/mapper/QueryMapperTest.java b/src/test/java/br/com/elementalsource/mock/generic/mapper/QueryMapperTest.java similarity index 97% rename from src/test/java/br/com/elementasource/mock/generic/mapper/QueryMapperTest.java rename to src/test/java/br/com/elementalsource/mock/generic/mapper/QueryMapperTest.java index a23aee2..3e4c2b1 100755 --- a/src/test/java/br/com/elementasource/mock/generic/mapper/QueryMapperTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/mapper/QueryMapperTest.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.generic.mapper; +package br.com.elementalsource.mock.generic.mapper; import com.google.common.collect.ImmutableMap; import org.junit.Test; diff --git a/src/test/java/br/com/elementasource/mock/generic/mapper/ResponseDtoTest.java b/src/test/java/br/com/elementalsource/mock/generic/mapper/ResponseDtoTest.java similarity index 87% rename from src/test/java/br/com/elementasource/mock/generic/mapper/ResponseDtoTest.java rename to src/test/java/br/com/elementalsource/mock/generic/mapper/ResponseDtoTest.java index 30a3b17..7d27423 100755 --- a/src/test/java/br/com/elementasource/mock/generic/mapper/ResponseDtoTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/mapper/ResponseDtoTest.java @@ -1,8 +1,8 @@ -package br.com.elementasource.mock.generic.mapper; +package br.com.elementalsource.mock.generic.mapper; -import br.com.elementasource.mock.generic.model.Response; -import br.com.elementasource.mock.generic.model.template.ResponseTemplate; -import br.com.elementasource.mock.infra.component.impl.FromJsonStringToObjectConverterImpl; +import br.com.elementalsource.mock.generic.model.template.ResponseTemplate; +import br.com.elementalsource.mock.infra.component.impl.FromJsonStringToObjectConverterImpl; +import br.com.elementalsource.mock.generic.model.Response; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import com.google.gson.Gson; @@ -18,7 +18,7 @@ public class ResponseDtoTest { @BeforeClass public static void initClass() { - FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + FixtureFactoryLoader.loadTemplates("br.com.elementalsource.mock.generic.model.template"); } @Test diff --git a/src/test/java/br/com/elementasource/mock/generic/model/RequestTest.java b/src/test/java/br/com/elementalsource/mock/generic/model/RequestTest.java similarity index 89% rename from src/test/java/br/com/elementasource/mock/generic/model/RequestTest.java rename to src/test/java/br/com/elementalsource/mock/generic/model/RequestTest.java index 608b7d6..f23a275 100755 --- a/src/test/java/br/com/elementasource/mock/generic/model/RequestTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/model/RequestTest.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.generic.model; +package br.com.elementalsource.mock.generic.model; -import br.com.elementasource.mock.generic.model.template.RequestTemplate; +import br.com.elementalsource.mock.generic.model.template.RequestTemplate; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.junit.BeforeClass; @@ -13,7 +13,7 @@ public class RequestTest { @BeforeClass public static void initClass() { - FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + FixtureFactoryLoader.loadTemplates("br.com.elementalsource.mock.generic.model.template"); } @Test diff --git a/src/test/java/br/com/elementasource/mock/generic/model/template/EndpointTemplate.java b/src/test/java/br/com/elementalsource/mock/generic/model/template/EndpointTemplate.java similarity index 91% rename from src/test/java/br/com/elementasource/mock/generic/model/template/EndpointTemplate.java rename to src/test/java/br/com/elementalsource/mock/generic/model/template/EndpointTemplate.java index 365ebd3..59ad88c 100755 --- a/src/test/java/br/com/elementasource/mock/generic/model/template/EndpointTemplate.java +++ b/src/test/java/br/com/elementalsource/mock/generic/model/template/EndpointTemplate.java @@ -1,8 +1,8 @@ -package br.com.elementasource.mock.generic.model.template; +package br.com.elementalsource.mock.generic.model.template; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.generic.model.Response; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.model.Response; import br.com.six2six.fixturefactory.Rule; import br.com.six2six.fixturefactory.loader.TemplateLoader; diff --git a/src/test/java/br/com/elementasource/mock/generic/model/template/RequestTemplate.java b/src/test/java/br/com/elementalsource/mock/generic/model/template/RequestTemplate.java similarity index 96% rename from src/test/java/br/com/elementasource/mock/generic/model/template/RequestTemplate.java rename to src/test/java/br/com/elementalsource/mock/generic/model/template/RequestTemplate.java index 7a4baca..ad12fbd 100755 --- a/src/test/java/br/com/elementasource/mock/generic/model/template/RequestTemplate.java +++ b/src/test/java/br/com/elementalsource/mock/generic/model/template/RequestTemplate.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.generic.model.template; +package br.com.elementalsource.mock.generic.model.template; -import br.com.elementasource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.model.Request; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.Rule; import br.com.six2six.fixturefactory.loader.TemplateLoader; diff --git a/src/test/java/br/com/elementasource/mock/generic/model/template/ResponseTemplate.java b/src/test/java/br/com/elementalsource/mock/generic/model/template/ResponseTemplate.java similarity index 92% rename from src/test/java/br/com/elementasource/mock/generic/model/template/ResponseTemplate.java rename to src/test/java/br/com/elementalsource/mock/generic/model/template/ResponseTemplate.java index 5650af4..2be87b2 100755 --- a/src/test/java/br/com/elementasource/mock/generic/model/template/ResponseTemplate.java +++ b/src/test/java/br/com/elementalsource/mock/generic/model/template/ResponseTemplate.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.generic.model.template; +package br.com.elementalsource.mock.generic.model.template; -import br.com.elementasource.mock.generic.model.Response; +import br.com.elementalsource.mock.generic.model.Response; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.Rule; import br.com.six2six.fixturefactory.loader.TemplateLoader; diff --git a/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBodyTest.java b/src/test/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterBodyTest.java similarity index 83% rename from src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBodyTest.java rename to src/test/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterBodyTest.java index 9e784b7..df08227 100755 --- a/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterBodyTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterBodyTest.java @@ -1,9 +1,9 @@ -package br.com.elementasource.mock.generic.repository.impl; +package br.com.elementalsource.mock.generic.repository.impl; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.generic.model.template.EndpointTemplate; -import br.com.elementasource.mock.generic.model.template.RequestTemplate; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.model.template.EndpointTemplate; +import br.com.elementalsource.mock.generic.model.template.RequestTemplate; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.junit.BeforeClass; @@ -25,7 +25,7 @@ public class EndpointFileFilterBodyTest { @BeforeClass public static void initClass() { - FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + FixtureFactoryLoader.loadTemplates("br.com.elementalsource.mock.generic.model.template"); } @Test diff --git a/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQueryTest.java b/src/test/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterQueryTest.java similarity index 83% rename from src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQueryTest.java rename to src/test/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterQueryTest.java index c537924..c9feffe 100755 --- a/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointFileFilterQueryTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/repository/impl/EndpointFileFilterQueryTest.java @@ -1,9 +1,9 @@ -package br.com.elementasource.mock.generic.repository.impl; +package br.com.elementalsource.mock.generic.repository.impl; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.generic.model.template.EndpointTemplate; -import br.com.elementasource.mock.generic.model.template.RequestTemplate; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.generic.model.template.EndpointTemplate; +import br.com.elementalsource.mock.generic.model.template.RequestTemplate; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.junit.BeforeClass; @@ -25,7 +25,7 @@ public class EndpointFileFilterQueryTest { @BeforeClass public static void initClass() { - FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + FixtureFactoryLoader.loadTemplates("br.com.elementalsource.mock.generic.model.template"); } @Test diff --git a/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModelTest.java b/src/test/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryModelTest.java similarity index 87% rename from src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModelTest.java rename to src/test/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryModelTest.java index 4abb9c7..8dc8f52 100755 --- a/src/test/java/br/com/elementasource/mock/generic/repository/impl/EndpointRepositoryModelTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/repository/impl/EndpointRepositoryModelTest.java @@ -1,12 +1,12 @@ -package br.com.elementasource.mock.generic.repository.impl; - -import br.com.elementasource.mock.generic.mapper.EndpointMapper; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.generic.model.template.EndpointTemplate; -import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilderModel; -import br.com.elementasource.mock.infra.property.FileExtensionProperty; -import br.com.elementasource.mock.infra.property.FileProperty; +package br.com.elementalsource.mock.generic.repository.impl; + +import br.com.elementalsource.mock.generic.mapper.EndpointMapper; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.infra.component.file.BaseFileNameBuilderModel; +import br.com.elementalsource.mock.infra.property.FileExtensionProperty; +import br.com.elementalsource.mock.infra.property.FileProperty; +import br.com.elementalsource.mock.generic.model.template.EndpointTemplate; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.junit.Before; @@ -59,7 +59,7 @@ public class EndpointRepositoryModelTest { @BeforeClass public static void initClass() { - FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + FixtureFactoryLoader.loadTemplates("br.com.elementalsource.mock.generic.model.template"); } @Before diff --git a/src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java b/src/test/java/br/com/elementalsource/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java similarity index 89% rename from src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java rename to src/test/java/br/com/elementalsource/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java index 5130065..f56885f 100755 --- a/src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/service/impl/EndpointBackupServiceFileIntegrarionTest.java @@ -1,10 +1,10 @@ -package br.com.elementasource.mock.generic.service.impl; +package br.com.elementalsource.mock.generic.service.impl; -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.template.EndpointTemplate; -import br.com.elementasource.mock.generic.service.EndpointBackupService; -import br.com.elementasource.mock.infra.property.FileExtensionProperty; -import br.com.elementasource.mock.infra.property.FileProperty; +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.infra.property.FileExtensionProperty; +import br.com.elementalsource.mock.infra.property.FileProperty; +import br.com.elementalsource.mock.generic.model.template.EndpointTemplate; +import br.com.elementalsource.mock.generic.service.EndpointBackupService; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.json.JSONException; @@ -58,7 +58,7 @@ public class EndpointBackupServiceFileIntegrarionTest { @BeforeClass public static void initClass() { - FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + FixtureFactoryLoader.loadTemplates("br.com.elementalsource.mock.generic.model.template"); } @Before diff --git a/src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileTest.java b/src/test/java/br/com/elementalsource/mock/generic/service/impl/EndpointBackupServiceFileTest.java similarity index 82% rename from src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileTest.java rename to src/test/java/br/com/elementalsource/mock/generic/service/impl/EndpointBackupServiceFileTest.java index e7336ec..79823a7 100755 --- a/src/test/java/br/com/elementasource/mock/generic/service/impl/EndpointBackupServiceFileTest.java +++ b/src/test/java/br/com/elementalsource/mock/generic/service/impl/EndpointBackupServiceFileTest.java @@ -1,15 +1,15 @@ -package br.com.elementasource.mock.generic.service.impl; - -import br.com.elementasource.mock.generic.model.Endpoint; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.generic.model.template.EndpointTemplate; -import br.com.elementasource.mock.generic.repository.EndpointRepository; -import br.com.elementasource.mock.infra.component.FromJsonStringToObjectConverter; -import br.com.elementasource.mock.infra.component.file.BaseFileNameBuilderModel; -import br.com.elementasource.mock.infra.component.file.FileNameGenerator; -import br.com.elementasource.mock.infra.component.impl.JsonFormatterPretty; -import br.com.elementasource.mock.infra.property.FileExtensionProperty; -import br.com.elementasource.mock.infra.property.FileProperty; +package br.com.elementalsource.mock.generic.service.impl; + +import br.com.elementalsource.mock.generic.model.Endpoint; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.infra.component.file.BaseFileNameBuilderModel; +import br.com.elementalsource.mock.infra.component.file.FileNameGenerator; +import br.com.elementalsource.mock.infra.property.FileExtensionProperty; +import br.com.elementalsource.mock.generic.model.template.EndpointTemplate; +import br.com.elementalsource.mock.generic.repository.EndpointRepository; +import br.com.elementalsource.mock.infra.component.FromJsonStringToObjectConverter; +import br.com.elementalsource.mock.infra.component.impl.JsonFormatterPretty; +import br.com.elementalsource.mock.infra.property.FileProperty; import br.com.six2six.fixturefactory.Fixture; import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader; import org.junit.BeforeClass; @@ -59,7 +59,7 @@ public class EndpointBackupServiceFileTest { @BeforeClass public static void initClass() { - FixtureFactoryLoader.loadTemplates("br.com.concrete.mock.generic.model.template"); + FixtureFactoryLoader.loadTemplates("br.com.elementalsource.mock.generic.model.template"); } @Test diff --git a/src/test/java/br/com/elementasource/mock/infra/component/ApiPropertyTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/ApiPropertyTest.java similarity index 88% rename from src/test/java/br/com/elementasource/mock/infra/component/ApiPropertyTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/ApiPropertyTest.java index 74ce1c5..1fecb1d 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/ApiPropertyTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/ApiPropertyTest.java @@ -1,8 +1,8 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; -import br.com.elementasource.mock.infra.model.DefaultHeader; -import br.com.elementasource.mock.infra.model.UriConfiguration; -import br.com.elementasource.mock.infra.property.ApiProperty; +import br.com.elementalsource.mock.infra.property.ApiProperty; +import br.com.elementalsource.mock.infra.model.DefaultHeader; +import br.com.elementalsource.mock.infra.model.UriConfiguration; import com.google.common.collect.ImmutableList; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/elementasource/mock/infra/component/CompareJsonTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/CompareJsonTest.java similarity index 95% rename from src/test/java/br/com/elementasource/mock/infra/component/CompareJsonTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/CompareJsonTest.java index 463d1db..5bb43c3 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/CompareJsonTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/CompareJsonTest.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; -import br.com.elementasource.mock.infra.component.impl.ConvertJsonImpl; +import br.com.elementalsource.mock.infra.component.impl.ConvertJsonImpl; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/elementasource/mock/infra/component/CompareMapTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/CompareMapTest.java similarity index 98% rename from src/test/java/br/com/elementasource/mock/infra/component/CompareMapTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/CompareMapTest.java index a60e1ab..907915d 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/CompareMapTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/CompareMapTest.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; import com.google.common.collect.ImmutableMap; import org.junit.Test; diff --git a/src/test/java/br/com/elementasource/mock/infra/component/ExternalApiTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/ExternalApiTest.java similarity index 90% rename from src/test/java/br/com/elementasource/mock/infra/component/ExternalApiTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/ExternalApiTest.java index 2f6c340..63a109a 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/ExternalApiTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/ExternalApiTest.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component; +package br.com.elementalsource.mock.infra.component; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.anyString; @@ -6,7 +6,10 @@ import java.util.Optional; -import br.com.elementasource.mock.infra.model.UriConfiguration; +import br.com.elementalsource.mock.generic.model.ExternalApiResult; +import br.com.elementalsource.mock.generic.model.Request; +import br.com.elementalsource.mock.infra.model.UriConfiguration; +import br.com.elementalsource.mock.infra.property.ApiProperty; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -15,10 +18,6 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.bind.annotation.RequestMethod; -import br.com.elementasource.mock.generic.model.ExternalApiResult; -import br.com.elementasource.mock.generic.model.Request; -import br.com.elementasource.mock.infra.property.ApiProperty; - @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ExternalApiTest { diff --git a/src/test/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModelTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderModelTest.java similarity index 93% rename from src/test/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModelTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderModelTest.java index cb77002..0ef760d 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/file/BaseFileNameBuilderModelTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/file/BaseFileNameBuilderModelTest.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component.file; +package br.com.elementalsource.mock.infra.component.file; -import br.com.elementasource.mock.infra.property.FileProperty; +import br.com.elementalsource.mock.infra.property.FileProperty; import org.hamcrest.CoreMatchers; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/br/com/elementasource/mock/infra/component/file/FileJsonReaderTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/file/FileJsonReaderTest.java similarity index 97% rename from src/test/java/br/com/elementasource/mock/infra/component/file/FileJsonReaderTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/file/FileJsonReaderTest.java index e81e4be..7651376 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/file/FileJsonReaderTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/file/FileJsonReaderTest.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component.file; +package br.com.elementalsource.mock.infra.component.file; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImplTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/file/FileNameGeneratorImplTest.java similarity index 95% rename from src/test/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImplTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/file/FileNameGeneratorImplTest.java index 9756112..5b055f6 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/file/FileNameGeneratorImplTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/file/FileNameGeneratorImplTest.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component.file; +package br.com.elementalsource.mock.infra.component.file; -import br.com.elementasource.mock.infra.property.FileExtensionProperty; +import br.com.elementalsource.mock.infra.property.FileExtensionProperty; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImplTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/impl/ConvertJsonImplTest.java similarity index 92% rename from src/test/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImplTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/impl/ConvertJsonImplTest.java index b2f7d7b..52c1b30 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/impl/ConvertJsonImplTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/impl/ConvertJsonImplTest.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component.impl; +package br.com.elementalsource.mock.infra.component.impl; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java similarity index 96% rename from src/test/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java index 724ccd4..0d0d9eb 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/impl/FromJsonStringToObjectConverterImplTest.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component.impl; +package br.com.elementalsource.mock.infra.component.impl; import com.google.gson.Gson; diff --git a/src/test/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPrettyTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/impl/JsonFormatterPrettyTest.java similarity index 95% rename from src/test/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPrettyTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/impl/JsonFormatterPrettyTest.java index 437903a..4139bd9 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/impl/JsonFormatterPrettyTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/impl/JsonFormatterPrettyTest.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component.impl; +package br.com.elementalsource.mock.infra.component.impl; import com.google.gson.JsonParseException; import org.junit.Assert; diff --git a/src/test/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImplTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/impl/JsonValueCompilerImplTest.java similarity index 98% rename from src/test/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImplTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/impl/JsonValueCompilerImplTest.java index 5c03c7a..5a6152f 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/impl/JsonValueCompilerImplTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/impl/JsonValueCompilerImplTest.java @@ -1,4 +1,4 @@ -package br.com.elementasource.mock.infra.component.impl; +package br.com.elementalsource.mock.infra.component.impl; import org.json.JSONException; import org.junit.Test; diff --git a/src/test/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImplTest.java b/src/test/java/br/com/elementalsource/mock/infra/component/impl/QueryStringBuilderImplTest.java similarity index 93% rename from src/test/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImplTest.java rename to src/test/java/br/com/elementalsource/mock/infra/component/impl/QueryStringBuilderImplTest.java index 3c55143..64e109d 100755 --- a/src/test/java/br/com/elementasource/mock/infra/component/impl/QueryStringBuilderImplTest.java +++ b/src/test/java/br/com/elementalsource/mock/infra/component/impl/QueryStringBuilderImplTest.java @@ -1,6 +1,6 @@ -package br.com.elementasource.mock.infra.component.impl; +package br.com.elementalsource.mock.infra.component.impl; -import br.com.elementasource.mock.infra.component.ConvertJson; +import br.com.elementalsource.mock.infra.component.ConvertJson; import com.google.common.collect.ImmutableMap; import org.junit.Test; import org.junit.runner.RunWith; From 4f3aa5cdfaa426b0abf97e739b5de8dfe410a1d4 Mon Sep 17 00:00:00 2001 From: V-V-K <33099230+V-V-K@users.noreply.github.com> Date: Sat, 28 Oct 2017 00:22:57 +0530 Subject: [PATCH 52/54] Translated README.md to English Translated the file. Added some spaces. Gave some empty lines to make it clear and understandable. --- README.md | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 7b56d0b..6e12ca7 100644 --- a/README.md +++ b/README.md @@ -7,37 +7,39 @@ # Mock API -App criado para fazer mock com REST utilizando JSON +App created to mock with REST using JSON. -## Regras +## Rules -Quando uma request é feita é seguido o seguinte fluxo: +When a request is made the following flow is followed: -* Existe na pasta do mock (conforme a propriedade `api.fileBase`)? Caso sim, retorna o mock -* 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` -* Se não entrar nos fluxos anteriores, vai redirecionar para o host padrão `api.host` +* Does it exist in the mock folder (as per the `api.fileBase` property)? If so, return the mock. +* Does the uri fit into any pattern in the `api.uriConfigurations []. Pattern` list? If so, it will redirect according to the configuration and cache according to the `backup` field. +* If it does not enter the previous flows, it will redirect to the default host `api.host` -## Requisitos +## Requirements * Java JDK 8 * Gradle 4 ## Run -## Usando seu arquivo de propriedades -Crie seu arquivo de propriedade `src/main/resources/application-custom.yml` e rode com o argumento `-Dspring.profiles.active=custom`. Exemplo: +## Using Your Property File +Create your `src / main / resources / application-custom.yml` property file and run it with the` -Dspring.profiles.active = custom` argument. Example: + ``` gradle bootRun -Dspring.profiles.active=custom ``` -## Usando imagem Docker -Para gerar a imagem Docker do projeto, execute: +## Using Docker Image +To generate the project Docker image, run: + ``` gradle buildDocker ``` -Por padrão, o nome da imagem será `elemental-source/mock-api:VERSAO`. +By default, the image name will be `elemental-source / mock-api: VERSAO`. -Para rodar a aplicação, crie dois diretórios: um contendo o arquivo de configuração `application-custom.yml` e o outro contendo os arquivos de mock. Execute então: +To run the application, create two directories: one containing the `application-custom.yml` configuration file and the other containing the mock files. Then run: ``` docker run -d --name mock-api \ @@ -47,14 +49,14 @@ docker run -d --name mock-api \ elemental-source/mock-api:VERSAO ``` -A porta `9090` expõe o serviço enquanto a porta `5000` é utilizada para debug da aplicação. +The `9090` port exposes the service while the` 5000` port is used to debug the application. -Para visualizar os logs da aplicação a partir do container: `docker logs -f mock-api` +To view the application logs from the container: `docker logs -f mock-api` -## TODO -- [X] Corrigir Code Style -- [ ] Inserir exemplo do "arquivo de propriedades" no README -- [ ] Separar testes unitários dos testes integrados -- [ ] Corrigir os testes ignorados -- [ ] Revisar dependências (ver, por exemplo, se é mesmo necessário ter o GSON ou modelmapper) -- [ ] Usar objectmapper como component: `compile('com.fasterxml.jackson.datatype:jackson-datatype-jdk8')` +## ALL +- [X] Correct Code Style +- [ ] Insert example of "property file" in README +- [ ] Separate unit tests from integrated tests +- [ ] Fix skipping tests +- [ ] Review dependencies (see, for example, if it is even necessary to have the GSON or modelmapper) +- [ ] Use objectmapper as component: `compile ('com.fasterxml.jackson.datatype: jackson-datatype-jdk8')`` From 26594ffa7bb63625d20abfaa01b22630d0b49beb Mon Sep 17 00:00:00 2001 From: Renato Silva Date: Sun, 29 Oct 2017 12:51:50 -0200 Subject: [PATCH 53/54] Improve description and how to use --- README.md | 105 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 84 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 6e12ca7..5760883 100644 --- a/README.md +++ b/README.md @@ -7,56 +7,119 @@ # Mock API -App created to mock with REST using JSON. +Allows for reusable http request/response cycles in your tests, similar to WireMock. + +## Features + +* Capture live responses from external hosts and save the stubs locally +* Define your mocked responses using JSON +* Folder-based data files +* Per-request conditional proxying +* Simple YAML configuration ## Rules -When a request is made the following flow is followed: +All your requests should be directed to the application. When an HTTP request is made, the following matching rules are applied: + +1. Is there a valid mock data file (i.e. request/response pattern) existing in `api.fileBase` folder that matches the request pattern? If so, the mocked response is returned. +2. If not, does the request uri match any pattern described by the `api.uriConfigurations[].pattern` list? If so, the request will be dispatched to the matching `api.uriConfigurations[].host`. +3. If none of above is true, the request is dispatched to the default host `api.host`. + +Should (2) or (3) occur, the response from an external host will be cached according to the `captureState` and `api.file.backup.path` properties. Next time the same request is made, it will be returned directly from the saved data file. + +## Example of a matched request -* Does it exist in the mock folder (as per the `api.fileBase` property)? If so, return the mock. -* Does the uri fit into any pattern in the `api.uriConfigurations []. Pattern` list? If so, it will redirect according to the configuration and cache according to the `backup` field. -* If it does not enter the previous flows, it will redirect to the default host `api.host` +Let's say you want to return the following mocked response for the following request: + +``` +GET http://www.example.com/payments/111/description?code=ABCD +``` + +Expected response: + +``` +HTTP 200 (OK) +{ + "payment": { + "from": "John", + "to": "Fred", + "value": 33 + } +} +``` + +You should create the following mock data file (its name has no meaning, it can be anything you like): + +``` +{ + // Request field describes what the request should look like in order to return the matched response. + // In this case, query parameter "code" should be equal to "ABCD". + // The request pattern is described by its method, headers, query parameters and body. + request": { + "query": { + "code": "ABCD" + } + }, + // Response field describes the mocked response in case the request matches. + // You can define the response body and status code. + "response": { + "body": { + "payment": { + "from": "John", + "to": "Fred", + "value": 33 + } + }, + "httpStatus": 200 + } +} +``` + +Now, in order to properly use the data file, we should consider where it should be located. `mock-api` will parse the request and use the uri to search for the data file in the `api.fileBase` folder. In our example the request uri is `/payments/111/description?code=ABCD`, this means that the data file should be located in `${api.fileBase}/payments/111/description` folder (i.e. file location is based in uri parts and path parameters, other request fields are described in the data file itself). ## Requirements + * Java JDK 8 * Gradle 4 ## Run -## Using Your Property File -Create your `src / main / resources / application-custom.yml` property file and run it with the` -Dspring.profiles.active = custom` argument. Example: +### Using Your Property File +Create a valid property file in `src/main/resources/application-custom.yml` then run with `-Dspring.profiles.active=custom` argument. Example: ``` gradle bootRun -Dspring.profiles.active=custom ``` -## Using Docker Image -To generate the project Docker image, run: +### Using Docker Image +To generate the Docker image, run: ``` gradle buildDocker ``` -By default, the image name will be `elemental-source / mock-api: VERSAO`. +By default, the image name will be `elemental-source/mock-api:VERSION`. -To run the application, create two directories: one containing the `application-custom.yml` configuration file and the other containing the mock files. Then run: +In order to run the application, create two folders: one containing the `application-custom.yml` configuration file and the other containing the mock data files. Then run: ``` docker run -d --name mock-api \ -p 9090:9090 \ - -v /path/para/arquivo/application-custom.yml:/config/application.yml \ - -v /path/para/diretorio/dados/:/data \ - elemental-source/mock-api:VERSAO + -p 5000:5000 \ + -v /path/to/application-custom.yml:/config/application.yml \ + -v /path/to/mock/data/files:/data \ + elemental-source/mock-api:VERSION ``` -The `9090` port exposes the service while the` 5000` port is used to debug the application. +Port `9090` exposes the service while port `5000` can be used to debug the application. + +You can check application logs from the container: `docker logs -f mock-api` -To view the application logs from the container: `docker logs -f mock-api` +## TODO -## ALL -- [X] Correct Code Style -- [ ] Insert example of "property file" in README -- [ ] Separate unit tests from integrated tests +- [X] Fix code Style +- [ ] Create an example of a property file +- [ ] Split unit from integrated tests - [ ] Fix skipping tests -- [ ] Review dependencies (see, for example, if it is even necessary to have the GSON or modelmapper) +- [ ] Review dependencies (check, for instance, if it's even necessary to have both GSON and modelmapper dependencies) - [ ] Use objectmapper as component: `compile ('com.fasterxml.jackson.datatype: jackson-datatype-jdk8')`` From b9834092571d668a98823762750c6c5e7ff4b7e7 Mon Sep 17 00:00:00 2001 From: Luis Fernando de Souza Moro Date: Fri, 5 Jan 2018 10:44:48 -0200 Subject: [PATCH 54/54] Delete application.yml --- src/main/resources/application.yml | 54 ------------------------------ 1 file changed, 54 deletions(-) delete mode 100755 src/main/resources/application.yml diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml deleted file mode 100755 index a65e4c1..0000000 --- a/src/main/resources/application.yml +++ /dev/null @@ -1,54 +0,0 @@ -server.port: 9090 -api: - host: "http://api.itau/apiitau" # "http://api-des.itau/" - acceptedHeaders: - - "execute" - - "Content-Type" - defaultHeaders: - - - headerName: "Server" - headerValues: - - "Microsoft-IIS/8.5" - - - headerName: "X-Powered-By" - headerValues: - - "Express,ASP.NET" - - - headerName: "Access-Control-Allow-Headers" - headerValues: - - "Content-Type" - - - headerName: "Access-Control-Allow-Methods" - headerValues: - - "GET,PUT,POST,DELETE,PATCH" - - - headerName: "Access-Control-Allow-Origin" - headerValues: - - "*" - - - headerName: "Connection" - headerValues: - - "Keep-Alive" - - - headerName: "Content-Type" - headerValues: - - "application/json;charset=utf-8" - uriConfigurations: - - - host: "http://api.itau/apiitau" - pattern: "seguranca/token" - backup: true - - - host: "http://api.itau/apiitau" - pattern: "v2/pagamento" - backup: true - - - host: "http://api.itau/apiitau" - pattern: "^(seguranca|limites_seguranca)\\/" - backup: false -file: - base: "/home/luis/dev/itau/ws/mobile-teste-integrado/server/fake-api-data" - extension: ".json" - backup.path: "/home/luis/dev/itau/ws/mobile-teste-integrado/server/fake-api-data-backup" -captureState: true -debug: true