From 1a2c0bbae409b32644deb2493aa68ca38e840e24 Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 13:04:41 +0300 Subject: [PATCH 01/12] toTest 1 --- .github/workflows/build.sh | 5 + .github/workflows/dashboard-template.hbs | 1672 +++ .github/workflows/run.sh | 5 + .github/workflows/wait-for-it.sh | 183 + .run/ShareItGateway.run.xml | 15 + .run/ShareItServer.run.xml | 15 + docker-compose.yml | 39 + gateway/Dockerfile | 3 + gateway/pom.xml | 65 + .../ru/practicum/shareit/ShareItGateway.java | 12 + .../shareit/booking/BookingClient.java | 70 + .../shareit/booking/BookingController.java | 72 + .../shareit/booking/dto/BookingInItemDto.java | 19 + .../booking/dto/BookingIncomingDto.java | 26 + .../practicum/shareit/booking/dto/State.java | 11 + .../practicum/shareit/client/BaseClient.java | 121 + .../shareit/error_handler/ErrorHandler.java | 34 + .../shareit/error_handler/ErrorResponse.java | 19 + .../ru/practicum/shareit/item/ItemClient.java | 62 + .../shareit/item/ItemController.java | 87 + .../shareit/item/dto/CommentDto.java | 18 + .../shareit/item/dto/CreateCommentDto.java | 15 + .../practicum/shareit/item/dto/ItemDto.java | 31 + .../request/ItemRequestController.java | 51 + .../shareit/request/RequestClient.java | 48 + .../request/dto/ItemRequestIncomingDto.java | 16 + .../ru/practicum/shareit/user/UserClient.java | 45 + .../shareit/user/UserController.java | 60 + .../ru/practicum/shareit/user/UserDto.java | 21 + .../src/main/resources/application.properties | 7 + pom.xml | 126 +- postman/sprint.json | 11050 ++++++++++++++++ server/Dockerfile | 3 + server/db/filmorate.mv.db | Bin 0 -> 57344 bytes server/pom.xml | 90 + .../ru/practicum/shareit/ShareItServer.java | 4 +- .../booking/controller/BookingController.java | 0 .../exceptions/BookerAndOwnerIdException.java | 0 .../exceptions/UnavailableItemException.java | 0 .../exceptions/WrongStateException.java | 0 .../shareit/booking/model/Booking.java | 0 .../shareit/booking/model/BookingDto.java | 0 .../booking/model/BookingInItemDto.java | 0 .../booking/model/BookingIncomingDto.java | 0 .../shareit/booking/model/BookingMapper.java | 0 .../booking/model/BookingResponseDto.java | 0 .../shareit/booking/model/State.java | 0 .../shareit/booking/model/Status.java | 0 .../booking/repository/BookingRepository.java | 0 .../booking/service/BookingService.java | 0 .../booking/service/BookingServiceImpl.java | 0 .../practicum/shareit/error/ErrorHandler.java | 0 .../shareit/error/ErrorResponse.java | 0 .../item/controller/ItemController.java | 0 .../item/exceptions/CommentException.java | 0 .../exceptions/DeniedAccessException.java | 0 .../exceptions/OwnerNotFoundException.java | 0 .../practicum/shareit/item/model/Comment.java | 0 .../shareit/item/model/CommentDto.java | 0 .../shareit/item/model/CommentMapper.java | 0 .../shareit/item/model/CreateCommentDto.java | 0 .../ru/practicum/shareit/item/model/Item.java | 0 .../practicum/shareit/item/model/ItemDto.java | 0 .../shareit/item/model/ItemInRequestDto.java | 0 .../shareit/item/model/ItemMapper.java | 0 .../item/repository/CommentRepository.java | 0 .../item/repository/ItemRepository.java | 0 .../shareit/item/service/ItemService.java | 0 .../shareit/item/service/ItemServiceImpl.java | 1 + .../controller/ItemRequestController.java | 0 .../shareit/request/model/ItemRequest.java | 0 .../request/model/ItemRequestInItemDto.java | 0 .../request/model/ItemRequestIncomingDto.java | 0 .../request/model/ItemRequestMapper.java | 0 .../request/model/ItemRequestResponseDto.java | 0 .../repository/ItemRequestRepository.java | 0 .../request/service/ItemRequestService.java | 0 .../service/ItemRequestServiceImpl.java | 0 .../user/controller/UserController.java | 0 .../exceptions/EmailValidationException.java | 0 .../exceptions/UserNotFoundException.java | 0 .../ru/practicum/shareit/user/model/User.java | 0 .../practicum/shareit/user/model/UserDto.java | 0 .../shareit/user/model/UserMapper.java | 0 .../user/repository/UserRepository.java | 0 .../shareit/user/service/UserService.java | 0 .../shareit/user/service/UserServiceImpl.java | 0 .../main/resources/application.properties | 2 + {src => server/src}/main/resources/schema.sql | 0 .../ru/practicum/shareit/ShareItTests.java | 0 .../booking/BookingControllerTest.java | 0 .../shareit/booking/BookingMapperTest.java | 0 .../booking/BookingRepositoryTest.java | 0 .../shareit/booking/BookingServiceTest.java | 0 .../error_handler/ErrorHandlerTest.java | 0 .../item/IntegrationItemServiceTest.java | 0 .../shareit/item/ItemControllerTest.java | 0 .../shareit/item/ItemServiceTest.java | 0 .../item/mapper/CommentMapperTest.java | 0 .../shareit/item/mapper/ItemMapperTest.java | 0 .../repository/CommentRepositoryTest.java | 0 .../item/repository/ItemRepositoryTest.java | 0 .../requests/ItemRequestControllerTest.java | 0 .../requests/ItemRequestMapperTest.java | 0 .../requests/ItemRequestRepositoryTest.java | 0 .../requests/ItemRequestServiceTest.java | 0 .../user/IntegrationUserServiceTest.java | 0 .../shareit/user/UserControllerTest.java | 0 .../shareit/user/UserMapperTest.java | 0 .../shareit/user/UserServiceTest.java | 0 110 files changed, 14024 insertions(+), 99 deletions(-) create mode 100644 .github/workflows/build.sh create mode 100644 .github/workflows/dashboard-template.hbs create mode 100644 .github/workflows/run.sh create mode 100644 .github/workflows/wait-for-it.sh create mode 100644 .run/ShareItGateway.run.xml create mode 100644 .run/ShareItServer.run.xml create mode 100644 docker-compose.yml create mode 100644 gateway/Dockerfile create mode 100644 gateway/pom.xml create mode 100644 gateway/src/main/java/ru/practicum/shareit/ShareItGateway.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/booking/BookingClient.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/booking/BookingController.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingInItemDto.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingIncomingDto.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/booking/dto/State.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/client/BaseClient.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/error_handler/ErrorHandler.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/error_handler/ErrorResponse.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/item/ItemClient.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/item/ItemController.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/item/dto/CommentDto.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/item/dto/CreateCommentDto.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/item/dto/ItemDto.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/request/ItemRequestController.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/request/RequestClient.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/request/dto/ItemRequestIncomingDto.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/user/UserClient.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/user/UserController.java create mode 100644 gateway/src/main/java/ru/practicum/shareit/user/UserDto.java create mode 100644 gateway/src/main/resources/application.properties create mode 100644 postman/sprint.json create mode 100644 server/Dockerfile create mode 100644 server/db/filmorate.mv.db create mode 100644 server/pom.xml rename src/main/java/ru/practicum/shareit/ShareItApp.java => server/src/main/java/ru/practicum/shareit/ShareItServer.java (73%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/controller/BookingController.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/exceptions/BookerAndOwnerIdException.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/exceptions/UnavailableItemException.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/exceptions/WrongStateException.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/model/Booking.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/model/BookingDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/model/BookingInItemDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/model/BookingIncomingDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/model/BookingMapper.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/model/BookingResponseDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/model/State.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/model/Status.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/repository/BookingRepository.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/service/BookingService.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/booking/service/BookingServiceImpl.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/error/ErrorHandler.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/error/ErrorResponse.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/controller/ItemController.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/exceptions/CommentException.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/exceptions/DeniedAccessException.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/exceptions/OwnerNotFoundException.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/model/Comment.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/model/CommentDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/model/CommentMapper.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/model/CreateCommentDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/model/Item.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/model/ItemDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/model/ItemInRequestDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/model/ItemMapper.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/repository/CommentRepository.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/repository/ItemRepository.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/service/ItemService.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/item/service/ItemServiceImpl.java (99%) rename {src => server/src}/main/java/ru/practicum/shareit/request/controller/ItemRequestController.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/request/model/ItemRequest.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/request/model/ItemRequestInItemDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/request/model/ItemRequestIncomingDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/request/model/ItemRequestMapper.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/request/model/ItemRequestResponseDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/request/repository/ItemRequestRepository.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/request/service/ItemRequestService.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/request/service/ItemRequestServiceImpl.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/user/controller/UserController.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/user/exceptions/EmailValidationException.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/user/exceptions/UserNotFoundException.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/user/model/User.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/user/model/UserDto.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/user/model/UserMapper.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/user/repository/UserRepository.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/user/service/UserService.java (100%) rename {src => server/src}/main/java/ru/practicum/shareit/user/service/UserServiceImpl.java (100%) rename {src => server/src}/main/resources/application.properties (97%) rename {src => server/src}/main/resources/schema.sql (100%) rename {src => server/src}/test/java/ru/practicum/shareit/ShareItTests.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/booking/BookingControllerTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/booking/BookingMapperTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/booking/BookingRepositoryTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/booking/BookingServiceTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/error_handler/ErrorHandlerTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/item/IntegrationItemServiceTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/item/ItemControllerTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/item/ItemServiceTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/item/mapper/CommentMapperTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/item/mapper/ItemMapperTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/item/repository/CommentRepositoryTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/item/repository/ItemRepositoryTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/requests/ItemRequestControllerTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/requests/ItemRequestMapperTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/requests/ItemRequestRepositoryTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/requests/ItemRequestServiceTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/user/IntegrationUserServiceTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/user/UserControllerTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/user/UserMapperTest.java (100%) rename {src => server/src}/test/java/ru/practicum/shareit/user/UserServiceTest.java (100%) diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh new file mode 100644 index 0000000..95efef0 --- /dev/null +++ b/.github/workflows/build.sh @@ -0,0 +1,5 @@ +cp -rf ./tests/checkstyle.xml ./checkstyle.xml +cp -rf ./tests/suppressions.xml ./suppressions.xml +mvn enforcer:enforce -Drules=requireProfileIdsExist -P check --no-transfer-progress +mvn verify -P check,coverage --no-transfer-progress +docker-compose build \ No newline at end of file diff --git a/.github/workflows/dashboard-template.hbs b/.github/workflows/dashboard-template.hbs new file mode 100644 index 0000000..56aa163 --- /dev/null +++ b/.github/workflows/dashboard-template.hbs @@ -0,0 +1,1672 @@ + + + + + {{browserTitle}} + + + + + + + + + +
+
+ + + +
+ {{#with summary}} +
+
+ + {{/with}} +
+
+
+
+

{{title}}

+
{{timestamp}}
+{{#with summary}} +
+
+
+
+
+ +
+
Итого итераций
+

{{stats.iterations.total}}

+
+
+
+
+
+
+
+ +
+
Всего проверенных утверждений
+

{{totalTests stats.assertions.total skippedTests.length}}

+
+
+
+
+
+
+
+ +
+
Всего проваленных тестов
+

{{failures.length}}

+
+
+
+
+
+
+
+ +
+
Всего пропущено тестов
+

{{#gt skippedTests.length 0}}{{skippedTests.length}}{{else}}0{{/gt}}

+
+
+
+
+
+
+
+
+
+
+
+
File Information
+ Коллекция: {{collection.name}}
+ {{/with}} + {{#if folders}} Указанные папки: {{folders}}
{{/if}} + {{#with summary}} + {{#if environment.name}} Окружение: {{environment.name}}
{{/if}} +
+
+
+
+ {{#if @root.showGlobalData}} + {{#if globals.values.members.length}} +
+
+
+
+
+ +
+
+
+ +
+ + + + {{#each globals.values.members}} + {{#isNotIn key @root.skipGlobalVars}} + + + + + {{/isNotIn}} + {{/each}} + +
Название переменнойЗначение переменной
{{key}}{{value}}
+
+
+
+
+
+
+
+ {{/if}} + {{/if}} + {{#if @root.showEnvironmentData}} + {{#if environment.values.members.length}} +
+
+
+
+
+ +
+
+
+ +
+ + + + {{#each environment.values.members}} + {{#isNotIn key @root.skipEnvironmentVars}} + + + + + {{/isNotIn}} + {{/each}} + +
Название переменнойЗначение переменной
{{key}}{{value}}
+
+
+
+
+
+
+
+ {{/if}} + {{/if}} + {{#if collection.description}} +
+
+
+
+
Описание Коллекции
+
+ {{collection.description}} +
+
+
+
+
+ {{/if}} +
+
+
+
+
Временные рамки и данные
+ Общая длительность выполнения: {{duration}}
+ Всего данных получено: {{responseTotal}}
+ Среднее время отклика: {{responseAverage}}
+
+
+
+
+ {{/with}} +
+
+
+ + + + + + + + + + {{#with summary.stats}} + + + + + + + + + + + + + + + + {{/with}} + {{#with summary}} + + + + + + + + + + + {{/with}} + +
Элемент сводных данныхВсегоПровалено
Requests{{requests.total}}{{requests.failed}}
Prerequest Scripts{{prerequestScripts.total}}{{prerequestScripts.failed}}
Test Scripts{{testScripts.total}}{{testScripts.failed}}
Assertions{{totalTests stats.assertions.total skippedTests.length}}{{stats.assertions.failed}}
Skipped Tests{{#gt skippedTests.length 0}}{{skippedTests.length}}{{else}}0{{/gt}}-
+
+
+
+
+
+
+
+
+
+
+ + + {{#if summary.failures.length}} +
+ +
+
+
+ + {{#with summary}} +
+

Showing {{failures.length}} {{#gt failures.length 1}}Failures{{else}}Failure{{/gt}}

+
+ {{/with}} + {{#each summary.failures}} +
+
+
+ +
+
+
Failed Test: {{error.test}}
+
+
Assertion Error Message
+
+
{{error.message}}
+
+
+
+
+
+
+ {{/each}} + {{else}} +
+

There are no failed tests



+
+ {{/if}} +
+ +
+ + + {{#if summary.skippedTests.length}} +
+ +
+
+
+ + {{#with summary}} +
+

Showing {{skippedTests.length}} Skipped {{#gt skippedTests.length 1}}Tests{{else}}Test{{/gt}}

+
+ {{/with}} + {{#each summary.skippedTests}} +
+
+
+ +
+
+
Request Name: {{item.name}}
+
+
+
+
+
+ {{/each}} + {{else}} +
+

There are no skipped tests



+
+ {{/if}} +
+
+ + + +
+ {{#if summary.failures.length}} + + {{/if}} + + +
+ +
+ {{#with summary}} +
{{stats.iterations.total}} {{#gt stats.iterations.total 1}}Iterations{{else}}Iteration{{/gt}} available to view
+ {{#gt stats.iterations.total 18}}{{/gt}} + {{/with}} + +
+
+
+{{#each aggregations}} + {{#isNotIn parent.name @root.skipFolders}} + {{#if parent.name }} + +
+ {{> aggregations}} +
+ {{else}} + {{> aggregations}} + {{/if}} + {{/isNotIn}} +{{/each}} +
+
+
+
+
+
+ +{{#*inline "aggregations"}} +{{#isNotIn parent.name @root.skipFolders}} +{{#if @root.showFolderDescription}} +{{#if parent.description.content}} + +
+
+
+
+
+
Описание папки
+
+ {{parent.description.content}} +
+
+
+
+
+
+{{/if}} +{{/if}} +{{#each executions}} +{{#isNotIn item.name @root.skipRequests}} +
+
+
+
+
+ + {{#if cumulativeTests.skipped}} + {{cumulativeTests.skipped}} Пропущено {{#gt cumulativeTests.skipped 1}}Тестов{{else}}Тест{{/gt}} + {{/if}} +
+
+
+ {{#with request}} + {{#if description.content}} +
+
+
+
+
+
Описание запроса
+
+ {{description.content}} +
+
+
+
+
+
+ {{/if}} + {{/with}} +
+
+
+
+
+
Информация о запросе
+ HTTP-метод запроса: {{request.method}}
+ URL запроса: {{request.url}}
+
+
+
+
+
Информация об ответе
+ Код статуса ответа: {{response.code}} - {{response.status}}
+ Среднее время на запрос: {{mean.time}}
+ Средний размер одного запроса: {{mean.size}}
+
+
Процент прохождения тестов
+
+ {{#if assertions.length}} +
+
+
{{#gte cumulativeTests.passed 1}}{{percent cumulativeTests.passed cumulativeTests.failed}} %{{else}}0 %{{/gte}}
+
+
+ {{else}} +
+
+
Для данного запроса нет тестов
+
+
+ {{/if}} +
+
+
+
+
+
+ {{#with request}} + {{#unless @root.omitHeaders}} + {{#unless @root.skipSensitiveData}} +
+
+
+
+
+
Заголовки запроса
+ {{#if headers}} +
+ + + + {{#each headers.members}} + {{#isNotIn key @root.skipHeaders}} + + + + + {{/isNotIn}} + {{/each}} + +
Название заголовкаЗначение заголовка
{{key}}{{value}}
+
+ {{/if}} +
+
+
+
+
+ {{/unless}} + {{/unless}} + {{/with}} + {{#unless @root.skipSensitiveData}} + {{#unless @root.omitRequestBodies}} + {{#isNotIn item.name @root.hideRequestBody}} + {{#with request}} + {{#if body.raw}} +
+
+
+
+
+
Тело запроса
+
+
{{body.raw}}
+
+ +
+
+
+
+
+ {{/if}} + {{/with}} + {{/isNotIn}} + {{/unless}} + {{/unless}} + {{#unless @root.skipSensitiveData}} + {{#unless @root.omitRequestBodies}} + {{#isNotIn item.name @root.hideRequestBody}} + {{#with request}} + {{#if body.formdata.members}} +
+
+
+
+
+
Тело Запроса
+
+
{{formdata body.formdata.members}}
+
+ +
+
+
+
+
+ {{/if}} + {{/with}} + {{/isNotIn}} + {{/unless}} + {{/unless}} + {{#unless @root.skipSensitiveData}} + {{#unless @root.omitRequestBodies}} + {{#isNotIn item.name @root.hideRequestBody}} + {{#with request}} + {{#if body.urlencoded.members}} +
+
+
+
+
+
Тело Запроса
+
+
{{formdata body.urlencoded.members}}
+
+ +
+
+
+
+
+ {{/if}} + {{/with}} + {{/isNotIn}} + {{/unless}} + {{/unless}} + {{#unless @root.skipSensitiveData}} + {{#unless @root.omitRequestBodies}} + {{#isNotIn item.name @root.hideRequestBody}} + {{#with request}} + {{#if body.graphql}} +
+
+
+
+
+
Тело Запроса
+
+
{{body.graphql.query}}
+
+ + {{#if body.graphql.variables }} +
Graphql Variables
+
+
{{body.graphql.variables}}
+
+ {{/if}} +
+
+
+
+
+ {{/if}} + {{/with}} + {{/isNotIn}} + {{/unless}} + {{/unless}} + {{#unless @root.omitHeaders}} + {{#unless @root.skipSensitiveData}} +
+
+
+
+
+
Заголовки Ответа
+ {{#if response.header}} +
+ + + + {{#each response.header}} + {{#isNotIn key @root.skipHeaders}} + + + + + {{/isNotIn}} + {{/each}} + +
Название заголовкаЗначение заголовка
{{key}}{{value}}
+
+ {{/if}} +
+
+
+
+
+ {{/unless}} + {{/unless}} + {{#unless @root.skipSensitiveData}} + {{#unless @root.omitResponseBodies}} + {{#isNotIn item.name @root.hideResponseBody}} +
+
+
+
+
+
Тело Ответа
+ {{#if response.body}} +
+
{{response.body}}
+
+ + {{else}} +
У ответа на этот запрос нет тела
+ {{/if}} +
+
+
+
+
+ {{/isNotIn}} + {{/unless}} + {{/unless}} + {{#if consoleLogs.length}} +
+
+
+
+
+
Логи консоли
+
+
+ + + + {{#each consoleLogs}} + + + + {{/each}} + +
Залогированные сообщения
{{#each messages}}{{this}}{{/each}}
+
+
+
+
+
+
+
+ {{/if}} +
+
+
+
Информация о тесте
+ {{#if assertions.length}} +
+ + + + {{#each assertions}} + + + + + + + {{/each}} + + + + + + + + + +
НазваниеПройденоПроваленоПропущено
{{this.name}}{{this.passed}}{{this.failed}}{{this.skipped}}
Всего{{cumulativeTests.passed}}{{cumulativeTests.failed}}{{cumulativeTests.skipped}}
+
+
+
+
+
+
+
{{#lte cumulativeTests.failed 1}}Проваленный тест{{else}}Проваленные тесты{{/lte}}
+
+ + + + {{#each assertions}} + {{#isTheSame testFailure.test this.name}} + + + + + {{/isTheSame}} + {{/each}} + +
Название тестаОшибка проверки
{{testFailure.test}}
{{testFailure.message}}
+
+
+
+
+
+
+ {{else}} +
No Tests for this request
+ {{/if}} +
+
+
+
+
+
+
+
+
+{{/isNotIn}} +{{/each}} +{{/isNotIn}} +{{/inline}} + + + + + + +{{#eq noSyntaxHighlighting false}} + + +{{/eq}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.github/workflows/run.sh b/.github/workflows/run.sh new file mode 100644 index 0000000..ff67969 --- /dev/null +++ b/.github/workflows/run.sh @@ -0,0 +1,5 @@ +docker-compose up --detach +chmod a+x ./tests/.github/workflows/wait-for-it.sh +./tests/.github/workflows/wait-for-it.sh -t 60 localhost:8080 +./tests/.github/workflows/wait-for-it.sh -t 60 localhost:9090 +docker-compose logs diff --git a/.github/workflows/wait-for-it.sh b/.github/workflows/wait-for-it.sh new file mode 100644 index 0000000..859de3f --- /dev/null +++ b/.github/workflows/wait-for-it.sh @@ -0,0 +1,183 @@ +#!/usr/bin/env bash +# Use this script to test if a given TCP host/port are available + +WAITFORIT_cmdname=${0##*/} + +echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } + +usage() +{ + cat << USAGE >&2 +Usage: + $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args] + -h HOST | --host=HOST Host or IP under test + -p PORT | --port=PORT TCP port under test + Alternatively, you specify the host and port as host:port + -s | --strict Only execute subcommand if the test succeeds + -q | --quiet Don't output any status messages + -t TIMEOUT | --timeout=TIMEOUT + Timeout in seconds, zero for no timeout + -- COMMAND ARGS Execute command with args after the test finishes +USAGE + exit 1 +} + +wait_for() +{ + if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then + echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" + else + echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout" + fi + WAITFORIT_start_ts=$(date +%s) + while : + do + if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then + nc -z $WAITFORIT_HOST $WAITFORIT_PORT + WAITFORIT_result=$? + else +# (echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1 + (curl --fail --silent $WAITFORIT_HOST:$WAITFORIT_PORT/actuator/health | grep UP) >/dev/null 2>&1 + WAITFORIT_result=$? + fi + if [[ $WAITFORIT_result -eq 0 ]]; then + WAITFORIT_end_ts=$(date +%s) + echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" + break + fi + sleep 1 + done + return $WAITFORIT_result +} + +wait_for_wrapper() +{ + # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 + if [[ $WAITFORIT_QUIET -eq 1 ]]; then + timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & + else + timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & + fi + WAITFORIT_PID=$! + trap "kill -INT -$WAITFORIT_PID" INT + wait $WAITFORIT_PID + WAITFORIT_RESULT=$? + if [[ $WAITFORIT_RESULT -ne 0 ]]; then + echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" + fi + return $WAITFORIT_RESULT +} + +# process arguments +while [[ $# -gt 0 ]] +do + case "$1" in + *:* ) + WAITFORIT_hostport=(${1//:/ }) + WAITFORIT_HOST=${WAITFORIT_hostport[0]} + WAITFORIT_PORT=${WAITFORIT_hostport[1]} + shift 1 + ;; + --child) + WAITFORIT_CHILD=1 + shift 1 + ;; + -q | --quiet) + WAITFORIT_QUIET=1 + shift 1 + ;; + -s | --strict) + WAITFORIT_STRICT=1 + shift 1 + ;; + -h) + WAITFORIT_HOST="$2" + if [[ $WAITFORIT_HOST == "" ]]; then break; fi + shift 2 + ;; + --host=*) + WAITFORIT_HOST="${1#*=}" + shift 1 + ;; + -p) + WAITFORIT_PORT="$2" + if [[ $WAITFORIT_PORT == "" ]]; then break; fi + shift 2 + ;; + --port=*) + WAITFORIT_PORT="${1#*=}" + shift 1 + ;; + -t) + WAITFORIT_TIMEOUT="$2" + if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi + shift 2 + ;; + --timeout=*) + WAITFORIT_TIMEOUT="${1#*=}" + shift 1 + ;; + --) + shift + WAITFORIT_CLI=("$@") + break + ;; + --help) + usage + ;; + *) + echoerr "Unknown argument: $1" + usage + ;; + esac +done + +if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then + echoerr "Error: you need to provide a host and port to test." + usage +fi + +WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} +WAITFORIT_STRICT=${WAITFORIT_STRICT:-0} +WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} +WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} + +# Check to see if timeout is from busybox? +WAITFORIT_TIMEOUT_PATH=$(type -p timeout) +WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH) + +WAITFORIT_BUSYTIMEFLAG="" +if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then + WAITFORIT_ISBUSY=1 + # Check if busybox timeout uses -t flag + # (recent Alpine versions don't support -t anymore) + if timeout &>/dev/stdout | grep -q -e '-t '; then + WAITFORIT_BUSYTIMEFLAG="-t" + fi +else + WAITFORIT_ISBUSY=0 +fi + +if [[ $WAITFORIT_CHILD -gt 0 ]]; then + wait_for + WAITFORIT_RESULT=$? + exit $WAITFORIT_RESULT +else + if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then + wait_for_wrapper + WAITFORIT_RESULT=$? + else + wait_for + WAITFORIT_RESULT=$? + fi +fi + +if [[ $WAITFORIT_CLI != "" ]]; then + if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then + echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess" + exit $WAITFORIT_RESULT + fi + exec "${WAITFORIT_CLI[@]}" +else + exit $WAITFORIT_RESULT +fi \ No newline at end of file diff --git a/.run/ShareItGateway.run.xml b/.run/ShareItGateway.run.xml new file mode 100644 index 0000000..32c8129 --- /dev/null +++ b/.run/ShareItGateway.run.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/.run/ShareItServer.run.xml b/.run/ShareItServer.run.xml new file mode 100644 index 0000000..a8ed9e5 --- /dev/null +++ b/.run/ShareItServer.run.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2807e14 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,39 @@ +version: '3.8' +services: + gateway: + build: gateway + image: gateway_image + container_name: gateway_container + ports: + - "8080:8080" + depends_on: + - server + environment: + - SHAREIT_SERVER_URL=http://server:9090 + + server: + build: server + image: server_image + container_name: server_container + ports: + - "9090:9090" + depends_on: + - db + environment: + - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/shareit + - DB_NAME=shareit + - SPRING_DATASOURCE_USERNAME=root + - SPRING_DATASOURCE_PASSWORD=password + - DB_HOST=db + - DB_PORT=6541 + + db: + image: postgres:13.7-alpine + container_name: shareit_bd_container + ports: + - "6541:5432" + environment: + - POSTGRES_DB=shareit + - POSTGRES_USER=root + - POSTGRES_PASSWORD=password + - TZ=Europe/Moscow \ No newline at end of file diff --git a/gateway/Dockerfile b/gateway/Dockerfile new file mode 100644 index 0000000..0939c6e --- /dev/null +++ b/gateway/Dockerfile @@ -0,0 +1,3 @@ +FROM amazoncorretto:11 +COPY target/*.jar app.jar +ENTRYPOINT ["java","-jar","/app.jar"] \ No newline at end of file diff --git a/gateway/pom.xml b/gateway/pom.xml new file mode 100644 index 0000000..ce8b4aa --- /dev/null +++ b/gateway/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + ru.practicum + shareit + 0.0.1-SNAPSHOT + + + shareit-gateway + 0.0.1-SNAPSHOT + + ShareIt Gateway + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-validation + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.apache.httpcomponents + httpclient + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + org.projectlombok + lombok + true + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/gateway/src/main/java/ru/practicum/shareit/ShareItGateway.java b/gateway/src/main/java/ru/practicum/shareit/ShareItGateway.java new file mode 100644 index 0000000..0aa75c3 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/ShareItGateway.java @@ -0,0 +1,12 @@ +package ru.practicum.shareit; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ShareItGateway { + public static void main(String[] args) { + SpringApplication.run(ShareItGateway.class, args); + } + +} diff --git a/gateway/src/main/java/ru/practicum/shareit/booking/BookingClient.java b/gateway/src/main/java/ru/practicum/shareit/booking/BookingClient.java new file mode 100644 index 0000000..1b27712 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/booking/BookingClient.java @@ -0,0 +1,70 @@ +package ru.practicum.shareit.booking; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.stereotype.Service; +import org.springframework.web.util.DefaultUriBuilderFactory; +import ru.practicum.shareit.booking.dto.BookingIncomingDto; +import ru.practicum.shareit.client.BaseClient; + +import java.util.Map; + +@Service +public class BookingClient extends BaseClient { + private static final String API_PREFIX = "/bookings"; + public static final String BOOKING_INVALID_MESSAGE = "недопустимые значения времени бронирования: "; + + @Autowired + public BookingClient(@Value("${shareit-server.url}") String serverUrl, RestTemplateBuilder builder) { + super( + builder + .uriTemplateHandler(new DefaultUriBuilderFactory(serverUrl + API_PREFIX)) + .requestFactory(HttpComponentsClientHttpRequestFactory::new) + .build() + ); + } + + public ResponseEntity createBooking(BookingIncomingDto dto, Long userId) { + if (!isStartBeforeEnd(dto)) { + throw new IllegalArgumentException(BOOKING_INVALID_MESSAGE + + "start: " + dto.getStart() + " end: " + dto.getEnd() + " now: "); + } + return post("", userId, dto); + } + + public ResponseEntity patchBooking(Long bookingId, Boolean approved, Long userId) { + Map parameters = Map.of( + "approved", approved + ); + return patch("/" + bookingId + "?approved={approved}", userId, parameters); + } + + public ResponseEntity findById(Long bookingId, Long userId) { + return get("/" + bookingId, userId); + } + + public ResponseEntity findAllByBooker(String state, Long userId, int from, int size) { + Map parameters = Map.of( + "state", state, + "from", from, + "size", size + ); + return get("?state={state}&from={from}&size={size}", userId, parameters); + } + + public ResponseEntity findAllByItemOwner(String state, Long userId, int from, int size) { + Map parameters = Map.of( + "state", state, + "from", from, + "size", size + ); + return get("/owner?state={state}&from={from}&size={size}", userId, parameters); + } + + private boolean isStartBeforeEnd(BookingIncomingDto dto) { + return dto.getStart().isBefore(dto.getEnd()); + } +} \ No newline at end of file diff --git a/gateway/src/main/java/ru/practicum/shareit/booking/BookingController.java b/gateway/src/main/java/ru/practicum/shareit/booking/BookingController.java new file mode 100644 index 0000000..137edcc --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/booking/BookingController.java @@ -0,0 +1,72 @@ +package ru.practicum.shareit.booking; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import ru.practicum.shareit.booking.dto.BookingIncomingDto; + +import javax.validation.Valid; +import javax.validation.constraints.Min; +import javax.validation.constraints.PositiveOrZero; + +@Slf4j +@Validated +@RestController +@RequiredArgsConstructor +@RequestMapping(path = "/bookings") +public class BookingController { + + public static final int MIN_VALUE = 0; + public static final String DEFAULT_FROM_VALUE = "0"; + public static final String DEFAULT_SIZE_VALUE = "20"; + public static final String DEFAULT_STATE_VALUE = "ALL"; + public static final String USER_ID_HEADER = "X-Sharer-User-Id"; + + private final BookingClient bookingClient; + + @PostMapping + public ResponseEntity createBooking(@RequestBody @Valid BookingIncomingDto dto, + @RequestHeader(USER_ID_HEADER) Long userId) { + log.info("Creating booking {}, userId={}", dto, userId); + return bookingClient.createBooking(dto, userId); + } + + @PatchMapping("/{bookingId}") + public ResponseEntity patchBooking(@PathVariable Long bookingId, + @RequestParam Boolean approved, + @RequestHeader(USER_ID_HEADER) Long userId) { + log.info("Path booking {}, approved={}. userId={}", bookingId, approved, userId); + return bookingClient.patchBooking(bookingId, approved, userId); + } + + @GetMapping("/{bookingId}") + public ResponseEntity findById(@PathVariable Long bookingId, + @RequestHeader(USER_ID_HEADER) Long userId) { + log.info("Get booking {}, userId={}", bookingId, userId); + return bookingClient.findById(bookingId, userId); + } + + @GetMapping + public ResponseEntity findAllBookings(@RequestParam(defaultValue = DEFAULT_STATE_VALUE) String state, + @RequestHeader(USER_ID_HEADER) Long userId, + @RequestParam(defaultValue = DEFAULT_FROM_VALUE) + @Min(MIN_VALUE) int from, + @RequestParam(defaultValue = DEFAULT_SIZE_VALUE) + @PositiveOrZero int size) { + log.info("Get booking with state {}, userId={}, from={}, size={}", state, userId, from, size); + return bookingClient.findAllByBooker(state, userId, from, size); + } + + @GetMapping("/owner") + public ResponseEntity findAllByItemOwner(@RequestParam(defaultValue = DEFAULT_STATE_VALUE) String state, + @RequestHeader(USER_ID_HEADER) Long userId, + @RequestParam(defaultValue = DEFAULT_FROM_VALUE) + @Min(MIN_VALUE) int from, + @RequestParam(defaultValue = DEFAULT_SIZE_VALUE) + @PositiveOrZero int size) { + log.info("Get bookings owner with state{}, userId={}, from={}, size={}", state, userId, from, size); + return bookingClient.findAllByItemOwner(state, userId, from, size); + } +} \ No newline at end of file diff --git a/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingInItemDto.java b/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingInItemDto.java new file mode 100644 index 0000000..58a3c5d --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingInItemDto.java @@ -0,0 +1,19 @@ +package ru.practicum.shareit.booking.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.time.LocalDateTime; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class BookingInItemDto { + private Long id; + private Long bookerId; + private LocalDateTime start; + private LocalDateTime end; +} diff --git a/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingIncomingDto.java b/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingIncomingDto.java new file mode 100644 index 0000000..0488a97 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingIncomingDto.java @@ -0,0 +1,26 @@ +package ru.practicum.shareit.booking.dto; + +import lombok.*; + +import javax.validation.constraints.Future; +import javax.validation.constraints.FutureOrPresent; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@Getter +@Setter +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class BookingIncomingDto { + + private Long id; + + private Long itemId; + @NotNull + @FutureOrPresent + private LocalDateTime start; + @NotNull + @Future + private LocalDateTime end; +} diff --git a/gateway/src/main/java/ru/practicum/shareit/booking/dto/State.java b/gateway/src/main/java/ru/practicum/shareit/booking/dto/State.java new file mode 100644 index 0000000..e1982c2 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/booking/dto/State.java @@ -0,0 +1,11 @@ +package ru.practicum.shareit.booking.dto; + +public enum State { + + ALL, + CURRENT, + FUTURE, + PAST, + REJECTED, + WAITING +} diff --git a/gateway/src/main/java/ru/practicum/shareit/client/BaseClient.java b/gateway/src/main/java/ru/practicum/shareit/client/BaseClient.java new file mode 100644 index 0000000..1a2d33a --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/client/BaseClient.java @@ -0,0 +1,121 @@ +package ru.practicum.shareit.client; + +import java.util.List; +import java.util.Map; + +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.lang.Nullable; +import org.springframework.web.client.HttpStatusCodeException; +import org.springframework.web.client.RestTemplate; + +public class BaseClient { + protected final RestTemplate rest; + + public BaseClient(RestTemplate rest) { + this.rest = rest; + } + + protected ResponseEntity get(String path) { + return get(path, null, null); + } + + protected ResponseEntity get(String path, long userId) { + return get(path, userId, null); + } + + protected ResponseEntity get(String path, Long userId, @Nullable Map parameters) { + return makeAndSendRequest(HttpMethod.GET, path, userId, parameters, null); + } + + protected ResponseEntity post(String path, T body) { + return post(path, null, null, body); + } + + protected ResponseEntity post(String path, long userId, T body) { + return post(path, userId, null, body); + } + + protected ResponseEntity post(String path, Long userId, @Nullable Map parameters, T body) { + return makeAndSendRequest(HttpMethod.POST, path, userId, parameters, body); + } + + protected ResponseEntity put(String path, long userId, T body) { + return put(path, userId, null, body); + } + + protected ResponseEntity put(String path, long userId, @Nullable Map parameters, T body) { + return makeAndSendRequest(HttpMethod.PUT, path, userId, parameters, body); + } + + protected ResponseEntity patch(String path, T body) { + return patch(path, null, null, body); + } + + protected ResponseEntity patch(String path, long userId) { + return patch(path, userId, null, null); + } + + protected ResponseEntity patch(String path, long userId, T body) { + return patch(path, userId, null, body); + } + + protected ResponseEntity patch(String path, Long userId, @Nullable Map parameters, T body) { + return makeAndSendRequest(HttpMethod.PATCH, path, userId, parameters, body); + } + + protected ResponseEntity delete(String path) { + return delete(path, null, null); + } + + protected ResponseEntity delete(String path, long userId) { + return delete(path, userId, null); + } + + protected ResponseEntity delete(String path, Long userId, @Nullable Map parameters) { + return makeAndSendRequest(HttpMethod.DELETE, path, userId, parameters, null); + } + + private ResponseEntity makeAndSendRequest(HttpMethod method, String path, Long userId, @Nullable Map parameters, @Nullable T body) { + HttpEntity requestEntity = new HttpEntity<>(body, defaultHeaders(userId)); + + ResponseEntity shareitServerResponse; + try { + if (parameters != null) { + shareitServerResponse = rest.exchange(path, method, requestEntity, Object.class, parameters); + } else { + shareitServerResponse = rest.exchange(path, method, requestEntity, Object.class); + } + } catch (HttpStatusCodeException e) { + return ResponseEntity.status(e.getStatusCode()).body(e.getResponseBodyAsByteArray()); + } + return prepareGatewayResponse(shareitServerResponse); + } + + private HttpHeaders defaultHeaders(Long userId) { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.setAccept(List.of(MediaType.APPLICATION_JSON)); + if (userId != null) { + headers.set("X-Sharer-User-Id", String.valueOf(userId)); + } + return headers; + } + + private static ResponseEntity prepareGatewayResponse(ResponseEntity response) { + if (response.getStatusCode().is2xxSuccessful()) { + return response; + } + + ResponseEntity.BodyBuilder responseBuilder = ResponseEntity.status(response.getStatusCode()); + + if (response.hasBody()) { + return responseBuilder.body(response.getBody()); + } + + return responseBuilder.build(); + } +} diff --git a/gateway/src/main/java/ru/practicum/shareit/error_handler/ErrorHandler.java b/gateway/src/main/java/ru/practicum/shareit/error_handler/ErrorHandler.java new file mode 100644 index 0000000..c4ce726 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/error_handler/ErrorHandler.java @@ -0,0 +1,34 @@ +package ru.practicum.shareit.error_handler; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@Slf4j +@RestControllerAdvice +public class ErrorHandler { + + @ExceptionHandler + @ResponseStatus(HttpStatus.BAD_REQUEST) + public ErrorResponse handle(MethodArgumentNotValidException e) { + log.warn("Ошибка валидации", e); + return new ErrorResponse("Ошибка валидации 400: ", e.getMessage()); + } + + @ExceptionHandler + @ResponseStatus(HttpStatus.BAD_REQUEST) + public ErrorResponse handle(IllegalArgumentException e) { + log.warn("Недопустимое значение", e); + return new ErrorResponse("Передано недопустимое значение 400: ", e.getMessage()); + } + + @ExceptionHandler + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public ErrorResponse handle(Throwable e) { + log.warn("Непредвиденная ошибка сервера", e); + return new ErrorResponse("непредвиденная ошибка сервера 500: ", e.getMessage()); + } +} diff --git a/gateway/src/main/java/ru/practicum/shareit/error_handler/ErrorResponse.java b/gateway/src/main/java/ru/practicum/shareit/error_handler/ErrorResponse.java new file mode 100644 index 0000000..c1a05a9 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/error_handler/ErrorResponse.java @@ -0,0 +1,19 @@ +package ru.practicum.shareit.error_handler; + +public class ErrorResponse { + private final String error; + private final String description; + + public ErrorResponse(String error, String description) { + this.error = error; + this.description = description; + } + + public String getError() { + return error; + } + + public String getDescription() { + return description; + } +} diff --git a/gateway/src/main/java/ru/practicum/shareit/item/ItemClient.java b/gateway/src/main/java/ru/practicum/shareit/item/ItemClient.java new file mode 100644 index 0000000..fb20850 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/item/ItemClient.java @@ -0,0 +1,62 @@ +package ru.practicum.shareit.item; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.stereotype.Service; +import org.springframework.web.util.DefaultUriBuilderFactory; +import ru.practicum.shareit.client.BaseClient; +import ru.practicum.shareit.item.dto.CreateCommentDto; +import ru.practicum.shareit.item.dto.ItemDto; + +import java.util.Map; + +@Service +public class ItemClient extends BaseClient { + private static final String API_PREFIX = "/items"; + + @Autowired + public ItemClient(@Value("${shareit-server.url}") String serverUrl, RestTemplateBuilder builder) { + super( + builder + .uriTemplateHandler(new DefaultUriBuilderFactory(serverUrl + API_PREFIX)) + .requestFactory(HttpComponentsClientHttpRequestFactory::new) + .build() + ); + } + + public ResponseEntity createItem(ItemDto itemDto, Long userId) { + return post("", userId, itemDto); + } + + public ResponseEntity createComment(CreateCommentDto commentDto, Long itemId, Long userId) { + return post("/" + itemId + "/comment", userId, commentDto); + } + + public ResponseEntity updateItem(ItemDto itemDto, Long itemId, Long userId) { + return patch("/" + itemId, userId, itemDto); + } + + public ResponseEntity findItemById(Long itemId, Long userId) { + return get("/" + itemId, userId); + } + + public ResponseEntity findAllItems(Long userId, int from, int size) { + Map parameters = Map.of( + "from", from, + "size", size + ); + return get("?from={from}&size={size}", userId, parameters); + } + + public ResponseEntity findItemsByRequest(String text, Long userId, int from, int size) { + Map parameters = Map.of( + "text", text, + "from", from, + "size", size + ); + return get("/search?text={text}&from={from}&size={size}", userId, parameters); + } +} diff --git a/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java b/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java new file mode 100644 index 0000000..0901cdd --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java @@ -0,0 +1,87 @@ +package ru.practicum.shareit.item; + +import lombok.AllArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import ru.practicum.shareit.item.dto.CreateCommentDto; +import ru.practicum.shareit.item.dto.ItemDto; + +import javax.validation.Valid; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +@RestController +@AllArgsConstructor +@RequestMapping(path = "/items") +public class ItemController { + + public static final int MIN_VALUE = 1; + public static final String DEFAULT_FROM_VALUE = "0"; + public static final String DEFAULT_SIZE_VALUE = "20"; + public static final String USER_ID_HEADER = "X-Sharer-User-Id"; + public static final String NULL_ITEM_ID_MESSAGE = "itemID is null"; + public static final String NULL_USER_ID_MESSAGE = "userID is null"; + + private final ItemClient itemClient; + + @PostMapping + public ResponseEntity createItem(@Valid + @RequestBody ItemDto itemDto, + @NotNull(message = (NULL_ITEM_ID_MESSAGE)) + @Min(MIN_VALUE) + @RequestHeader(USER_ID_HEADER) Long userId) { + return itemClient.createItem(itemDto, userId); + } + + @PostMapping("/{itemId}/comment") + public ResponseEntity createComment(@Valid + @RequestBody CreateCommentDto commentDto, + @NotNull(message = (NULL_ITEM_ID_MESSAGE)) + @Min(MIN_VALUE) + @PathVariable Long itemId, + @NotNull(message = (NULL_USER_ID_MESSAGE)) + @Min(MIN_VALUE) + @RequestHeader(USER_ID_HEADER) Long userId) { + return itemClient.createComment(commentDto, itemId, userId); + } + + @PatchMapping("/{itemId}") + public ResponseEntity updateItem(@Valid + @RequestBody ItemDto itemDto, + @NotNull(message = NULL_ITEM_ID_MESSAGE) + @Min(MIN_VALUE) + @PathVariable Long itemId, + @NotNull(message = NULL_USER_ID_MESSAGE) + @Min(MIN_VALUE) + @RequestHeader(USER_ID_HEADER) Long userId) { + return itemClient.updateItem(itemDto, itemId, userId); + } + + @GetMapping("/{itemId}") + public ResponseEntity findItemById(@NotNull(message = NULL_ITEM_ID_MESSAGE) + @Min(MIN_VALUE) + @PathVariable Long itemId, + @RequestHeader(USER_ID_HEADER) Long userId) { + return itemClient.findItemById(itemId, userId); + } + + @GetMapping + public ResponseEntity findAllItems(@NotNull(message = NULL_USER_ID_MESSAGE) + @RequestHeader(USER_ID_HEADER) Long userId, + @RequestParam(defaultValue = DEFAULT_FROM_VALUE) + @Min(MIN_VALUE) int from, + @RequestParam(defaultValue = DEFAULT_SIZE_VALUE) + @Min(MIN_VALUE) int size) { + return itemClient.findAllItems(userId, from, size); + } + + @GetMapping("/search") + public ResponseEntity findItemsByRequest(@RequestParam String text, + @RequestHeader(USER_ID_HEADER) Long userId, + @RequestParam(defaultValue = DEFAULT_FROM_VALUE) + @Min(MIN_VALUE) int from, + @RequestParam(defaultValue = DEFAULT_SIZE_VALUE) + @Min(MIN_VALUE) int size) { + return itemClient.findItemsByRequest(text, userId, from, size); + } +} \ No newline at end of file diff --git a/gateway/src/main/java/ru/practicum/shareit/item/dto/CommentDto.java b/gateway/src/main/java/ru/practicum/shareit/item/dto/CommentDto.java new file mode 100644 index 0000000..1a496b4 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/item/dto/CommentDto.java @@ -0,0 +1,18 @@ +package ru.practicum.shareit.item.dto; + +import lombok.*; + +import java.time.LocalDateTime; + +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CommentDto { + + private Long id; + private String text; + private String authorName; + private LocalDateTime created; +} diff --git a/gateway/src/main/java/ru/practicum/shareit/item/dto/CreateCommentDto.java b/gateway/src/main/java/ru/practicum/shareit/item/dto/CreateCommentDto.java new file mode 100644 index 0000000..41acbfe --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/item/dto/CreateCommentDto.java @@ -0,0 +1,15 @@ +package ru.practicum.shareit.item.dto; + +import lombok.*; + +import javax.validation.constraints.NotBlank; + +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreateCommentDto { + @NotBlank + private String text; +} diff --git a/gateway/src/main/java/ru/practicum/shareit/item/dto/ItemDto.java b/gateway/src/main/java/ru/practicum/shareit/item/dto/ItemDto.java new file mode 100644 index 0000000..9b76b30 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/item/dto/ItemDto.java @@ -0,0 +1,31 @@ +package ru.practicum.shareit.item.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import ru.practicum.shareit.booking.dto.BookingInItemDto; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.List; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class ItemDto { + + private Long id; + @NotBlank + private String name; + @NotBlank + private String description; + @NotNull + private Boolean available; + private BookingInItemDto lastBooking; + private BookingInItemDto nextBooking; + private List comments; + private Long requestId; + +} diff --git a/gateway/src/main/java/ru/practicum/shareit/request/ItemRequestController.java b/gateway/src/main/java/ru/practicum/shareit/request/ItemRequestController.java new file mode 100644 index 0000000..4c89d17 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/request/ItemRequestController.java @@ -0,0 +1,51 @@ +package ru.practicum.shareit.request; + +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import ru.practicum.shareit.request.dto.ItemRequestIncomingDto; + +import javax.validation.Valid; +import javax.validation.constraints.Min; + +@Validated +@RestController +@RequiredArgsConstructor +@RequestMapping(path = "/requests") +public class ItemRequestController { + + public static final int MIN_VALUE = 0; + public static final String DEFAULT_FROM_VALUE = "0"; + public static final String DEFAULT_SIZE_VALUE = "20"; + public static final String USER_ID_HEADER = "X-Sharer-User-Id"; + + private final RequestClient requestClient; + + @PostMapping + public ResponseEntity createRequest(@Valid + @RequestBody ItemRequestIncomingDto incomingItemRequestDto, + @RequestHeader(USER_ID_HEADER) Long userId) { + return requestClient.createRequest(incomingItemRequestDto, userId); + } + + @GetMapping + public ResponseEntity findAllByUserId(@RequestHeader(USER_ID_HEADER) Long userId) { + return requestClient.findAllByUserId(userId); + } + + @GetMapping ("/all") + public ResponseEntity findAll(@RequestParam(defaultValue = DEFAULT_FROM_VALUE) + @Min(MIN_VALUE) int from, + @RequestParam(defaultValue = DEFAULT_SIZE_VALUE) + @Min(MIN_VALUE) int size, + @RequestHeader(USER_ID_HEADER) Long userId) { + return requestClient.findAll(from, size, userId); + } + + @GetMapping("/{requestId}") + public ResponseEntity findById(@PathVariable Long requestId, + @RequestHeader(USER_ID_HEADER) Long userId) { + return requestClient.findById(requestId, userId); + } +} diff --git a/gateway/src/main/java/ru/practicum/shareit/request/RequestClient.java b/gateway/src/main/java/ru/practicum/shareit/request/RequestClient.java new file mode 100644 index 0000000..ebabee9 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/request/RequestClient.java @@ -0,0 +1,48 @@ +package ru.practicum.shareit.request; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.stereotype.Service; +import org.springframework.web.util.DefaultUriBuilderFactory; +import ru.practicum.shareit.client.BaseClient; +import ru.practicum.shareit.request.dto.ItemRequestIncomingDto; + +import java.util.Map; + +@Service +public class RequestClient extends BaseClient { + private static final String API_PREFIX = "/requests"; + + @Autowired + public RequestClient(@Value("${shareit-server.url}") String serverUrl, RestTemplateBuilder builder) { + super( + builder + .uriTemplateHandler(new DefaultUriBuilderFactory(serverUrl + API_PREFIX)) + .requestFactory(HttpComponentsClientHttpRequestFactory::new) + .build() + ); + } + + public ResponseEntity createRequest(ItemRequestIncomingDto incomingItemRequestDto, Long userId) { + return post("", userId, incomingItemRequestDto); + } + + public ResponseEntity findAllByUserId(Long userId) { + return get("", userId); + } + + public ResponseEntity findAll(int from, int size, Long userId) { + Map parameters = Map.of( + "from", from, + "size", size + ); + return get("/all?from={from}&size={size}", userId, parameters); + } + + public ResponseEntity findById(Long requestId, Long userId) { + return get("/" + requestId, userId); + } +} diff --git a/gateway/src/main/java/ru/practicum/shareit/request/dto/ItemRequestIncomingDto.java b/gateway/src/main/java/ru/practicum/shareit/request/dto/ItemRequestIncomingDto.java new file mode 100644 index 0000000..1d0fe43 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/request/dto/ItemRequestIncomingDto.java @@ -0,0 +1,16 @@ +package ru.practicum.shareit.request.dto; + +import lombok.*; + +import javax.validation.constraints.NotBlank; + +@Setter +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ItemRequestIncomingDto { + + @NotBlank + private String description; +} diff --git a/gateway/src/main/java/ru/practicum/shareit/user/UserClient.java b/gateway/src/main/java/ru/practicum/shareit/user/UserClient.java new file mode 100644 index 0000000..0a1c496 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/user/UserClient.java @@ -0,0 +1,45 @@ +package ru.practicum.shareit.user; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.stereotype.Service; +import org.springframework.web.util.DefaultUriBuilderFactory; +import ru.practicum.shareit.client.BaseClient; + +@Service +public class UserClient extends BaseClient { + private static final String API_PREFIX = "/users"; + + @Autowired + public UserClient(@Value("${shareit-server.url}") String serverUrl, RestTemplateBuilder builder) { + super( + builder + .uriTemplateHandler(new DefaultUriBuilderFactory(serverUrl + API_PREFIX)) + .requestFactory(HttpComponentsClientHttpRequestFactory::new) + .build() + ); + } + + public ResponseEntity createUser(UserDto userDto) { + return post("", userDto); + } + + public ResponseEntity findUserById(Long userId) { + return get("/" + userId); + } + + public ResponseEntity findAllUsers() { + return get(""); + } + + public ResponseEntity updateUser(Long userId, UserDto userDto) { + return patch("/" + userId, userDto); + } + + public void deleteUserById(Long userId) { + delete("/" + userId); + } +} diff --git a/gateway/src/main/java/ru/practicum/shareit/user/UserController.java b/gateway/src/main/java/ru/practicum/shareit/user/UserController.java new file mode 100644 index 0000000..37a147a --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/user/UserController.java @@ -0,0 +1,60 @@ +package ru.practicum.shareit.user; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +@Slf4j +@RestController +@RequiredArgsConstructor +@RequestMapping(path = "/users") +public class UserController { + + public static final int MIN_ID_VALUE = 1; + public static final String NULL_USER_ID_MESSAGE = "userID is null"; + + private final UserClient userClient; + + @PostMapping + public ResponseEntity createUser(@Valid @RequestBody UserDto userDto) { + log.info("Creating user {}", userDto); + return userClient.createUser(userDto); + } + + @GetMapping("/{userId}") + public ResponseEntity findUserById(@NotNull(message = (NULL_USER_ID_MESSAGE)) + @Min(MIN_ID_VALUE) + @PathVariable Long userId) { + log.info("Searching userId={}", userId); + return userClient.findUserById(userId); + } + + @GetMapping + public ResponseEntity findAllUsers() { + log.info("Searching all users"); + return userClient.findAllUsers(); + } + + @PatchMapping("/{userId}") + public ResponseEntity updateUser(@NotNull(message = NULL_USER_ID_MESSAGE) + @Min(MIN_ID_VALUE) + @PathVariable Long userId, + @Valid + @RequestBody UserDto userDto) { + log.info("Updating userId={}, user {}", userId, userDto); + return userClient.updateUser(userId, userDto); + } + + @DeleteMapping("/{userId}") + public void deleteUserById(@NotNull(message = (NULL_USER_ID_MESSAGE)) + @Min(MIN_ID_VALUE) + @PathVariable Long userId) { + log.info("Deleting userId={}", userId); + userClient.deleteUserById(userId); + } +} diff --git a/gateway/src/main/java/ru/practicum/shareit/user/UserDto.java b/gateway/src/main/java/ru/practicum/shareit/user/UserDto.java new file mode 100644 index 0000000..5288e6a --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/user/UserDto.java @@ -0,0 +1,21 @@ +package ru.practicum.shareit.user; + +import lombok.*; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotNull; + +@Getter +@Setter +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class UserDto { + private Long id; + @NotNull + private String name; + @Email + @NotNull + private String email; + +} diff --git a/gateway/src/main/resources/application.properties b/gateway/src/main/resources/application.properties new file mode 100644 index 0000000..2ee0851 --- /dev/null +++ b/gateway/src/main/resources/application.properties @@ -0,0 +1,7 @@ +logging.level.org.springframework.web.client.RestTemplate=DEBUG +#logging.level.org.apache.http=DEBUG +#logging.level.httpclient.wire=DEBUG + +server.port=8080 + +shareit-server.url=http://localhost:9090 \ No newline at end of file diff --git a/pom.xml b/pom.xml index a1024da..7d33e46 100644 --- a/pom.xml +++ b/pom.xml @@ -11,101 +11,37 @@ ru.practicum shareit + pom 0.0.1-SNAPSHOT ShareIt - 11 + 11 + 11 + UTF-8 - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.postgresql - postgresql - runtime - - - com.h2database - h2 - runtime - - - org.postgresql - postgresql - runtime - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - 2.14.2 - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.projectlombok - lombok - true - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.boot - spring-boot-starter-validation - - - - commons-validator - commons-validator - 1.4.1 - - + + gateway + server + - - - src/main/resources - true - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.projectlombok - lombok - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 11 - 11 - - - + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + org.apache.maven.plugins maven-surefire-plugin @@ -115,6 +51,14 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + true + + org.apache.maven.plugins maven-checkstyle-plugin @@ -189,7 +133,7 @@ LINE COVEREDRATIO - 0.7 + 0.9 BRANCH @@ -252,17 +196,5 @@ - - coverage - - - - org.jacoco - jacoco-maven-plugin - - - - - diff --git a/postman/sprint.json b/postman/sprint.json new file mode 100644 index 0000000..d5d4403 --- /dev/null +++ b/postman/sprint.json @@ -0,0 +1,11050 @@ +{ + "info": { + "_postman_id": "02b3b696-d51d-4750-b4dc-35e6712fd023", + "name": "Sprint 16 ShareIt (add-docker)", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "2036415" + }, + "item": [ + { + "name": "users", + "item": [ + { + "name": "User 1 create", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has user create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test user 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test user 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('email');", + " pm.expect(jsonData.email, '\"email\" must be \"user@user.com\"').to.eql('user@user.com');", + "});", + "pm.test(\"Test user 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"user\"').to.eql('user');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"user\",\n \"email\": \"user@user.com\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users" + ] + } + }, + "response": [] + }, + { + "name": "User 2 create fail duplicate email", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 409\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([409, 500]);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"user\",\n \"email\": \"user@user.com\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users" + ] + } + }, + "response": [] + }, + { + "name": "User create fail no email", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"user\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users" + ] + } + }, + "response": [] + }, + { + "name": "User create fail invalid email", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"user\",\n \"email\": \"user.com\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users" + ] + } + }, + "response": [] + }, + { + "name": "User 1 update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has user update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test user 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test user 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('email');", + " pm.expect(jsonData.email, '\"email\" must be \"update@user.com\"').to.eql('update@user.com');", + "});", + "pm.test(\"Test user 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"update\"').to.eql('update');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"update\",\n \"email\": \"update@user.com\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users/:userId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users", + ":userId" + ], + "variable": [ + { + "key": "userId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "User 3 create", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has user create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test user 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 3').to.eql(3);", + "});", + "pm.test(\"Test user 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('email');", + " pm.expect(jsonData.email, '\"email\" must be \"user@user.com\"').to.eql('user@user.com');", + "});", + "pm.test(\"Test user 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"user\"').to.eql('user');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"user\",\n \"email\": \"user@user.com\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users" + ] + } + }, + "response": [] + }, + { + "name": "User 1 update name", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has user update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test user 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test user 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('email');", + " pm.expect(jsonData.email, '\"email\" must be \"update@user.com\"').to.eql('update@user.com');", + "});", + "pm.test(\"Test user 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"updateName\"').to.eql('updateName');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"updateName\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users/:userId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users", + ":userId" + ], + "variable": [ + { + "key": "userId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "User 1 update email", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has user update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test user 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test user 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('email');", + " pm.expect(jsonData.email, '\"email\" must be \"updateName@user.com\"').to.eql('updateName@user.com');", + "});", + "pm.test(\"Test user 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"updateName\"').to.eql('updateName');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"email\": \"updateName@user.com\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users/:userId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users", + ":userId" + ], + "variable": [ + { + "key": "userId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "User 1 update with same email", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has user update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test user 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test user 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('email');", + " pm.expect(jsonData.email, '\"email\" must be \"updateName@user.com\"').to.eql('updateName@user.com');", + "});", + "pm.test(\"Test user 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"updateName\"').to.eql('updateName');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"email\": \"updateName@user.com\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users/:userId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users", + ":userId" + ], + "variable": [ + { + "key": "userId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "User 1 name update fail email exists", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 409\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([409, 500]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"email\": \"user@user.com\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users/:userId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users", + ":userId" + ], + "variable": [ + { + "key": "userId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "User 1 get updated", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has user update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test user 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test user 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('email');", + " pm.expect(jsonData.email, '\"email\" must be \"updateName@user.com\"').to.eql('updateName@user.com');", + "});", + "pm.test(\"Test user 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"updateName\"').to.eql('updateName');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/users/:userId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users", + ":userId" + ], + "variable": [ + { + "key": "userId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "User 3 get", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has user update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test user 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 3').to.eql(3);", + "});", + "pm.test(\"Test user 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('email');", + " pm.expect(jsonData.email, '\"email\" must be \"user@user.com\"').to.eql('user@user.com');", + "});", + "pm.test(\"Test user 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"user\"').to.eql('user');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/users/:userId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users", + ":userId" + ], + "variable": [ + { + "key": "userId", + "value": "3" + } + ] + } + }, + "response": [] + }, + { + "name": "User 100 get unkonwn", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([404]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/users/:userId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users", + ":userId" + ], + "variable": [ + { + "key": "userId", + "value": "100" + } + ] + } + }, + "response": [] + }, + { + "name": "User 3 delete", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,204]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/users/:userId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users", + ":userId" + ], + "variable": [ + { + "key": "userId", + "value": "3" + } + ] + } + }, + "response": [] + }, + { + "name": "User 4 create after delete", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has user create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test user 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 4').to.eql(4);", + "});", + "pm.test(\"Test user 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('email');", + " pm.expect(jsonData.email, '\"email\" must be \"user@user.com\"').to.eql('user@user.com');", + "});", + "pm.test(\"Test user 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"user\"').to.eql('user');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"user\",\n \"email\": \"user@user.com\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users" + ] + } + }, + "response": [] + }, + { + "name": "User get all", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list user response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test user[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test user[0] 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('email');", + " pm.expect(jsonData[0].email, '\"email\" must be \"updateName@user.com\"').to.eql('updateName@user.com');", + "});", + "pm.test(\"Test user[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('name');", + " pm.expect(jsonData[0].name, '\"name\" must be \"updateName\"').to.eql('updateName');", + "});", + "", + "pm.test(\"Test user[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 4').to.eql(4);", + "});", + "pm.test(\"Test user[1] 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('email');", + " pm.expect(jsonData[1].email, '\"email\" must be \"user@user.com\"').to.eql('user@user.com');", + "});", + "pm.test(\"Test user[1] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('name');", + " pm.expect(jsonData[1].name, '\"name\" must be \"user\"').to.eql('user');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "items", + "item": [ + { + "name": "Item 1 create by user 1", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has item create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Дрель\"').to.eql('Дрель');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Простая дрель\"').to.eql('Простая дрель');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Дрель\",\n \"description\": \"Простая дрель\",\n \"available\": true\n}" + }, + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Item create without X-Sharer-User-Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 500\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500, 400]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text", + "disabled": true + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Дрель\",\n \"description\": \"Простая дрель\",\n \"available\": true\n}" + }, + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Item create with not found user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([404,403]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "10", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Дрель\",\n \"description\": \"Простая дрель\",\n \"available\": true\n}" + }, + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Item create without available", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "3", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Отвертка\",\n \"description\": \"Аккумуляторная отвертка\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Item create with empty name", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "3", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"\",\n \"description\": \"Аккумуляторная отвертка\",\n \"available\": true\n}" + }, + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Item create with empty description", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "3", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Отвертка\",\n \"available\": true\n}" + }, + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "item 1 update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Дрель+\"').to.eql('Дрель+');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"false\"').to.false;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": 1,\n \"name\": \"Дрель+\",\n \"description\": \"Аккумуляторная дрель\",\n \"available\": false\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "item 1 update without X-Sharer-User-Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 500\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500, 400]);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text", + "disabled": true + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": 1,\n \"name\": \"Дрель\",\n \"description\": \"Простая дрель\",\n \"available\": false\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "item 1 update with other user 3", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500, 404, 403]);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "3", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Дрель\",\n \"description\": \"Простая дрель\",\n \"available\": false\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "item 1 update available", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Дрель+\"').to.eql('Дрель+');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"available\": true\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "item 1 update description", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Дрель+\"').to.eql('Дрель+');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная дрель + аккумулятор\"').to.eql('Аккумуляторная дрель + аккумулятор');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"description\": \"Аккумуляторная дрель + аккумулятор\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "item 1 update name", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная дрель + аккумулятор\"').to.eql('Аккумуляторная дрель + аккумулятор');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Аккумуляторная дрель\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 1 get from owner user 1", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная дрель + аккумулятор\"').to.eql('Аккумуляторная дрель + аккумулятор');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 1 get from user 4", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200]);", + "});", + "pm.test(\"Test get item\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.id, '\"id\" field').to.eql(1);", + " pm.expect(jsonData.name, '\"name\" field').to.eql('Аккумуляторная дрель');", + " pm.expect(jsonData.description, '\"description\" field').to.eql('Аккумуляторная дрель + аккумулятор');", + " pm.expect(jsonData.available, '\"available\" field').to.true;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 100 get from user 4", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([404]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "100" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 2 create by user 4", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has item create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Отвертка\",\n \"description\": \"Аккумуляторная отвертка\",\n \"available\": true\n}" + }, + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Item 3 create by user 4", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has item create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 3').to.eql(3);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Клей Момент\"').to.eql('Клей Момент');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Тюбик суперклея марки Момент\"').to.eql('Тюбик суперклея марки Момент');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Клей Момент\",\n \"description\": \"Тюбик суперклея марки Момент\",\n \"available\": true\n}" + }, + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Item get all user 1", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list item response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "", + "pm.test(\"Test item[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('name');", + " pm.expect(jsonData[0].name, '\"name\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "pm.test(\"Test item[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('description');", + " pm.expect(jsonData[0].description, '\"description\" must be \"Аккумуляторная дрель + аккумулятор\"').to.eql('Аккумуляторная дрель + аккумулятор');", + "});", + "pm.test(\"Test item[0] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('available');", + " pm.expect(jsonData[0].available, '\"available\" must be \"true\"').to.true;", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Item get all user 4", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list item response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test item[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('name');", + " pm.expect(jsonData[0].name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('description');", + " pm.expect(jsonData[0].description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item[0] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('available');", + " pm.expect(jsonData[0].available, '\"available\" must be \"true\"').to.true;", + "});", + "", + "", + "pm.test(\"Test item[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 3').to.eql(3);", + "});", + "pm.test(\"Test item[1] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('name');", + " pm.expect(jsonData[1].name, '\"name\" must be \"Клей Момент\"').to.eql('Клей Момент');", + "});", + "pm.test(\"Test item[1] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('description');", + " pm.expect(jsonData[1].description, '\"description\" must be \"Тюбик суперклея марки Момент\"').to.eql('Тюбик суперклея марки Момент');", + "});", + "pm.test(\"Test item[1] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('available');", + " pm.expect(jsonData[1].available, '\"available\" must be \"true\"').to.true;", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Item search аккумуляторная", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list item response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test item[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('name');", + " pm.expect(jsonData[0].name, '\"name\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "pm.test(\"Test item[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('description');", + " pm.expect(jsonData[0].description, '\"description\" must be \"Аккумуляторная дрель + аккумулятор\"').to.eql('Аккумуляторная дрель + аккумулятор');", + "});", + "pm.test(\"Test item[0] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('available');", + " pm.expect(jsonData[0].available, '\"available\" must be \"true\"').to.true;", + "});", + "", + "pm.test(\"Test item[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item[1] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('name');", + " pm.expect(jsonData[1].name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item[1] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('description');", + " pm.expect(jsonData[1].description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item[1] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('available');", + " pm.expect(jsonData[1].available, '\"available\" must be \"true\"').to.true;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/search?text=аккУМУляторная", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + "search" + ], + "query": [ + { + "key": "text", + "value": "аккУМУляторная" + } + ] + } + }, + "response": [] + }, + { + "name": "item 2 update set unavailable", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"false\"').to.false;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"available\": false\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Item search дрель", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test search item response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "", + "pm.test(\"Test item[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('name');", + " pm.expect(jsonData[0].name, '\"name\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "pm.test(\"Test item[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('description');", + " pm.expect(jsonData[0].description, '\"description\" must be \"Аккумуляторная дрель + аккумулятор\"').to.eql('Аккумуляторная дрель + аккумулятор');", + "});", + "pm.test(\"Test item[0] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('available');", + " pm.expect(jsonData[0].available, '\"available\" must be \"true\"').to.true;", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/search?text=дРелЬ", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + "search" + ], + "query": [ + { + "key": "text", + "value": "дРелЬ" + } + ] + } + }, + "response": [] + }, + { + "name": "Item search аккумуляторная available", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test search item response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "", + "pm.test(\"Test item[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('name');", + " pm.expect(jsonData[0].name, '\"name\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "pm.test(\"Test item[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('description');", + " pm.expect(jsonData[0].description, '\"description\" must be \"Аккумуляторная дрель + аккумулятор\"').to.eql('Аккумуляторная дрель + аккумулятор');", + "});", + "pm.test(\"Test item[0] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('available');", + " pm.expect(jsonData[0].available, '\"available\" must be \"true\"').to.true;", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/search?text=аккУМУляторная", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + "search" + ], + "query": [ + { + "key": "text", + "value": "аккУМУляторная" + } + ] + } + }, + "response": [] + }, + { + "name": "item 2 update set available", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"available\": true\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Item search отвертка", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test search item response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "pm.test(\"Test item[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('name');", + " pm.expect(jsonData[0].name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('description');", + " pm.expect(jsonData[0].description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item[0] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('available');", + " pm.expect(jsonData[0].available, '\"available\" must be \"true\"').to.true;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/search?text=оТверТ", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + "search" + ], + "query": [ + { + "key": "text", + "value": "оТверТ" + } + ] + } + }, + "response": [] + }, + { + "name": "Item search empty", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test search item response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 0').to.eql(0);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/search?text=", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + "search" + ], + "query": [ + { + "key": "text", + "value": "" + } + ] + } + }, + "response": [] + } + ] + }, + { + "name": "bookings", + "item": [ + { + "name": "item 2 update set unavailable", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"false\"').to.false;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"available\": false\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking create from user1 to item2 unavailable", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(1, 'd');\r", + "var end = moment().add(2, 'd');\r", + "pm.environment.set('start', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"start\": \"{{start}}\",\n \"end\": \"{{end}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "item 2 update set available", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"available\": true\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking create failed by wrong userId", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 500\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500, 404, 403]);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(1, 'd');\r", + "var end = moment().add(2, 'd');\r", + "pm.environment.set('start', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "100", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"start\": \"{{start}}\",\n \"end\": \"{{end}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking create failed by not found itemId", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([404]);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(1, 'd');\r", + "var end = moment().add(2, 'd');\r", + "pm.environment.set('start', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 200,\n \"start\": \"{{start}}\",\n \"end\": \"{{end}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking create failed by end in past", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(1, 'd');\r", + "var end = moment().add(-1, 'd');\r", + "pm.environment.set('start', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"start\": \"{{start}}\",\n \"end\": \"{{end}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking create failed by end before start", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(2, 'd');\r", + "var end = moment().add(1, 'd');\r", + "pm.environment.set('start', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"start\": \"{{start}}\",\n \"end\": \"{{end}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking create failed by start equal end", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(2, 'd');\r", + "pm.environment.set('start_equal_end', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"start\": \"{{start_equal_end}}\",\n \"end\": \"{{start_equal_end}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking create failed by start equal null", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(2, 'd');\r", + "pm.environment.set('start_null', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"end\": \"{{start_null}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking create failed by end equal null", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(2, 'd');\r", + "pm.environment.set('end_null', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"start\": \"{{end_null}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking create failed by start in past", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(-1, 'd');\r", + "var end = moment().add(1, 'd');\r", + "pm.environment.set('start', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"start\": \"{{start}}\",\n \"end\": \"{{end}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking 1 create from user 1 to item 2 current", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has booking create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start') + '\"').to.eql(pm.environment.get('start'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end') + '\"').to.eql(pm.environment.get('end'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(3, 's');\r", + "var end = moment().add(4, 's')\r", + "pm.environment.set('start', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"start\": \"{{start}}\",\n \"end\": \"{{end}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking set approve by owner current", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200]);", + "});", + "pm.test(\"Has booking patch response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start') + '\"').to.eql(pm.environment.get('start'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end') + '\"').to.eql(pm.environment.get('end'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId?approved=true", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "query": [ + { + "key": "approved", + "value": "true" + } + ], + "variable": [ + { + "key": "bookingId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 2 create from user 1 to item 2", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has booking create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start2') + '\"').to.eql(pm.environment.get('start2'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end2') + '\"').to.eql(pm.environment.get('end2'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(1, 'd');\r", + "var end = moment().add(2, 'd');\r", + "pm.environment.set('start2', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end2', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"start\": \"{{start2}}\",\n \"end\": \"{{end2}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking 2 get by user 1 (booker)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200]);", + "});", + "pm.test(\"Has booking get response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start2') + '\"').to.eql(pm.environment.get('start2'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end2') + '\"').to.eql(pm.environment.get('end2'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "variable": [ + { + "key": "bookingId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 2 get by user 4 (owner)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200]);", + "});", + "pm.test(\"Has booking get response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start2') + '\"').to.eql(pm.environment.get('start2'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end2') + '\"').to.eql(pm.environment.get('end2'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "variable": [ + { + "key": "bookingId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for wrong user 100", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 500\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,404,403]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "100", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "" + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for wrong owner user 100", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 500\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,404,403]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "100", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 1", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start2') + '\"').to.eql(pm.environment.get('start2'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end2') + '\"').to.eql(pm.environment.get('end2'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "", + "pm.test(\"Test booking[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('start');", + " pm.expect(jsonData[1].start, '\"start\" must be \"' + pm.environment.get('start') + '\"').to.eql(pm.environment.get('start'));", + "});", + "pm.test(\"Test booking[1] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('end');", + " pm.expect(jsonData[1].end, '\"end\" must be \"' + pm.environment.get('end') + '\"').to.eql(pm.environment.get('end'));", + "});", + "pm.test(\"Test booking[1] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('status');", + " pm.expect(jsonData[1].status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking[1] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('booker');", + " pm.expect(jsonData[1].booker).to.have.property('id');", + " pm.expect(jsonData[1].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('id');", + " pm.expect(jsonData[1].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[1] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('name');", + " pm.expect(jsonData[1].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 1 by ALL state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start2') + '\"').to.eql(pm.environment.get('start2'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end2') + '\"').to.eql(pm.environment.get('end2'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "", + "pm.test(\"Test booking[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('start');", + " pm.expect(jsonData[1].start, '\"start\" must be \"' + pm.environment.get('start') + '\"').to.eql(pm.environment.get('start'));", + "});", + "pm.test(\"Test booking[1] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('end');", + " pm.expect(jsonData[1].end, '\"end\" must be \"' + pm.environment.get('end') + '\"').to.eql(pm.environment.get('end'));", + "});", + "pm.test(\"Test booking[1] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('status');", + " pm.expect(jsonData[1].status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking[1] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('booker');", + " pm.expect(jsonData[1].booker).to.have.property('id');", + " pm.expect(jsonData[1].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('id');", + " pm.expect(jsonData[1].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[1] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('name');", + " pm.expect(jsonData[1].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings?state=ALL", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ], + "query": [ + { + "key": "state", + "value": "ALL" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 1 by FUTURE state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(new Date(jsonData[0].start), '\"start\" must be > \"' + pm.environment.get('currentDateTime') + '\"').to.greaterThan(new Date(pm.environment.get('currentDateTime')));", + "", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(new Date(jsonData[0].end), '\"end\" must be > \"' + pm.environment.get('currentDateTime') + '\"').to.greaterThan(new Date(pm.environment.get('currentDateTime')));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "", + "pm.test(\"Test booking[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('start');", + "});", + "pm.test(\"Test booking[1] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('end');", + "});", + "pm.test(\"Test booking[1] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('start');", + " pm.expect(new Date(jsonData[1].start), '\"start\" must be > \"' + pm.environment.get('currentDateTime') + '\"').to.greaterThan(new Date(pm.environment.get('currentDateTime')));", + "", + "});", + "pm.test(\"Test booking[1] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('end');", + " pm.expect(new Date(jsonData[1].end), '\"end\" must be > \"' + pm.environment.get('currentDateTime') + '\"').to.greaterThan(new Date(pm.environment.get('currentDateTime')));", + "});", + "pm.test(\"Test booking[1] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('status');", + " pm.expect(jsonData[1].status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking[1] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('booker');", + " pm.expect(jsonData[1].booker).to.have.property('id');", + " pm.expect(jsonData[1].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('id');", + " pm.expect(jsonData[1].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[1] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('name');", + " pm.expect(jsonData[1].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');", + "", + "var start = moment();", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings?state=FUTURE", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ], + "query": [ + { + "key": "state", + "value": "FUTURE" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 1 by wrong state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 500\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});", + "pm.test(\"Test get user bookings by 'UNSUPPORTED_STATUS' state\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.error, 'Error message').to.be.eql('Unknown state: UNSUPPORTED_STATUS');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings?state=UNSUPPORTED_STATUS", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ], + "query": [ + { + "key": "state", + "value": "UNSUPPORTED_STATUS" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for owner", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start2') + '\"').to.eql(pm.environment.get('start2'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end2') + '\"').to.eql(pm.environment.get('end2'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "", + "pm.test(\"Test booking[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('start');", + " pm.expect(jsonData[1].start, '\"start\" must be \"' + pm.environment.get('start') + '\"').to.eql(pm.environment.get('start'));", + "});", + "pm.test(\"Test booking[1] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('end');", + " pm.expect(jsonData[1].end, '\"end\" must be \"' + pm.environment.get('end') + '\"').to.eql(pm.environment.get('end'));", + "});", + "pm.test(\"Test booking[1] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('status');", + " pm.expect(jsonData[1].status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking[1] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('booker');", + " pm.expect(jsonData[1].booker).to.have.property('id');", + " pm.expect(jsonData[1].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('id');", + " pm.expect(jsonData[1].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[1] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('name');", + " pm.expect(jsonData[1].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for owner by ALL state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start2') + '\"').to.eql(pm.environment.get('start2'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end2') + '\"').to.eql(pm.environment.get('end2'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "", + "pm.test(\"Test booking[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('start');", + " pm.expect(jsonData[1].start, '\"start\" must be \"' + pm.environment.get('start') + '\"').to.eql(pm.environment.get('start'));", + "});", + "pm.test(\"Test booking[1] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('end');", + " pm.expect(jsonData[1].end, '\"end\" must be \"' + pm.environment.get('end') + '\"').to.eql(pm.environment.get('end'));", + "});", + "pm.test(\"Test booking[1] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('status');", + " pm.expect(jsonData[1].status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking[1] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('booker');", + " pm.expect(jsonData[1].booker).to.have.property('id');", + " pm.expect(jsonData[1].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('id');", + " pm.expect(jsonData[1].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[1] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('name');", + " pm.expect(jsonData[1].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner?state=ALL", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ], + "query": [ + { + "key": "state", + "value": "ALL" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for owner by FUTURE state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(new Date(jsonData[0].start), '\"start\" must be > \"' + pm.environment.get('currentDateTime') + '\"').to.greaterThan(new Date(pm.environment.get('currentDateTime')));", + "", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(new Date(jsonData[0].end), '\"end\" must be > \"' + pm.environment.get('currentDateTime') + '\"').to.greaterThan(new Date(pm.environment.get('currentDateTime')));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "", + "pm.test(\"Test booking[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('start');", + "});", + "pm.test(\"Test booking[1] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('end');", + "});", + "pm.test(\"Test booking[1] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('start');", + " pm.expect(new Date(jsonData[1].start), '\"start\" must be > \"' + pm.environment.get('currentDateTime') + '\"').to.greaterThan(new Date(pm.environment.get('currentDateTime')));", + "", + "});", + "pm.test(\"Test booking[1] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('end');", + " pm.expect(new Date(jsonData[1].end), '\"end\" must be > \"' + pm.environment.get('currentDateTime') + '\"').to.greaterThan(new Date(pm.environment.get('currentDateTime')));", + "});", + "pm.test(\"Test booking[1] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('status');", + " pm.expect(jsonData[1].status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking[1] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('booker');", + " pm.expect(jsonData[1].booker).to.have.property('id');", + " pm.expect(jsonData[1].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('id');", + " pm.expect(jsonData[1].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[1] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('name');", + " pm.expect(jsonData[1].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');", + "", + "var start = moment();", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner?state=FUTURE", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ], + "query": [ + { + "key": "state", + "value": "FUTURE" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for owner by wrong state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 500\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});", + "pm.test(\"Test get owner bookings by 'UNSUPPORTED_STATUS' state\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.error, 'Error message').to.be.eql('Unknown state: UNSUPPORTED_STATUS');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner?state=UNSUPPORTED_STATUS", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ], + "query": [ + { + "key": "state", + "value": "UNSUPPORTED_STATUS" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 1000 get from user 4", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([404]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "variable": [ + { + "key": "bookingId", + "value": "1000" + } + ] + } + }, + "response": [] + }, + { + "name": "User 5 create", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has user create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test user 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test user 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('email');", + " pm.expect(jsonData.email, '\"email\" must be \"other@other.com\"').to.eql('other@other.com');", + "});", + "pm.test(\"Test user 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"other\"').to.eql('other');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"other\",\n \"email\": \"other@other.com\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users" + ] + } + }, + "response": [] + }, + { + "name": "Booking 1 get from user 5", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([404]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "5", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "variable": [ + { + "key": "bookingId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 2 change status from user 5 fail", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 500\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "5", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "variable": [ + { + "key": "bookingId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 2 change status by user 1 (booker)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([404]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId?approved=true", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "query": [ + { + "key": "approved", + "value": "true" + } + ], + "variable": [ + { + "key": "bookingId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 2 set approve by user 4 (owner)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200]);", + "});", + "pm.test(\"Has booking get response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start2') + '\"').to.eql(pm.environment.get('start2'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end2') + '\"').to.eql(pm.environment.get('end2'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId?approved=true", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "query": [ + { + "key": "approved", + "value": "true" + } + ], + "variable": [ + { + "key": "bookingId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 2 change status by user 4 (owner) after approve", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId?approved=true", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "query": [ + { + "key": "approved", + "value": "true" + } + ], + "variable": [ + { + "key": "bookingId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "User 6 create", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has user create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test user 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 6').to.eql(6);", + "});", + "pm.test(\"Test user 'email' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('email');", + " pm.expect(jsonData.email, '\"email\" must be \"practicum@yandex.ru\"').to.eql('practicum@yandex.ru');", + "});", + "pm.test(\"Test user 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"practicum\"').to.eql('practicum');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"practicum\",\n \"email\": \"practicum@yandex.ru\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/users", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "users" + ] + } + }, + "response": [] + }, + { + "name": "Booking create from user 1 to item 1 failed", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([404]);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(2, 'd');\r", + "var end = moment().add(3, 'd');\r", + "pm.environment.set('start3', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end3', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 1,\n \"start\": \"{{start3}}\",\n \"end\": \"{{end3}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking 3 create from user 4 to item 1", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has booking create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 3').to.eql(3);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start3') + '\"').to.eql(pm.environment.get('start3'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end3') + '\"').to.eql(pm.environment.get('end3'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"4\"').to.eql(4);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(1, 'd');\r", + "var end = moment().add(1, 'd').add(1, 'h');\r", + "pm.environment.set('start3', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end3', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 1,\n \"start\": \"{{start3}}\",\n \"end\": \"{{end3}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking 3 set rejected by user 1 (owner)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.ok;", + "});", + "pm.test(\"Has booking create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 3').to.eql(3);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start3') + '\"').to.eql(pm.environment.get('start3'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end3') + '\"').to.eql(pm.environment.get('end3'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"REJECTED\"').to.eql('REJECTED');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"4\"').to.eql(4);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId?approved=false", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "query": [ + { + "key": "approved", + "value": "false" + } + ], + "variable": [ + { + "key": "bookingId", + "value": "3" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 4 create from user 5 to item 2", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has booking create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 4').to.eql(4);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start4') + '\"').to.eql(pm.environment.get('start4'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end4') + '\"').to.eql(pm.environment.get('end4'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"5\"').to.eql(5);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(1, 'h');\r", + "var end = moment().add(2, 'h');\r", + "pm.environment.set('start4', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end4', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "5", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"start\": \"{{start4}}\",\n \"end\": \"{{end4}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking 4 set approve by user 4 (owner)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200]);", + "});", + "pm.test(\"Has booking get response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 4').to.eql(4);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start4') + '\"').to.eql(pm.environment.get('start4'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end4') + '\"').to.eql(pm.environment.get('end4'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"5\"').to.eql(5);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId?approved=true", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "query": [ + { + "key": "approved", + "value": "true" + } + ], + "variable": [ + { + "key": "bookingId", + "value": "4" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 2 get by user 4 (owner) with bookings", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "", + "pm.test(\"Test item 'lastBooking.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking).to.have.property('id');", + " pm.expect(jsonData.lastBooking.id, '\"lastBooking.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test item 'lastBooking.bookerId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking).to.have.property('bookerId');", + " pm.expect(jsonData.lastBooking.bookerId, '\"lastBooking.bookerId\" must be \"1\"').to.eql(1);", + "});", + "", + "pm.test(\"Test item 'nextBooking.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking).to.have.property('id');", + " pm.expect(jsonData.nextBooking.id, '\"nextBooking.id\" must be \"1\"').to.eql(4);", + "});", + "pm.test(\"Test item 'nextBooking.bookerId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking).to.have.property('bookerId');", + " pm.expect(jsonData.nextBooking.bookerId, '\"nextBooking.bookerId\" must be \"1\"').to.eql(5);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var time = setTimeout(function(){}, 4000);\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 2 get by user 1 without bookings", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "", + "pm.test(\"Test item 'lastBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking, '\"lastBooking\" must be \"null\"').null;", + "});", + "pm.test(\"Test item 'nextBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking, '\"nextBooking\" must be \"null\"').null;", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 2 get by user 5 without bookings", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "", + "pm.test(\"Test item 'lastBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking, '\"lastBooking\" must be \"null\"').null;", + "});", + "pm.test(\"Test item 'nextBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking, '\"nextBooking\" must be \"null\"').null;", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "5", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Item get all user 4 with bookings", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list item response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test item[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('name');", + " pm.expect(jsonData[0].name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('description');", + " pm.expect(jsonData[0].description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item[0] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('available');", + " pm.expect(jsonData[0].available, '\"available\" must be \"true\"').to.true;", + "});", + "pm.test(\"Test item[0] 'lastBooking.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('lastBooking');", + " pm.expect(jsonData[0].lastBooking).to.have.property('id');", + " pm.expect(jsonData[0].lastBooking.id, '\"lastBooking.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test item[0] 'lastBooking.bookerId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('lastBooking');", + " pm.expect(jsonData[0].lastBooking).to.have.property('bookerId');", + " pm.expect(jsonData[0].lastBooking.bookerId, '\"lastBooking.bookerId\" must be \"1\"').to.eql(1);", + "});", + "", + "pm.test(\"Test item[0] 'nextBooking.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('nextBooking');", + " pm.expect(jsonData[0].nextBooking).to.have.property('id');", + " pm.expect(jsonData[0].nextBooking.id, '\"nextBooking.id\" must be \"1\"').to.eql(4);", + "});", + "pm.test(\"Test item[0] 'nextBooking.bookerId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('nextBooking');", + " pm.expect(jsonData[0].nextBooking).to.have.property('bookerId');", + " pm.expect(jsonData[0].nextBooking.bookerId, '\"nextBooking.bookerId\" must be \"1\"').to.eql(5);", + "});", + "", + "", + "pm.test(\"Test item[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 3').to.eql(3);", + "});", + "pm.test(\"Test item[1] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('name');", + " pm.expect(jsonData[1].name, '\"name\" must be \"Клей Момент\"').to.eql('Клей Момент');", + "});", + "pm.test(\"Test item[1] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('description');", + " pm.expect(jsonData[1].description, '\"description\" must be \"Тюбик суперклея марки Момент\"').to.eql('Тюбик суперклея марки Момент');", + "});", + "pm.test(\"Test item[1] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('available');", + " pm.expect(jsonData[1].available, '\"available\" must be \"true\"').to.true;", + "});", + "pm.test(\"Test item[1] 'lastBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('lastBooking');", + " pm.expect(jsonData[1].lastBooking, '\"lastBooking\" must be \"null\"').null;", + "});", + "pm.test(\"Test item[1] 'nextBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('nextBooking');", + " pm.expect(jsonData[1].nextBooking, '\"nextBooking\" must be \"null\"').null;", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Booking 5 create from user 1 to item 3 current", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has booking create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start5') + '\"').to.eql(pm.environment.get('start5'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end5') + '\"').to.eql(pm.environment.get('end5'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"3\"').to.eql(3);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Клей Момент\"').to.eql('Клей Момент');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(3, 's');\r", + "var end = moment().add(1, 'd')\r", + "pm.environment.set('start5', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end5', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 3,\n \"start\": \"{{start5}}\",\n \"end\": \"{{end5}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 1 by WAITING state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start5') + '\"').to.eql(pm.environment.get('start5'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end5') + '\"').to.eql(pm.environment.get('end5'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"3\"').to.eql(3);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Клей Момент\"').to.eql('Клей Момент');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');", + "", + "var start = moment();", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings?state=WAITING", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ], + "query": [ + { + "key": "state", + "value": "WAITING" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 4 (owner) by WAITING state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start5') + '\"').to.eql(pm.environment.get('start5'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end5') + '\"').to.eql(pm.environment.get('end5'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"3\"').to.eql(3);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Клей Момент\"').to.eql('Клей Момент');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');", + "", + "var start = moment();", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner?state=WAITING", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ], + "query": [ + { + "key": "state", + "value": "WAITING" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 6 create from user 1 to item 2 current", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has booking create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 6').to.eql(6);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start6') + '\"').to.eql(pm.environment.get('start6'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end6') + '\"').to.eql(pm.environment.get('end6'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(3, 's');\r", + "var end = moment().add(4, 's')\r", + "pm.environment.set('start6', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end6', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 2,\n \"start\": \"{{start6}}\",\n \"end\": \"{{end6}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking 5 set rejected by user 4 (owner)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has booking create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start5') + '\"').to.eql(pm.environment.get('start5'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end5') + '\"').to.eql(pm.environment.get('end5'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"REJECTED\"').to.eql('REJECTED');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"3\"').to.eql(3);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Клей Момент\"').to.eql('Клей Момент');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId?approved=false", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "query": [ + { + "key": "approved", + "value": "false" + } + ], + "variable": [ + { + "key": "bookingId", + "value": "5" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 1 by REJECTED state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start5') + '\"').to.eql(pm.environment.get('start5'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end5') + '\"').to.eql(pm.environment.get('end5'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"REJECTED\"').to.eql('REJECTED');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"3\"').to.eql(3);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Клей Момент\"').to.eql('Клей Момент');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');", + "", + "var start = moment();", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings?state=REJECTED", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ], + "query": [ + { + "key": "state", + "value": "REJECTED" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 4 (owner) by REJECTED state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start5') + '\"').to.eql(pm.environment.get('start5'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end5') + '\"').to.eql(pm.environment.get('end5'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"REJECTED\"').to.eql('REJECTED');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"3\"').to.eql(3);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Клей Момент\"').to.eql('Клей Момент');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');", + "", + "var start = moment();", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner?state=REJECTED", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ], + "query": [ + { + "key": "state", + "value": "REJECTED" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 6 set approve by owner 4 current", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200]);", + "});", + "pm.test(\"Has booking patch response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 6').to.eql(6);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start6') + '\"').to.eql(pm.environment.get('start6'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end6') + '\"').to.eql(pm.environment.get('end6'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId?approved=true", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "query": [ + { + "key": "approved", + "value": "true" + } + ], + "variable": [ + { + "key": "bookingId", + "value": "6" + } + ] + } + }, + "response": [] + } + ] + }, + { + "name": "comments", + "item": [ + { + "name": "Item 4 create by user 6", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has item create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 4').to.eql(4);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Кухонный стол\"').to.eql('Кухонный стол');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Стол для празднования\"').to.eql('Стол для празднования');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "6", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Кухонный стол\",\n \"description\": \"Стол для празднования\",\n \"available\": true\n}" + }, + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Item 1 get from user 1 (owner) without comments", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная дрель + аккумулятор\"').to.eql('Аккумуляторная дрель + аккумулятор');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "pm.test(\"Test item 'lastBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking, '\"lastBooking\" must be \"null\"').null;", + "});", + "pm.test(\"Test item 'nextBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking, '\"nextBooking\" must be \"null\"').null;", + "});", + "pm.test(\"Test item 'comments' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('comments');", + " pm.expect(jsonData.comments.length, 'length of \"comments\" must be \"0\"').to.eql(0);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 7 future create from user 5 to item 1", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has booking create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 7').to.eql(7);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start7') + '\"').to.eql(pm.environment.get('start7'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end7') + '\"').to.eql(pm.environment.get('end7'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"5\"').to.eql(5);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(10, 'd');\r", + "var end = moment().add(11, 'd')\r", + "pm.environment.set('start7', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end7', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "5", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 1,\n \"start\": \"{{start7}}\",\n \"end\": \"{{end7}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking 8 create from user 1 to item 4 start past and end future", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has booking create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 8').to.eql(8);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start8') + '\"').to.eql(pm.environment.get('start8'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end8') + '\"').to.eql(pm.environment.get('end8'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"WAITING\"').to.eql('WAITING');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"4\"').to.eql(4);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Кухонный стол\"').to.eql('Кухонный стол');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment().add(2, 's');\r", + "var end = moment().add(1, 'h');\r", + "pm.environment.set('start8', start.format('YYYY-MM-DDTHH:mm:ss'));\r", + "pm.environment.set('end8', end.format('YYYY-MM-DDTHH:mm:ss'));\r", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": 4,\n \"start\": \"{{start8}}\",\n \"end\": \"{{end8}}\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/bookings", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ] + } + }, + "response": [] + }, + { + "name": "Booking 8 set approve by user 6 (owner)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200]);", + "});", + "pm.test(\"Has booking get response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 8').to.eql(8);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start8') + '\"').to.eql(pm.environment.get('start8'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end8') + '\"').to.eql(pm.environment.get('end8'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"4\"').to.eql(4);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Кухонный стол\"').to.eql('Кухонный стол');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "6", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId?approved=true", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "query": [ + { + "key": "approved", + "value": "true" + } + ], + "variable": [ + { + "key": "bookingId", + "value": "8" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 2 get from user 1 without comments", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "pm.test(\"Test item 'lastBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking, '\"lastBooking\" must be \"null\"').null;", + "});", + "pm.test(\"Test item 'nextBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking, '\"nextBooking\" must be \"null\"').null;", + "});", + "", + "pm.test(\"Test item 'comments' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('comments');", + " pm.expect(jsonData.comments.length, 'length of \"comments\" must be \"0\"').to.eql(0);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var time = setTimeout(function(){}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 2 get from user 4 (owner) without comments", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "", + "pm.test(\"Test item 'lastBooking.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking).to.have.property('id');", + " pm.expect(jsonData.lastBooking.id, '\"lastBooking.id\" must be \"6\"').to.eql(6);", + "});", + "pm.test(\"Test item 'lastBooking.bookerId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking).to.have.property('bookerId');", + " pm.expect(jsonData.lastBooking.bookerId, '\"lastBooking.bookerId\" must be \"1\"').to.eql(1);", + "});", + "", + "pm.test(\"Test item 'nextBooking.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking).to.have.property('id');", + " pm.expect(jsonData.nextBooking.id, '\"nextBooking.id\" must be \"1\"').to.eql(4);", + "});", + "pm.test(\"Test item 'nextBooking.bookerId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking).to.have.property('bookerId');", + " pm.expect(jsonData.nextBooking.bookerId, '\"nextBooking.bookerId\" must be \"1\"').to.eql(5);", + "});", + "", + "pm.test(\"Test item 'comments' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('comments');", + " pm.expect(jsonData.comments.length, 'length of \"comments\" must be \"0\"').to.eql(0);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var time = setTimeout(function(){}, 3000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Comment from user 4 to item 1 without booking failed", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + }, + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"text\": \"Comment for item 1\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId/comment", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId", + "comment" + ], + "variable": [ + { + "key": "itemId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "Comment from user 1 to item 2 empty failed", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + }, + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"text\": \"\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId/comment", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId", + "comment" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Comment 1 from user 1 to item 2", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200]);", + "});", + "pm.test(\"Test add comment to item 2 from user1\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.id, '\"id\" field').to.eql(1);", + " pm.expect(jsonData.text, '\"text\" field').to.eql(\"Add comment from user1\");", + " pm.expect(jsonData.authorName, '\"authorName\" field').to.eql(\"updateName\");", + " pm.expect(jsonData.created, '\"created\" field').not.null;", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment();\r", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + }, + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"text\": \"Add comment from user1\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId/comment", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId", + "comment" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 2 get by user 1 with comments", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "pm.test(\"Test item 'lastBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking, '\"lastBooking\" must be \"null\"').null;", + "});", + "pm.test(\"Test item 'nextBooking' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking, '\"nextBooking\" must be \"null\"').null;", + "});", + "", + "pm.test(\"Test item 'comments' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('comments');", + " pm.expect(jsonData.comments.length, 'length of \"comments\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test item 'comments[0].id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.comments[0]).to.have.property('id');", + " pm.expect(jsonData.comments[0].id, '\"id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test item 'comments[0].text' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.comments[0]).to.have.property('text');", + " pm.expect(jsonData.comments[0].text, '\"text\" must be \"Add comment from user1\"').to.eql('Add comment from user1');", + "});", + "pm.test(\"Test item 'comments[0].authorName' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.comments[0]).to.have.property('authorName');", + " pm.expect(jsonData.comments[0].authorName, '\"authorName\" must be \"updateName\"').to.eql(\"updateName\");", + "});", + "pm.test(\"Test item 'comments[0].created' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.comments[0]).to.have.property('created');", + " pm.expect(new Date(jsonData.comments[0].created), '\"created\" must be > \"' + pm.environment.get('currentDateTime') + '\"').to.greaterThan(new Date(pm.environment.get('currentDateTime')));", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 2 get by user 4 (owner) with comments", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 2').to.eql(2);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Аккумуляторная отвертка\"').to.eql('Аккумуляторная отвертка');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "", + "pm.test(\"Test item 'lastBooking.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking).to.have.property('id');", + " pm.expect(jsonData.lastBooking.id, '\"lastBooking.id\" must be \"6\"').to.eql(6);", + "});", + "pm.test(\"Test item 'lastBooking.bookerId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking).to.have.property('bookerId');", + " pm.expect(jsonData.lastBooking.bookerId, '\"lastBooking.bookerId\" must be \"1\"').to.eql(1);", + "});", + "", + "pm.test(\"Test item 'nextBooking.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking).to.have.property('id');", + " pm.expect(jsonData.nextBooking.id, '\"nextBooking.id\" must be \"1\"').to.eql(4);", + "});", + "pm.test(\"Test item 'nextBooking.bookerId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking).to.have.property('bookerId');", + " pm.expect(jsonData.nextBooking.bookerId, '\"nextBooking.bookerId\" must be \"1\"').to.eql(5);", + "});", + "", + "pm.test(\"Test item 'comments' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('comments');", + " pm.expect(jsonData.comments.length, 'length of \"comments\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test item 'comments[0].id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.comments[0]).to.have.property('id');", + " pm.expect(jsonData.comments[0].id, '\"id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test item 'comments[0].text' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.comments[0]).to.have.property('text');", + " pm.expect(jsonData.comments[0].text, '\"text\" must be \"Add comment from user1\"').to.eql('Add comment from user1');", + "});", + "pm.test(\"Test item 'comments[0].authorName' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.comments[0]).to.have.property('authorName');", + " pm.expect(jsonData.comments[0].authorName, '\"authorName\" must be \"updateName\"').to.eql(\"updateName\");", + "});", + "pm.test(\"Test item 'comments[0].created' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.comments[0]).to.have.property('created');", + " pm.expect(new Date(jsonData.comments[0].created), '\"created\" must be > \"' + pm.environment.get('currentDateTime') + '\"').to.greaterThan(new Date(pm.environment.get('currentDateTime')));", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking 7 set approve by owner future", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has booking create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test booking 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 7').to.eql(7);", + "});", + "pm.test(\"Test booking 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('start');", + " pm.expect(jsonData.start, '\"start\" must be \"' + pm.environment.get('start7') + '\"').to.eql(pm.environment.get('start7'));", + "});", + "pm.test(\"Test booking 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('end');", + " pm.expect(jsonData.end, '\"end\" must be \"' + pm.environment.get('end7') + '\"').to.eql(pm.environment.get('end7'));", + "});", + "pm.test(\"Test booking 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('status');", + " pm.expect(jsonData.status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('booker');", + " pm.expect(jsonData.booker).to.have.property('id');", + " pm.expect(jsonData.booker.id, '\"booker.id\" must be \"5\"').to.eql(5);", + "});", + "pm.test(\"Test booking 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('id');", + " pm.expect(jsonData.item.id, '\"item.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('item');", + " pm.expect(jsonData.item).to.have.property('name');", + " pm.expect(jsonData.item.name, '\"item.name\" must be \"Аккумуляторная дрель\"').to.eql('Аккумуляторная дрель');", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/:bookingId?approved=true", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + ":bookingId" + ], + "query": [ + { + "key": "approved", + "value": "true" + } + ], + "variable": [ + { + "key": "bookingId", + "value": "7" + } + ] + } + }, + "response": [] + }, + { + "name": "Add comment to item 1 from user5 failed by future booking", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + }, + { + "key": "X-Sharer-User-Id", + "value": "5", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"text\": \"Add comment from user5\"\n}" + }, + "url": { + "raw": "{{baseUrl}}/items/:itemId/comment", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId", + "comment" + ], + "variable": [ + { + "key": "itemId", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 1 by CURRENT state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start5') + '\"').to.eql(pm.environment.get('start5'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end5') + '\"').to.eql(pm.environment.get('end5'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"REJECTED\"').to.eql('REJECTED');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"3\"').to.eql(3);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Клей Момент\"').to.eql('Клей Момент');", + "});", + "", + "pm.test(\"Test booking[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 8').to.eql(8);", + "});", + "pm.test(\"Test booking[1] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('start');", + " pm.expect(jsonData[1].start, '\"start\" must be \"' + pm.environment.get('start8') + '\"').to.eql(pm.environment.get('start8'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('end');", + " pm.expect(jsonData[1].end, '\"end\" must be \"' + pm.environment.get('end8') + '\"').to.eql(pm.environment.get('end8'));", + "});", + "pm.test(\"Test booking[1] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('status');", + " pm.expect(jsonData[1].status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('booker');", + " pm.expect(jsonData[1].booker).to.have.property('id');", + " pm.expect(jsonData[1].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('id');", + " pm.expect(jsonData[1].item.id, '\"item.id\" must be \"4\"').to.eql(4);", + "});", + "pm.test(\"Test booking[1] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('name');", + " pm.expect(jsonData[1].item.name, '\"item.name\" must be \"Кухонный стол\"').to.eql('Кухонный стол');", + "});", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings?state=CURRENT", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ], + "query": [ + { + "key": "state", + "value": "CURRENT" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 4 (owner) by CURRENT state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start5') + '\"').to.eql(pm.environment.get('start5'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end5') + '\"').to.eql(pm.environment.get('end5'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"REJECTED\"').to.eql('REJECTED');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"3\"').to.eql(3);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Клей Момент\"').to.eql('Клей Момент');", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner?state=CURRENT", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ], + "query": [ + { + "key": "state", + "value": "CURRENT" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 1 by PAST state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 6').to.eql(6);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start6') + '\"').to.eql(pm.environment.get('start6'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end6') + '\"').to.eql(pm.environment.get('end6'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "", + "pm.test(\"Test booking[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('start');", + " pm.expect(jsonData[1].start, '\"start\" must be \"' + pm.environment.get('start') + '\"').to.eql(pm.environment.get('start'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('end');", + " pm.expect(jsonData[1].end, '\"end\" must be \"' + pm.environment.get('end') + '\"').to.eql(pm.environment.get('end'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('status');", + " pm.expect(jsonData[1].status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('booker');", + " pm.expect(jsonData[1].booker).to.have.property('id');", + " pm.expect(jsonData[1].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('id');", + " pm.expect(jsonData[1].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('name');", + " pm.expect(jsonData[1].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings?state=PAST", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ], + "query": [ + { + "key": "state", + "value": "PAST" + } + ] + } + }, + "response": [] + }, + { + "name": "Booking get all for user 4 (owner) by PAST state", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list booking response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 2').to.eql(2);", + "});", + "", + "pm.test(\"Test booking[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 6').to.eql(6);", + "});", + "pm.test(\"Test booking[0] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('start');", + " pm.expect(jsonData[0].start, '\"start\" must be \"' + pm.environment.get('start6') + '\"').to.eql(pm.environment.get('start6'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('end');", + " pm.expect(jsonData[0].end, '\"end\" must be \"' + pm.environment.get('end6') + '\"').to.eql(pm.environment.get('end6'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('status');", + " pm.expect(jsonData[0].status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('booker');", + " pm.expect(jsonData[0].booker).to.have.property('id');", + " pm.expect(jsonData[0].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('id');", + " pm.expect(jsonData[0].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('item');", + " pm.expect(jsonData[0].item).to.have.property('name');", + " pm.expect(jsonData[0].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});", + "", + "pm.test(\"Test booking[1] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('id');", + " pm.expect(jsonData[1].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test booking[1] 'start' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('start');", + " pm.expect(jsonData[1].start, '\"start\" must be \"' + pm.environment.get('start') + '\"').to.eql(pm.environment.get('start'));", + "});", + "pm.test(\"Test booking[0] 'end' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('end');", + " pm.expect(jsonData[1].end, '\"end\" must be \"' + pm.environment.get('end') + '\"').to.eql(pm.environment.get('end'));", + "});", + "pm.test(\"Test booking[0] 'status' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('status');", + " pm.expect(jsonData[1].status, '\"status\" must be \"APPROVED\"').to.eql('APPROVED');", + "});", + "pm.test(\"Test booking[0] 'booker.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('booker');", + " pm.expect(jsonData[1].booker).to.have.property('id');", + " pm.expect(jsonData[1].booker.id, '\"booker.id\" must be \"1\"').to.eql(1);", + "});", + "pm.test(\"Test booking[0] 'item.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('id');", + " pm.expect(jsonData[1].item.id, '\"item.id\" must be \"2\"').to.eql(2);", + "});", + "pm.test(\"Test booking[0] 'item.name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[1]).to.have.property('item');", + " pm.expect(jsonData[1].item).to.have.property('name');", + " pm.expect(jsonData[1].item.name, '\"item.name\" must be \"Отвертка\"').to.eql('Отвертка');", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner?state=PAST", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ], + "query": [ + { + "key": "state", + "value": "PAST" + } + ] + } + }, + "response": [] + }, + { + "name": "Item 4 get by user 6 (owner) without comments", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Has item update response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 4').to.eql(4);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Кухонный стол\"').to.eql('Кухонный стол');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Стол для празднования\"').to.eql('Стол для празднования');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "", + "pm.test(\"Test item 'lastBooking.id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking).to.have.property('id');", + " pm.expect(jsonData.lastBooking.id, '\"lastBooking.id\" must be \"8\"').to.eql(8);", + "});", + "pm.test(\"Test item 'lastBooking.bookerId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('lastBooking');", + " pm.expect(jsonData.lastBooking).to.have.property('bookerId');", + " pm.expect(jsonData.lastBooking.bookerId, '\"lastBooking.bookerId\" must be \"1\"').to.eql(1);", + "});", + "", + "pm.test(\"Test item 'nextBooking'\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('nextBooking');", + " pm.expect(jsonData.nextBooking, '\"nextBooking\" must be \"null\"').null;", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "6", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/items/:itemId", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items", + ":itemId" + ], + "variable": [ + { + "key": "itemId", + "value": "4" + } + ] + } + }, + "response": [] + } + ] + }, + { + "name": "item requests", + "item": [ + { + "name": "Add item request with wrong user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 500\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,404,403]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "99", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"description\": \"Хотел бы воспользоваться щёткой для обуви\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/requests", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests" + ] + } + }, + "response": [] + }, + { + "name": "Add item request with empty description", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([400]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"description\": null\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/requests", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests" + ] + } + }, + "response": [] + }, + { + "name": "Requests get own by wrong user id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,404,403]);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "99", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests" + ] + } + }, + "response": [] + }, + { + "name": "Requests get own by user id without requests", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list item requests response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 0').to.eql(0);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests" + ] + } + }, + "response": [] + }, + { + "name": "Requests get all without pagination params", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list item requests response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 0').to.eql(0);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests/all", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests", + "all" + ] + } + }, + "response": [] + }, + { + "name": "Requests get all with from = 0 & size = 0", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests/all?from=0&size=0", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests", + "all" + ], + "query": [ + { + "key": "from", + "value": "0" + }, + { + "key": "size", + "value": "0" + } + ] + } + }, + "response": [] + }, + { + "name": "Requests get all with from = -1 & size = 20", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests/all?from=-1&size=20", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests", + "all" + ], + "query": [ + { + "key": "from", + "value": "-1" + }, + { + "key": "size", + "value": "20" + } + ] + } + }, + "response": [] + }, + { + "name": "Requests get all with from = 0 & size = -1", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests/all?from=0&size=-1", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests", + "all" + ], + "query": [ + { + "key": "from", + "value": "0" + }, + { + "key": "size", + "value": "-1" + } + ] + } + }, + "response": [] + }, + { + "name": "Requests get all with from = 0 & size = 20 when empty", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list item requests response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 0').to.eql(0);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests/all?from=0&size=20", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests", + "all" + ], + "query": [ + { + "key": "from", + "value": "0" + }, + { + "key": "size", + "value": "20" + } + ] + } + }, + "response": [] + }, + { + "name": "Add item request 1", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has item request create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item request 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item request 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Хотел бы воспользоваться щёткой для обуви\"').to.eql(\"Хотел бы воспользоваться щёткой для обуви\");", + "});", + "pm.test(\"Test item request 'created' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('created');", + " pm.expect(jsonData.created, '\"created\" must be not null').is.not.null;", + "", + " var current = pm.environment.get('currentDateTime');", + " var created = new Date(jsonData.created);", + " var future = new Date(current);", + " future.setSeconds(future.getSeconds() + 2);", + " pm.expect(created, '\"created\" must be > ' + pm.environment.get('currentDateTime')).to.gte(new Date(current));", + " pm.expect(created, '\"created\" must be < ' + future).to.lte(future);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');", + "", + "var start = moment();", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"description\": \"Хотел бы воспользоваться щёткой для обуви\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{baseUrl}}/requests", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests" + ] + } + }, + "response": [] + }, + { + "name": "Requests get own by user id with requests empty items", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list item requests response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "", + "pm.test(\"Test item request[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item request[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('description');", + " pm.expect(jsonData[0].description, '\"description\" must be \"Хотел бы воспользоваться щёткой для обуви\"').to.eql(\"Хотел бы воспользоваться щёткой для обуви\");", + "});", + "pm.test(\"Test item request[0] 'created' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('created');", + " pm.expect(jsonData[0].created, '\"created\" must be not null').is.not.null;", + "});", + "pm.test(\"Test item request[0] 'items' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('items');", + " pm.expect(jsonData[0].items, '\"items\" must be not null').is.not.null;", + " pm.expect(jsonData[0].items.length, 'items count in total').to.eql(0);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var time = setTimeout(function(){}, 1000);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests" + ] + } + }, + "response": [] + }, + { + "name": "Add item 5 to request 1 from user 4", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 or 201\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + "});", + "pm.test(\"Has item create response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "pm.test(\"Test item 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test item 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('name');", + " pm.expect(jsonData.name, '\"name\" must be \"Щётка для обуви\"').to.eql('Щётка для обуви');", + "});", + "pm.test(\"Test item 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Стандартная щётка для обуви\"').to.eql('Стандартная щётка для обуви');", + "});", + "pm.test(\"Test item 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('available');", + " pm.expect(jsonData.available, '\"available\" must be \"true\"').to.true;", + "});", + "pm.test(\"Test item 'requestId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('requestId');", + " pm.expect(jsonData.requestId, '\"requestId\" must be \"1\"').to.eq(1);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Щётка для обуви\",\n \"description\": \"Стандартная щётка для обуви\",\n \"available\": true,\n \"requestId\": 1\n}" + }, + "url": { + "raw": "{{baseUrl}}/items", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "items" + ] + } + }, + "response": [] + }, + { + "name": "Requests get own by user id with requests", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list item requests response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "", + "pm.test(\"Test item request[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item request[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('description');", + " pm.expect(jsonData[0].description, '\"description\" must be \"Хотел бы воспользоваться щёткой для обуви\"').to.eql(\"Хотел бы воспользоваться щёткой для обуви\");", + "});", + "pm.test(\"Test item request[0] 'created' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('created');", + " pm.expect(jsonData[0].created, '\"created\" must be not null').is.not.null;", + " ", + " var created = new Date(jsonData[0].created);", + " var future = new Date(pm.environment.get('currentDateTime'));", + " pm.expect(created, '\"created\" must be < ' + pm.environment.get('currentDateTime')).to.lte(future);", + "});", + "pm.test(\"Test item request[0] 'items' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('items');", + " pm.expect(jsonData[0].items, '\"items\" must be not null').is.not.null;", + " pm.expect(jsonData[0].items.length, 'items count must be 1').to.eql(1);", + "});", + "pm.test(\"Test request[0].items[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0].items[0]).to.have.property('id');", + " pm.expect(jsonData[0].items[0].id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test request[0].items[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0].items[0]).to.have.property('name');", + " pm.expect(jsonData[0].items[0].name, '\"name\" must be \"Щётка для обуви\"').to.eql('Щётка для обуви');", + "});", + "pm.test(\"Test request[0].items[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0].items[0]).to.have.property('description');", + " pm.expect(jsonData[0].items[0].description, '\"description\" must be \"Стандартная щётка для обуви\"').to.eql('Стандартная щётка для обуви');", + "});", + "pm.test(\"Test request[0].items[0] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0].items[0]).to.have.property('available');", + " pm.expect(jsonData[0].items[0].available, '\"available\" must be \"true\"').to.true;", + "});", + "pm.test(\"Test request[0].items[0] 'requestId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0].items[0]).to.have.property('requestId');", + " pm.expect(jsonData[0].items[0].requestId, '\"requestId\" must be \"1\"').to.eq(1);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');", + "", + "var start = moment();", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss.sss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests" + ] + } + }, + "response": [] + }, + { + "name": "Requests get all with from = 0 & size = 20 for request owner", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list item requests response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 0').to.eql(0);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests/all?from=0&size=20", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests", + "all" + ], + "query": [ + { + "key": "from", + "value": "0" + }, + { + "key": "size", + "value": "20" + } + ] + } + }, + "response": [] + }, + { + "name": "Requests get all with from = 0 & size = 20 for other user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test list item requests response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'List length must be 1').to.eql(1);", + "});", + "", + "pm.test(\"Test item request[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('id');", + " pm.expect(jsonData[0].id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item request[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('description');", + " pm.expect(jsonData[0].description, '\"description\" must be \"Хотел бы воспользоваться щёткой для обуви\"').to.eql(\"Хотел бы воспользоваться щёткой для обуви\");", + "});", + "pm.test(\"Test item request[0] 'created' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('created');", + " pm.expect(jsonData[0].created, '\"created\" must be not null').is.not.null;", + " ", + " var created = new Date(jsonData[0].created);", + " var future = new Date(pm.environment.get('currentDateTime'));", + " pm.expect(created, '\"created\" must be < ' + pm.environment.get('currentDateTime')).to.lte(future);", + "});", + "pm.test(\"Test item request[0] 'items' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0]).to.have.property('items');", + " pm.expect(jsonData[0].items, '\"items\" must be not null').is.not.null;", + " pm.expect(jsonData[0].items.length, 'items count must be 1').to.eql(1);", + "});", + "pm.test(\"Test request[0].items[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0].items[0]).to.have.property('id');", + " pm.expect(jsonData[0].items[0].id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test request[0].items[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0].items[0]).to.have.property('name');", + " pm.expect(jsonData[0].items[0].name, '\"name\" must be \"Щётка для обуви\"').to.eql('Щётка для обуви');", + "});", + "pm.test(\"Test request[0].items[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0].items[0]).to.have.property('description');", + " pm.expect(jsonData[0].items[0].description, '\"description\" must be \"Стандартная щётка для обуви\"').to.eql('Стандартная щётка для обуви');", + "});", + "pm.test(\"Test request[0].items[0] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0].items[0]).to.have.property('available');", + " pm.expect(jsonData[0].items[0].available, '\"available\" must be \"true\"').to.true;", + "});", + "pm.test(\"Test request[0].items[0] 'requestId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0].items[0]).to.have.property('requestId');", + " pm.expect(jsonData[0].items[0].requestId, '\"requestId\" must be \"1\"').to.eq(1);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');", + "", + "var start = moment();", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss.sss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests/all?from=0&size=20", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests", + "all" + ], + "query": [ + { + "key": "from", + "value": "0" + }, + { + "key": "size", + "value": "20" + } + ] + } + }, + "response": [] + }, + { + "name": "Requests get by id for wrong user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 500\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500, 404, 403]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "99", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests/1", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Requests get by wrong id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([404]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests/99", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests", + "99" + ] + } + }, + "response": [] + }, + { + "name": "Requests get by id for other user", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test item request response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "", + "pm.test(\"Test item request 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item request 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Хотел бы воспользоваться щёткой для обуви\"').to.eql(\"Хотел бы воспользоваться щёткой для обуви\");", + "});", + "pm.test(\"Test item request 'created' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('created');", + " pm.expect(jsonData.created, '\"created\" must be not null').is.not.null;", + "", + " var created = new Date(jsonData.created);", + " var future = new Date(pm.environment.get('currentDateTime'));", + " pm.expect(created, '\"created\" must be < ' + pm.environment.get('currentDateTime')).to.lte(future);", + "});", + "pm.test(\"Test item request 'items' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('items');", + " pm.expect(jsonData.items, '\"items\" must be not null').is.not.null;", + " pm.expect(jsonData.items.length, 'items count must be 1').to.eql(1);", + "});", + "pm.test(\"Test request.items[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.items[0]).to.have.property('id');", + " pm.expect(jsonData.items[0].id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test request.items[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.items[0]).to.have.property('name');", + " pm.expect(jsonData.items[0].name, '\"name\" must be \"Щётка для обуви\"').to.eql('Щётка для обуви');", + "});", + "pm.test(\"Test request.items[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.items[0]).to.have.property('description');", + " pm.expect(jsonData.items[0].description, '\"description\" must be \"Стандартная щётка для обуви\"').to.eql('Стандартная щётка для обуви');", + "});", + "pm.test(\"Test request.items[0] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.items[0]).to.have.property('available');", + " pm.expect(jsonData.items[0].available, '\"available\" must be \"true\"').to.true;", + "});", + "pm.test(\"Test request.items[0] 'requestId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.items[0]).to.have.property('requestId');", + " pm.expect(jsonData.items[0].requestId, '\"requestId\" must be \"1\"').to.eq(1);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');\r", + "\r", + "var start = moment();\r", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss.sss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "4", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests/1", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Requests get by id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.be.ok;", + "});", + "pm.test(\"Test item request response\", function () {", + " pm.response.to.be.withBody;", + " pm.response.to.be.json;", + "});", + "", + "pm.test(\"Test item request 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('id');", + " pm.expect(jsonData.id, '\"id\" must be 1').to.eql(1);", + "});", + "pm.test(\"Test item request 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('description');", + " pm.expect(jsonData.description, '\"description\" must be \"Хотел бы воспользоваться щёткой для обуви\"').to.eql(\"Хотел бы воспользоваться щёткой для обуви\");", + "});", + "pm.test(\"Test item request 'created' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('created');", + " pm.expect(jsonData.created, '\"created\" must be not null').is.not.null;", + "", + " var created = new Date(jsonData.created);", + " var future = new Date(pm.environment.get('currentDateTime'));", + " pm.expect(created, '\"created\" must be < ' + pm.environment.get('currentDateTime')).to.lte(future);", + "});", + "pm.test(\"Test item request 'items' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.have.property('items');", + " pm.expect(jsonData.items, '\"items\" must be not null').is.not.null;", + " pm.expect(jsonData.items.length, 'items count must be 1').to.eql(1);", + "});", + "pm.test(\"Test request.items[0] 'id' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.items[0]).to.have.property('id');", + " pm.expect(jsonData.items[0].id, '\"id\" must be 5').to.eql(5);", + "});", + "pm.test(\"Test request.items[0] 'name' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.items[0]).to.have.property('name');", + " pm.expect(jsonData.items[0].name, '\"name\" must be \"Щётка для обуви\"').to.eql('Щётка для обуви');", + "});", + "pm.test(\"Test request.items[0] 'description' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.items[0]).to.have.property('description');", + " pm.expect(jsonData.items[0].description, '\"description\" must be \"Стандартная щётка для обуви\"').to.eql('Стандартная щётка для обуви');", + "});", + "pm.test(\"Test request.items[0] 'available' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.items[0]).to.have.property('available');", + " pm.expect(jsonData.items[0].available, '\"available\" must be \"true\"').to.true;", + "});", + "pm.test(\"Test request.items[0] 'requestId' field\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.items[0]).to.have.property('requestId');", + " pm.expect(jsonData.items[0].requestId, '\"requestId\" must be \"1\"').to.eq(1);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "var moment = require('moment');", + "", + "var start = moment();", + "pm.environment.set('currentDateTime', start.format('YYYY-MM-DDTHH:mm:ss.sss'));" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/requests/1", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "requests", + "1" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "Pagination", + "item": [ + { + "name": "Bookings get all with from = 0 & size = 0", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings?from=0&size=0", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ], + "query": [ + { + "key": "from", + "value": "0" + }, + { + "key": "size", + "value": "0" + } + ] + } + }, + "response": [] + }, + { + "name": "Bookings owner get all with from = 0 & size = 0", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner?from=0&size=0", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ], + "query": [ + { + "key": "from", + "value": "0" + }, + { + "key": "size", + "value": "0" + } + ] + } + }, + "response": [] + }, + { + "name": "Bookings get all with from = -1 & size = 20", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings?from=-1&size=20", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ], + "query": [ + { + "key": "from", + "value": "-1" + }, + { + "key": "size", + "value": "20" + } + ] + } + }, + "response": [] + }, + { + "name": "Bookings owner get all with from = -1 & size = 20", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner?from=-1&size=20", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ], + "query": [ + { + "key": "from", + "value": "-1" + }, + { + "key": "size", + "value": "20" + } + ] + } + }, + "response": [] + }, + { + "name": "Bookings get all with from = 0 & size = -1", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings?from=0&size=-1", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ], + "query": [ + { + "key": "from", + "value": "0" + }, + { + "key": "size", + "value": "-1" + } + ] + } + }, + "response": [] + }, + { + "name": "Bookings owner get all with from = 0 & size = -1", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 400\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([500,400]);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner?from=0&size=-1", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ], + "query": [ + { + "key": "from", + "value": "0" + }, + { + "key": "size", + "value": "-1" + } + ] + } + }, + "response": [] + }, + { + "name": "Bookings get all with from = 4 & size = 2 when all=5", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200]);", + "});", + "pm.test(\"Test get all bookings\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'bookings count in total').to.eql(1);", + " pm.expect(jsonData[0].id, 'result[0]: \"id\" field').to.eql(1);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings?from=4&size=2", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings" + ], + "query": [ + { + "key": "from", + "value": "4" + }, + { + "key": "size", + "value": "2" + } + ] + } + }, + "response": [] + }, + { + "name": "Bookings owner get all with from = 1 & size = 1 when all=2", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.expect(pm.response.code).to.be.oneOf([200]);", + "});", + "pm.test(\"Test get all owner bookings\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.length, 'owner bookings count in total').to.eql(1);", + " pm.expect(jsonData[0].id, 'result[0]: \"id\" field').to.eql(3);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "X-Sharer-User-Id", + "value": "1", + "type": "text" + }, + { + "key": "Accept", + "value": "*/*", + "type": "text" + } + ], + "url": { + "raw": "{{baseUrl}}/bookings/owner?from=1&size=1", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "bookings", + "owner" + ], + "query": [ + { + "key": "from", + "value": "1" + }, + { + "key": "size", + "value": "1" + } + ] + } + }, + "response": [] + } + ] + } + ], + "variable": [ + { + "key": "baseUrl", + "value": "http://localhost:8080" + } + ] +} \ No newline at end of file diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000..0939c6e --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,3 @@ +FROM amazoncorretto:11 +COPY target/*.jar app.jar +ENTRYPOINT ["java","-jar","/app.jar"] \ No newline at end of file diff --git a/server/db/filmorate.mv.db b/server/db/filmorate.mv.db new file mode 100644 index 0000000000000000000000000000000000000000..7bb1475c0784b577213128a2ed48b0a83ccc76ac GIT binary patch literal 57344 zcmeHQ-H+Q=c9&#%Jh9_VvPrz(UPf^oPpegVNnU>FDU?Ln+RTSDBYWe1fS@QUF)}kU z#^bErZh;gniv9tMVv8+Wpe@j%4~wE`i@vlE?Q>uH)R*?L+oz(B1zMmzydUJ{hcujt z>^Pfiz(Y~u43SU{%NobljGTXEH(LrzwC;2!!dU$^hhuQ7fesmmu7#(#DgwRyitcx}I zPa+@@kO)WwBmxoviGV~vA|Mfv2uK7Z0uq7G5P@5A{r?%FFT0iqNCYGT5&?;TL_i`S z5s(N-1SA3y0g1q~L4Y~=4Hg8TwfCdLuHHTf9&~XCo5x+vfLMSB!3WVp`2J`*}|aH(GCAd+U1b4dwd#d)`>-?|Sao^Luwj zn*&8dMoVd3{;fLwR=Kn1?JA?8vb{4_y!S_Y<2|Ld=eCqRcXO<~ZA?`Qsg^xa_0U8Z zzpdPI_iia~YatG2vp@^X8Fqr{G%_ba06>@+VFd9J4vKIzQ;`!O8wIu{wd#w&D)9M%!;H%H`i~FiHAu|CTpU#%^!ZQ(Cw0^fpKRR;LvUxYxRIF@}@u_@hBf z>5XoVw#Uj%Z`<32iyJ7td&`TR#8A zHyq0_P_OT!zT^0YVVl0IBIMhu?&+59^)$8DBKU0I+1zYXLAKp3uch>Fxw~$E3<%zJ zckhk1Z{9G}jr^hBmOI)!>DY@K*OWIeA22AmYyu2tlX`FL?v9o3jmEbWr1ZSao$Z@@ z{&>eHAit%&arwKf$J@K3Ew}{bUGJXIDf`xkZ+)0HJKMr=(4WLmz zhA`#>rN6ViH{NyQ!Ar;Z_Pc(3x|Sk{aU(smGTI(^?~BJ%X_;Ja!*%=$pU&GO81O=a zJMWPWd@>e3Io-kwV&fGL_MS2v?e2{?ZosAe+Sx8G({oF?L*%>BqMdA16m$dhTS z$!DnQi)!=?&Bdy(4F{kt78>|H%k24<(I46l9=O&}D`?BW+w1R+ZjVPh z+hvM?kyg+eCjQQ@cmc7I5|ogRIaq`7XbUdg-MXFV-o=fdJDomNyRN1B^z*_z%+J_# z+Oye*a_W>0Un_g*;yi4_JpAi=`9w@kuvpCmA)x!=&aOAQxgD$gjclLAX(_a%$^-3p zy`i@o+g7+^q+1Q+nPCP9(I)KL~tHHy{86O5G>87BiqFqF- zUjXg=j}x?W1hJ3%jbFt0kc%Go3Fs+ zy~`%=iJG0iQL>?Lr57uzbo0wFhkvqQ4%4QU6dHQXD0I?W1!ab|r&H$Us{qKo%7DNP zA@k_K5fO(sgUM@v$=|L36X-YtiqK&dSfF_+F6=a*&)jZOGr>$<^L0Sy-O9GkSOgC@ z6C2GdfX5HY&Hibohz8HGnJ28Ihou${1Z;intb8Z^so-Pd69zF$?fVWF7OYzAMf83{%i&Hg&f z3*)5qdZ2XBWZC(XHeq%*|fPu}JJ+Y&umd|Z9 zzYT`(A5SoR{hh5Xc;Ap1KDNJV!`DYW6`8i?o35_IBi>N=U2G40uMb90g-5)h2hYtp zTQv6GAD0=LvNac1p#^5my)(Xb_Vrj(Ih`%5cD2iG*&8r5D?g^VaCgiYvvgP&7_%14 z(Z5_UN0Y|Yj2ZNuQCdC}Ra6$*ma6PxbM_|S^2?RYSr2Z7i+~a4M8=+718DwcMbJR^ z8En!%E1?6;OW|2;(c%|l?^S+&TQ+Y5OR&+5Uy%Lgsxay2Y?|29a+}s`)oN?&FaLYJ z-maa8x7{6${MFau&jz9!`W+@aSfv~K6V~V+Jsul$j~!{!J&SH^x^d_xpqmNZgrrlG z{I$qmoBVaw4ugZJ<6kD5`-ju$aR;Hyo|V~i#61mX_A*E6y7-%pUle+<=+6FpG6;@? zOXL^W*$N&cpLe6#>*V|SgXnO46dXPb!edDLdq|re2b2A%qtY(u4r0R4Jxv!6WU|no zbR_=dyhOS=jt(Ad5)r;c_8%Qi=bQ5nIw-rV5xlxSk*%AT?P}b#n>1y4jCWbW;w<~K zmjC%WY0a*z{ZaI!Yr{K#tf@x(<6ysw;SKpjpCL;)OwXMIX(jEVAPm4YK-Wp!Ld-NmViS=)t6kOg{>&l@GUZPs6i;s=b2$xs^QohR1XrpEglKJ zGBW^=+BJSYFe>DzD40a5W>LMetiYHAA=N%+k`|wu18a4wVW5Vg)oSO~uU>7`)@$p;8QMWA|A6=hjepQD97M-K z=l*mp_Jnp2-Dq@!|FF*7sVZ})&X_xO|Nh6(7Wh(4aHYndZxeSaB5qb=M%}D7{B{^U zKJJ3GpzcV2xP12f<q{B=)A|5z3r-^i-IYUf3a1Do!W)x)w+rksZ z5s?)I6C}urW{IpkLERu=R*^N}P?}6ujmZia!xAAh9l(b=t_A60H#Ul*qO1b08kN-! zO+i*w|9y_D&Tut}tSG_N$_%_lkj1f^{c$%D*2;R>jW8A#0kF_1^RkzUr>9WrL_8-9 zMd^$>xllYV~(&wf0qrJ9wvd{_lT8;twvo^TXKOn92Xv}6aXOh~CQu_uE2h3yy)Vg66i}QTO1!YVY-3kUH zws8>R0(=+L_D-@os1seW^f1vuRdZ%mWkILZT+9qh6x8B^Mhwx($(D@@iY8ppY1Xpo z%(7{46QIUI)sdMZs_Iyq6)YRv-x;D26*N#q8?5SF&>0hST3JvqUKG(;PEcaiaESQG zBT+Ok!6yv;j0u{#S*SXgIBM3+nT^eiiKE{m6Hmd!)jk0ecZHa`dh~C^)UEyZU1I9i zzyBK9%0ChTiGV~vA|Mfv2uK7Z0uq6zhd?3zo-3U?r zG9Lg^%|tw8KEU#1j0jr$rG{62jHuMVv=xE<^v?rzcL@7LZW9=<^v?L-;A|Dh|T4p^{YsPsum%i zGkh{1pnBZ<;;?rfo}YbmllcIxG&VmAjm!s#(}Q4zxfN#$(G;iWC?DY5-@W!n_1X)S z;y`&osIfG3N(O`ycAzg_K0Uakizwq1GR8NjU|S zMO;8>cwZdEmycN%si8>Ba*&OiTf`8xOuUpdN{p4m%Ys*FXjd+HwN^X-4?m0(K4kpA zT^385NgT+>(jp;oARkQooJYyZ_?tv-JGO{}=r4iMhst|KHF7brRPg`vU}J3Z%!FAu3DP?ad=316XktyChX4Pb^#5mhHCC~VevbVA zKX``zf9d|0?*C6uo+;h`3+Xi_9biJR!T zq7W!o;u4c|fP}O$b%#khK+3!;=>P>PSmt6+Sh2XveZ}1~J1R?r3rj*N2-ti?uCBnM}e0OZkQDV*{ z9bj5#q_|XV{_N8MHjiFCsMju@&i&8h0I-Y$ki<}3lqZIgaR9(!Rjd?shB$zP4veR& z1}AdSuqXwRz)IYKVU~+#Q64LmE)J=Py;=oXaq8$w6J5oag_wkJBo#hF);+TcI zodS~<_r^>9KT1g|`TrOZTq#MC8byp z6IMDb_$$u;7l|n=5mF|ir_m>?mKgH?n?G&dtTkS(t#f|abxy&%&Y4BmF(cQ#0IXl8 zX{hU*fbasN6c8OUFVFb?fKCMoe#Cn!N(7e=SNZJ_;Kehjme9qcZ2;$(fG-O=-Lp7l;=lJ z-pU<3opg5R-;ep2#iQ0Pa7K!!aPsDPdh)y|#~@~>_vAQokB)*TT%@NUz_}(7;LRcw z+mH7531m;P_w#EE+baF%F)AOfa}D@cuXb$n6vv)F<+0}~%CH9KJjO`n4V~76YwubQB$i(Y080zf+~j z7LW^*qvJBCul`eAmN{LqpJdRp2d3@mzKSguik`YAR5*2!-yfJm2YFf_TgB=jr|<|r zoieA@q+aU6kY!FY#XES}3t8rLSy5mhcp5^TQ>dia>-T(PsP}x=v4@~CLu?McUayCs zu1GF^;tZS!&zjbx+I20}CmGiyHO#k!w*TvHz#uGP2tK6YKWiwzLyB^nyOZ4ER> zcl)m4Kn1g$UY_DEb_NxGK4?v<0kc%GWtmeNTrT69HVILUEOQFQ9|whE_RlD;NykH| zuLOnuhDOhX$B=>HJ6P-c*1*(yc&HEHf5Fo67%QUZKeMzZ)u35!>ttM0Ng#kMbIMmo z@s?!i%QB})c;PdmHR)lb!drjO@AW;^H!LuLt^?(s9S>>(xwc`L-mqZ!KDV?c)vk8A zEt6$VGxTVQ%F4K=FL+$j`Tx0kv9YwwDJe#3u-d1zmZ?E&nHsc~sX=R*8nl+FL2H>B zw3ewsYnd7$JnoHk723)Af1hP#Q(6D-A(WT~J>>x= zvi@IJ*8j^#T*~@?JSIqPB?1xwiGV~vA|Mfv2uK8;Uj!KcUmAbU*EmQ`>pu!&P#MBI(PtSACT|yC9?nMa5~?df6zhMU2ToHR{Yn=X8s^L93KUT z4?!j1t>(k4;NuZRE%-Z~X5I$Bo*0k(ITufa+@@ym&zsHf}x#eJZ zSOiHw*v`2N;_ho~e62Xguti}8oWDSWRKig)XV@?e765I*mf3&7Y?UP!qeFYxI z->KE3e<2U$ji3Irz^<6*`uqIF|FiXfy8ceq|5m#GcPz(n(DW(t|J!W+KP|5R!LQaP z>?sj@3xMcb0Fw+JwJ+>g)cwX!NrB?ggOMr)~M zOw^fMM$Ur36{V=o(lEwvcr;ZFM8*Dm7{(vv4I?jl!H4@Zvx~pWB}>ggY_U;dvEx!4 zv6QzV&HN!)@-w}rD;R7my(=eg?!;j=D%)!?(e2k_j*D_01iAiCSwQ6ae;PgRXx8O; z1>2#aa=M<`!*tEff(z*m@G8VK5tm3S*n!1&@)-yh$QrwoUt^1Fca?U*mx|(^ri%wM zS@`Nl{7J6=AsmaZI}krBf0(;--d8Hs=C%VdvQ9s{y*s@gmd3Mp&Ll_H65#u=Rhs{!Z5awy^%U1Jlu_;ZyMc|39TA@_qmS literal 0 HcmV?d00001 diff --git a/server/pom.xml b/server/pom.xml new file mode 100644 index 0000000..7227d57 --- /dev/null +++ b/server/pom.xml @@ -0,0 +1,90 @@ + + + 4.0.0 + + ru.practicum + shareit + 0.0.1-SNAPSHOT + + + shareit-server + 0.0.1-SNAPSHOT + + ShareIt Server + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.postgresql + postgresql + runtime + + + + com.h2database + h2 + runtime + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + org.projectlombok + lombok + true + + + + org.springframework.boot + spring-boot-starter-test + test + + + jakarta.validation + jakarta.validation-api + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + coverage + + + + org.jacoco + jacoco-maven-plugin + + + + + + + diff --git a/src/main/java/ru/practicum/shareit/ShareItApp.java b/server/src/main/java/ru/practicum/shareit/ShareItServer.java similarity index 73% rename from src/main/java/ru/practicum/shareit/ShareItApp.java rename to server/src/main/java/ru/practicum/shareit/ShareItServer.java index a00ad56..303541d 100644 --- a/src/main/java/ru/practicum/shareit/ShareItApp.java +++ b/server/src/main/java/ru/practicum/shareit/ShareItServer.java @@ -4,10 +4,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class ShareItApp { +public class ShareItServer { public static void main(String[] args) { - SpringApplication.run(ShareItApp.class, args); + SpringApplication.run(ShareItServer.class, args); } } diff --git a/src/main/java/ru/practicum/shareit/booking/controller/BookingController.java b/server/src/main/java/ru/practicum/shareit/booking/controller/BookingController.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/controller/BookingController.java rename to server/src/main/java/ru/practicum/shareit/booking/controller/BookingController.java diff --git a/src/main/java/ru/practicum/shareit/booking/exceptions/BookerAndOwnerIdException.java b/server/src/main/java/ru/practicum/shareit/booking/exceptions/BookerAndOwnerIdException.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/exceptions/BookerAndOwnerIdException.java rename to server/src/main/java/ru/practicum/shareit/booking/exceptions/BookerAndOwnerIdException.java diff --git a/src/main/java/ru/practicum/shareit/booking/exceptions/UnavailableItemException.java b/server/src/main/java/ru/practicum/shareit/booking/exceptions/UnavailableItemException.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/exceptions/UnavailableItemException.java rename to server/src/main/java/ru/practicum/shareit/booking/exceptions/UnavailableItemException.java diff --git a/src/main/java/ru/practicum/shareit/booking/exceptions/WrongStateException.java b/server/src/main/java/ru/practicum/shareit/booking/exceptions/WrongStateException.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/exceptions/WrongStateException.java rename to server/src/main/java/ru/practicum/shareit/booking/exceptions/WrongStateException.java diff --git a/src/main/java/ru/practicum/shareit/booking/model/Booking.java b/server/src/main/java/ru/practicum/shareit/booking/model/Booking.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/model/Booking.java rename to server/src/main/java/ru/practicum/shareit/booking/model/Booking.java diff --git a/src/main/java/ru/practicum/shareit/booking/model/BookingDto.java b/server/src/main/java/ru/practicum/shareit/booking/model/BookingDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/model/BookingDto.java rename to server/src/main/java/ru/practicum/shareit/booking/model/BookingDto.java diff --git a/src/main/java/ru/practicum/shareit/booking/model/BookingInItemDto.java b/server/src/main/java/ru/practicum/shareit/booking/model/BookingInItemDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/model/BookingInItemDto.java rename to server/src/main/java/ru/practicum/shareit/booking/model/BookingInItemDto.java diff --git a/src/main/java/ru/practicum/shareit/booking/model/BookingIncomingDto.java b/server/src/main/java/ru/practicum/shareit/booking/model/BookingIncomingDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/model/BookingIncomingDto.java rename to server/src/main/java/ru/practicum/shareit/booking/model/BookingIncomingDto.java diff --git a/src/main/java/ru/practicum/shareit/booking/model/BookingMapper.java b/server/src/main/java/ru/practicum/shareit/booking/model/BookingMapper.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/model/BookingMapper.java rename to server/src/main/java/ru/practicum/shareit/booking/model/BookingMapper.java diff --git a/src/main/java/ru/practicum/shareit/booking/model/BookingResponseDto.java b/server/src/main/java/ru/practicum/shareit/booking/model/BookingResponseDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/model/BookingResponseDto.java rename to server/src/main/java/ru/practicum/shareit/booking/model/BookingResponseDto.java diff --git a/src/main/java/ru/practicum/shareit/booking/model/State.java b/server/src/main/java/ru/practicum/shareit/booking/model/State.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/model/State.java rename to server/src/main/java/ru/practicum/shareit/booking/model/State.java diff --git a/src/main/java/ru/practicum/shareit/booking/model/Status.java b/server/src/main/java/ru/practicum/shareit/booking/model/Status.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/model/Status.java rename to server/src/main/java/ru/practicum/shareit/booking/model/Status.java diff --git a/src/main/java/ru/practicum/shareit/booking/repository/BookingRepository.java b/server/src/main/java/ru/practicum/shareit/booking/repository/BookingRepository.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/repository/BookingRepository.java rename to server/src/main/java/ru/practicum/shareit/booking/repository/BookingRepository.java diff --git a/src/main/java/ru/practicum/shareit/booking/service/BookingService.java b/server/src/main/java/ru/practicum/shareit/booking/service/BookingService.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/service/BookingService.java rename to server/src/main/java/ru/practicum/shareit/booking/service/BookingService.java diff --git a/src/main/java/ru/practicum/shareit/booking/service/BookingServiceImpl.java b/server/src/main/java/ru/practicum/shareit/booking/service/BookingServiceImpl.java similarity index 100% rename from src/main/java/ru/practicum/shareit/booking/service/BookingServiceImpl.java rename to server/src/main/java/ru/practicum/shareit/booking/service/BookingServiceImpl.java diff --git a/src/main/java/ru/practicum/shareit/error/ErrorHandler.java b/server/src/main/java/ru/practicum/shareit/error/ErrorHandler.java similarity index 100% rename from src/main/java/ru/practicum/shareit/error/ErrorHandler.java rename to server/src/main/java/ru/practicum/shareit/error/ErrorHandler.java diff --git a/src/main/java/ru/practicum/shareit/error/ErrorResponse.java b/server/src/main/java/ru/practicum/shareit/error/ErrorResponse.java similarity index 100% rename from src/main/java/ru/practicum/shareit/error/ErrorResponse.java rename to server/src/main/java/ru/practicum/shareit/error/ErrorResponse.java diff --git a/src/main/java/ru/practicum/shareit/item/controller/ItemController.java b/server/src/main/java/ru/practicum/shareit/item/controller/ItemController.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/controller/ItemController.java rename to server/src/main/java/ru/practicum/shareit/item/controller/ItemController.java diff --git a/src/main/java/ru/practicum/shareit/item/exceptions/CommentException.java b/server/src/main/java/ru/practicum/shareit/item/exceptions/CommentException.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/exceptions/CommentException.java rename to server/src/main/java/ru/practicum/shareit/item/exceptions/CommentException.java diff --git a/src/main/java/ru/practicum/shareit/item/exceptions/DeniedAccessException.java b/server/src/main/java/ru/practicum/shareit/item/exceptions/DeniedAccessException.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/exceptions/DeniedAccessException.java rename to server/src/main/java/ru/practicum/shareit/item/exceptions/DeniedAccessException.java diff --git a/src/main/java/ru/practicum/shareit/item/exceptions/OwnerNotFoundException.java b/server/src/main/java/ru/practicum/shareit/item/exceptions/OwnerNotFoundException.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/exceptions/OwnerNotFoundException.java rename to server/src/main/java/ru/practicum/shareit/item/exceptions/OwnerNotFoundException.java diff --git a/src/main/java/ru/practicum/shareit/item/model/Comment.java b/server/src/main/java/ru/practicum/shareit/item/model/Comment.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/model/Comment.java rename to server/src/main/java/ru/practicum/shareit/item/model/Comment.java diff --git a/src/main/java/ru/practicum/shareit/item/model/CommentDto.java b/server/src/main/java/ru/practicum/shareit/item/model/CommentDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/model/CommentDto.java rename to server/src/main/java/ru/practicum/shareit/item/model/CommentDto.java diff --git a/src/main/java/ru/practicum/shareit/item/model/CommentMapper.java b/server/src/main/java/ru/practicum/shareit/item/model/CommentMapper.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/model/CommentMapper.java rename to server/src/main/java/ru/practicum/shareit/item/model/CommentMapper.java diff --git a/src/main/java/ru/practicum/shareit/item/model/CreateCommentDto.java b/server/src/main/java/ru/practicum/shareit/item/model/CreateCommentDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/model/CreateCommentDto.java rename to server/src/main/java/ru/practicum/shareit/item/model/CreateCommentDto.java diff --git a/src/main/java/ru/practicum/shareit/item/model/Item.java b/server/src/main/java/ru/practicum/shareit/item/model/Item.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/model/Item.java rename to server/src/main/java/ru/practicum/shareit/item/model/Item.java diff --git a/src/main/java/ru/practicum/shareit/item/model/ItemDto.java b/server/src/main/java/ru/practicum/shareit/item/model/ItemDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/model/ItemDto.java rename to server/src/main/java/ru/practicum/shareit/item/model/ItemDto.java diff --git a/src/main/java/ru/practicum/shareit/item/model/ItemInRequestDto.java b/server/src/main/java/ru/practicum/shareit/item/model/ItemInRequestDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/model/ItemInRequestDto.java rename to server/src/main/java/ru/practicum/shareit/item/model/ItemInRequestDto.java diff --git a/src/main/java/ru/practicum/shareit/item/model/ItemMapper.java b/server/src/main/java/ru/practicum/shareit/item/model/ItemMapper.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/model/ItemMapper.java rename to server/src/main/java/ru/practicum/shareit/item/model/ItemMapper.java diff --git a/src/main/java/ru/practicum/shareit/item/repository/CommentRepository.java b/server/src/main/java/ru/practicum/shareit/item/repository/CommentRepository.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/repository/CommentRepository.java rename to server/src/main/java/ru/practicum/shareit/item/repository/CommentRepository.java diff --git a/src/main/java/ru/practicum/shareit/item/repository/ItemRepository.java b/server/src/main/java/ru/practicum/shareit/item/repository/ItemRepository.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/repository/ItemRepository.java rename to server/src/main/java/ru/practicum/shareit/item/repository/ItemRepository.java diff --git a/src/main/java/ru/practicum/shareit/item/service/ItemService.java b/server/src/main/java/ru/practicum/shareit/item/service/ItemService.java similarity index 100% rename from src/main/java/ru/practicum/shareit/item/service/ItemService.java rename to server/src/main/java/ru/practicum/shareit/item/service/ItemService.java diff --git a/src/main/java/ru/practicum/shareit/item/service/ItemServiceImpl.java b/server/src/main/java/ru/practicum/shareit/item/service/ItemServiceImpl.java similarity index 99% rename from src/main/java/ru/practicum/shareit/item/service/ItemServiceImpl.java rename to server/src/main/java/ru/practicum/shareit/item/service/ItemServiceImpl.java index 146979a..bdc0508 100644 --- a/src/main/java/ru/practicum/shareit/item/service/ItemServiceImpl.java +++ b/server/src/main/java/ru/practicum/shareit/item/service/ItemServiceImpl.java @@ -152,6 +152,7 @@ private void fillItemDtoList(List targetList, List foundItems, Lo Sort sortAsc = Sort.by("start").ascending(); List comments = commentRepository.findAllByItemIn(foundItems); + for (Item item : foundItems) { if (item.getOwnerId().equals(userId)) { ItemDto dto = constructItemDtoForOwner(item, now, sortDesc, sortAsc, comments); diff --git a/src/main/java/ru/practicum/shareit/request/controller/ItemRequestController.java b/server/src/main/java/ru/practicum/shareit/request/controller/ItemRequestController.java similarity index 100% rename from src/main/java/ru/practicum/shareit/request/controller/ItemRequestController.java rename to server/src/main/java/ru/practicum/shareit/request/controller/ItemRequestController.java diff --git a/src/main/java/ru/practicum/shareit/request/model/ItemRequest.java b/server/src/main/java/ru/practicum/shareit/request/model/ItemRequest.java similarity index 100% rename from src/main/java/ru/practicum/shareit/request/model/ItemRequest.java rename to server/src/main/java/ru/practicum/shareit/request/model/ItemRequest.java diff --git a/src/main/java/ru/practicum/shareit/request/model/ItemRequestInItemDto.java b/server/src/main/java/ru/practicum/shareit/request/model/ItemRequestInItemDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/request/model/ItemRequestInItemDto.java rename to server/src/main/java/ru/practicum/shareit/request/model/ItemRequestInItemDto.java diff --git a/src/main/java/ru/practicum/shareit/request/model/ItemRequestIncomingDto.java b/server/src/main/java/ru/practicum/shareit/request/model/ItemRequestIncomingDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/request/model/ItemRequestIncomingDto.java rename to server/src/main/java/ru/practicum/shareit/request/model/ItemRequestIncomingDto.java diff --git a/src/main/java/ru/practicum/shareit/request/model/ItemRequestMapper.java b/server/src/main/java/ru/practicum/shareit/request/model/ItemRequestMapper.java similarity index 100% rename from src/main/java/ru/practicum/shareit/request/model/ItemRequestMapper.java rename to server/src/main/java/ru/practicum/shareit/request/model/ItemRequestMapper.java diff --git a/src/main/java/ru/practicum/shareit/request/model/ItemRequestResponseDto.java b/server/src/main/java/ru/practicum/shareit/request/model/ItemRequestResponseDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/request/model/ItemRequestResponseDto.java rename to server/src/main/java/ru/practicum/shareit/request/model/ItemRequestResponseDto.java diff --git a/src/main/java/ru/practicum/shareit/request/repository/ItemRequestRepository.java b/server/src/main/java/ru/practicum/shareit/request/repository/ItemRequestRepository.java similarity index 100% rename from src/main/java/ru/practicum/shareit/request/repository/ItemRequestRepository.java rename to server/src/main/java/ru/practicum/shareit/request/repository/ItemRequestRepository.java diff --git a/src/main/java/ru/practicum/shareit/request/service/ItemRequestService.java b/server/src/main/java/ru/practicum/shareit/request/service/ItemRequestService.java similarity index 100% rename from src/main/java/ru/practicum/shareit/request/service/ItemRequestService.java rename to server/src/main/java/ru/practicum/shareit/request/service/ItemRequestService.java diff --git a/src/main/java/ru/practicum/shareit/request/service/ItemRequestServiceImpl.java b/server/src/main/java/ru/practicum/shareit/request/service/ItemRequestServiceImpl.java similarity index 100% rename from src/main/java/ru/practicum/shareit/request/service/ItemRequestServiceImpl.java rename to server/src/main/java/ru/practicum/shareit/request/service/ItemRequestServiceImpl.java diff --git a/src/main/java/ru/practicum/shareit/user/controller/UserController.java b/server/src/main/java/ru/practicum/shareit/user/controller/UserController.java similarity index 100% rename from src/main/java/ru/practicum/shareit/user/controller/UserController.java rename to server/src/main/java/ru/practicum/shareit/user/controller/UserController.java diff --git a/src/main/java/ru/practicum/shareit/user/exceptions/EmailValidationException.java b/server/src/main/java/ru/practicum/shareit/user/exceptions/EmailValidationException.java similarity index 100% rename from src/main/java/ru/practicum/shareit/user/exceptions/EmailValidationException.java rename to server/src/main/java/ru/practicum/shareit/user/exceptions/EmailValidationException.java diff --git a/src/main/java/ru/practicum/shareit/user/exceptions/UserNotFoundException.java b/server/src/main/java/ru/practicum/shareit/user/exceptions/UserNotFoundException.java similarity index 100% rename from src/main/java/ru/practicum/shareit/user/exceptions/UserNotFoundException.java rename to server/src/main/java/ru/practicum/shareit/user/exceptions/UserNotFoundException.java diff --git a/src/main/java/ru/practicum/shareit/user/model/User.java b/server/src/main/java/ru/practicum/shareit/user/model/User.java similarity index 100% rename from src/main/java/ru/practicum/shareit/user/model/User.java rename to server/src/main/java/ru/practicum/shareit/user/model/User.java diff --git a/src/main/java/ru/practicum/shareit/user/model/UserDto.java b/server/src/main/java/ru/practicum/shareit/user/model/UserDto.java similarity index 100% rename from src/main/java/ru/practicum/shareit/user/model/UserDto.java rename to server/src/main/java/ru/practicum/shareit/user/model/UserDto.java diff --git a/src/main/java/ru/practicum/shareit/user/model/UserMapper.java b/server/src/main/java/ru/practicum/shareit/user/model/UserMapper.java similarity index 100% rename from src/main/java/ru/practicum/shareit/user/model/UserMapper.java rename to server/src/main/java/ru/practicum/shareit/user/model/UserMapper.java diff --git a/src/main/java/ru/practicum/shareit/user/repository/UserRepository.java b/server/src/main/java/ru/practicum/shareit/user/repository/UserRepository.java similarity index 100% rename from src/main/java/ru/practicum/shareit/user/repository/UserRepository.java rename to server/src/main/java/ru/practicum/shareit/user/repository/UserRepository.java diff --git a/src/main/java/ru/practicum/shareit/user/service/UserService.java b/server/src/main/java/ru/practicum/shareit/user/service/UserService.java similarity index 100% rename from src/main/java/ru/practicum/shareit/user/service/UserService.java rename to server/src/main/java/ru/practicum/shareit/user/service/UserService.java diff --git a/src/main/java/ru/practicum/shareit/user/service/UserServiceImpl.java b/server/src/main/java/ru/practicum/shareit/user/service/UserServiceImpl.java similarity index 100% rename from src/main/java/ru/practicum/shareit/user/service/UserServiceImpl.java rename to server/src/main/java/ru/practicum/shareit/user/service/UserServiceImpl.java diff --git a/src/main/resources/application.properties b/server/src/main/resources/application.properties similarity index 97% rename from src/main/resources/application.properties rename to server/src/main/resources/application.properties index ddeb46e..b30fa80 100644 --- a/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -1,3 +1,5 @@ +server.port=9090 + spring.jpa.hibernate.ddl-auto=none spring.jpa.hibernate.dialect=org.hibernate.dialect.PostgresSQLDialect spring.jpa.hibernate.show_sql=true diff --git a/src/main/resources/schema.sql b/server/src/main/resources/schema.sql similarity index 100% rename from src/main/resources/schema.sql rename to server/src/main/resources/schema.sql diff --git a/src/test/java/ru/practicum/shareit/ShareItTests.java b/server/src/test/java/ru/practicum/shareit/ShareItTests.java similarity index 100% rename from src/test/java/ru/practicum/shareit/ShareItTests.java rename to server/src/test/java/ru/practicum/shareit/ShareItTests.java diff --git a/src/test/java/ru/practicum/shareit/booking/BookingControllerTest.java b/server/src/test/java/ru/practicum/shareit/booking/BookingControllerTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/booking/BookingControllerTest.java rename to server/src/test/java/ru/practicum/shareit/booking/BookingControllerTest.java diff --git a/src/test/java/ru/practicum/shareit/booking/BookingMapperTest.java b/server/src/test/java/ru/practicum/shareit/booking/BookingMapperTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/booking/BookingMapperTest.java rename to server/src/test/java/ru/practicum/shareit/booking/BookingMapperTest.java diff --git a/src/test/java/ru/practicum/shareit/booking/BookingRepositoryTest.java b/server/src/test/java/ru/practicum/shareit/booking/BookingRepositoryTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/booking/BookingRepositoryTest.java rename to server/src/test/java/ru/practicum/shareit/booking/BookingRepositoryTest.java diff --git a/src/test/java/ru/practicum/shareit/booking/BookingServiceTest.java b/server/src/test/java/ru/practicum/shareit/booking/BookingServiceTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/booking/BookingServiceTest.java rename to server/src/test/java/ru/practicum/shareit/booking/BookingServiceTest.java diff --git a/src/test/java/ru/practicum/shareit/error_handler/ErrorHandlerTest.java b/server/src/test/java/ru/practicum/shareit/error_handler/ErrorHandlerTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/error_handler/ErrorHandlerTest.java rename to server/src/test/java/ru/practicum/shareit/error_handler/ErrorHandlerTest.java diff --git a/src/test/java/ru/practicum/shareit/item/IntegrationItemServiceTest.java b/server/src/test/java/ru/practicum/shareit/item/IntegrationItemServiceTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/item/IntegrationItemServiceTest.java rename to server/src/test/java/ru/practicum/shareit/item/IntegrationItemServiceTest.java diff --git a/src/test/java/ru/practicum/shareit/item/ItemControllerTest.java b/server/src/test/java/ru/practicum/shareit/item/ItemControllerTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/item/ItemControllerTest.java rename to server/src/test/java/ru/practicum/shareit/item/ItemControllerTest.java diff --git a/src/test/java/ru/practicum/shareit/item/ItemServiceTest.java b/server/src/test/java/ru/practicum/shareit/item/ItemServiceTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/item/ItemServiceTest.java rename to server/src/test/java/ru/practicum/shareit/item/ItemServiceTest.java diff --git a/src/test/java/ru/practicum/shareit/item/mapper/CommentMapperTest.java b/server/src/test/java/ru/practicum/shareit/item/mapper/CommentMapperTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/item/mapper/CommentMapperTest.java rename to server/src/test/java/ru/practicum/shareit/item/mapper/CommentMapperTest.java diff --git a/src/test/java/ru/practicum/shareit/item/mapper/ItemMapperTest.java b/server/src/test/java/ru/practicum/shareit/item/mapper/ItemMapperTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/item/mapper/ItemMapperTest.java rename to server/src/test/java/ru/practicum/shareit/item/mapper/ItemMapperTest.java diff --git a/src/test/java/ru/practicum/shareit/item/repository/CommentRepositoryTest.java b/server/src/test/java/ru/practicum/shareit/item/repository/CommentRepositoryTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/item/repository/CommentRepositoryTest.java rename to server/src/test/java/ru/practicum/shareit/item/repository/CommentRepositoryTest.java diff --git a/src/test/java/ru/practicum/shareit/item/repository/ItemRepositoryTest.java b/server/src/test/java/ru/practicum/shareit/item/repository/ItemRepositoryTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/item/repository/ItemRepositoryTest.java rename to server/src/test/java/ru/practicum/shareit/item/repository/ItemRepositoryTest.java diff --git a/src/test/java/ru/practicum/shareit/requests/ItemRequestControllerTest.java b/server/src/test/java/ru/practicum/shareit/requests/ItemRequestControllerTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/requests/ItemRequestControllerTest.java rename to server/src/test/java/ru/practicum/shareit/requests/ItemRequestControllerTest.java diff --git a/src/test/java/ru/practicum/shareit/requests/ItemRequestMapperTest.java b/server/src/test/java/ru/practicum/shareit/requests/ItemRequestMapperTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/requests/ItemRequestMapperTest.java rename to server/src/test/java/ru/practicum/shareit/requests/ItemRequestMapperTest.java diff --git a/src/test/java/ru/practicum/shareit/requests/ItemRequestRepositoryTest.java b/server/src/test/java/ru/practicum/shareit/requests/ItemRequestRepositoryTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/requests/ItemRequestRepositoryTest.java rename to server/src/test/java/ru/practicum/shareit/requests/ItemRequestRepositoryTest.java diff --git a/src/test/java/ru/practicum/shareit/requests/ItemRequestServiceTest.java b/server/src/test/java/ru/practicum/shareit/requests/ItemRequestServiceTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/requests/ItemRequestServiceTest.java rename to server/src/test/java/ru/practicum/shareit/requests/ItemRequestServiceTest.java diff --git a/src/test/java/ru/practicum/shareit/user/IntegrationUserServiceTest.java b/server/src/test/java/ru/practicum/shareit/user/IntegrationUserServiceTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/user/IntegrationUserServiceTest.java rename to server/src/test/java/ru/practicum/shareit/user/IntegrationUserServiceTest.java diff --git a/src/test/java/ru/practicum/shareit/user/UserControllerTest.java b/server/src/test/java/ru/practicum/shareit/user/UserControllerTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/user/UserControllerTest.java rename to server/src/test/java/ru/practicum/shareit/user/UserControllerTest.java diff --git a/src/test/java/ru/practicum/shareit/user/UserMapperTest.java b/server/src/test/java/ru/practicum/shareit/user/UserMapperTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/user/UserMapperTest.java rename to server/src/test/java/ru/practicum/shareit/user/UserMapperTest.java diff --git a/src/test/java/ru/practicum/shareit/user/UserServiceTest.java b/server/src/test/java/ru/practicum/shareit/user/UserServiceTest.java similarity index 100% rename from src/test/java/ru/practicum/shareit/user/UserServiceTest.java rename to server/src/test/java/ru/practicum/shareit/user/UserServiceTest.java From d259963a2d99e7c51cdcc2914afe7e7711bd78a0 Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 13:15:14 +0300 Subject: [PATCH 02/12] Delete filmorate.mv.db --- server/db/filmorate.mv.db | Bin 57344 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 server/db/filmorate.mv.db diff --git a/server/db/filmorate.mv.db b/server/db/filmorate.mv.db deleted file mode 100644 index 7bb1475c0784b577213128a2ed48b0a83ccc76ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 57344 zcmeHQ-H+Q=c9&#%Jh9_VvPrz(UPf^oPpegVNnU>FDU?Ln+RTSDBYWe1fS@QUF)}kU z#^bErZh;gniv9tMVv8+Wpe@j%4~wE`i@vlE?Q>uH)R*?L+oz(B1zMmzydUJ{hcujt z>^Pfiz(Y~u43SU{%NobljGTXEH(LrzwC;2!!dU$^hhuQ7fesmmu7#(#DgwRyitcx}I zPa+@@kO)WwBmxoviGV~vA|Mfv2uK7Z0uq7G5P@5A{r?%FFT0iqNCYGT5&?;TL_i`S z5s(N-1SA3y0g1q~L4Y~=4Hg8TwfCdLuHHTf9&~XCo5x+vfLMSB!3WVp`2J`*}|aH(GCAd+U1b4dwd#d)`>-?|Sao^Luwj zn*&8dMoVd3{;fLwR=Kn1?JA?8vb{4_y!S_Y<2|Ld=eCqRcXO<~ZA?`Qsg^xa_0U8Z zzpdPI_iia~YatG2vp@^X8Fqr{G%_ba06>@+VFd9J4vKIzQ;`!O8wIu{wd#w&D)9M%!;H%H`i~FiHAu|CTpU#%^!ZQ(Cw0^fpKRR;LvUxYxRIF@}@u_@hBf z>5XoVw#Uj%Z`<32iyJ7td&`TR#8A zHyq0_P_OT!zT^0YVVl0IBIMhu?&+59^)$8DBKU0I+1zYXLAKp3uch>Fxw~$E3<%zJ zckhk1Z{9G}jr^hBmOI)!>DY@K*OWIeA22AmYyu2tlX`FL?v9o3jmEbWr1ZSao$Z@@ z{&>eHAit%&arwKf$J@K3Ew}{bUGJXIDf`xkZ+)0HJKMr=(4WLmz zhA`#>rN6ViH{NyQ!Ar;Z_Pc(3x|Sk{aU(smGTI(^?~BJ%X_;Ja!*%=$pU&GO81O=a zJMWPWd@>e3Io-kwV&fGL_MS2v?e2{?ZosAe+Sx8G({oF?L*%>BqMdA16m$dhTS z$!DnQi)!=?&Bdy(4F{kt78>|H%k24<(I46l9=O&}D`?BW+w1R+ZjVPh z+hvM?kyg+eCjQQ@cmc7I5|ogRIaq`7XbUdg-MXFV-o=fdJDomNyRN1B^z*_z%+J_# z+Oye*a_W>0Un_g*;yi4_JpAi=`9w@kuvpCmA)x!=&aOAQxgD$gjclLAX(_a%$^-3p zy`i@o+g7+^q+1Q+nPCP9(I)KL~tHHy{86O5G>87BiqFqF- zUjXg=j}x?W1hJ3%jbFt0kc%Go3Fs+ zy~`%=iJG0iQL>?Lr57uzbo0wFhkvqQ4%4QU6dHQXD0I?W1!ab|r&H$Us{qKo%7DNP zA@k_K5fO(sgUM@v$=|L36X-YtiqK&dSfF_+F6=a*&)jZOGr>$<^L0Sy-O9GkSOgC@ z6C2GdfX5HY&Hibohz8HGnJ28Ihou${1Z;intb8Z^so-Pd69zF$?fVWF7OYzAMf83{%i&Hg&f z3*)5qdZ2XBWZC(XHeq%*|fPu}JJ+Y&umd|Z9 zzYT`(A5SoR{hh5Xc;Ap1KDNJV!`DYW6`8i?o35_IBi>N=U2G40uMb90g-5)h2hYtp zTQv6GAD0=LvNac1p#^5my)(Xb_Vrj(Ih`%5cD2iG*&8r5D?g^VaCgiYvvgP&7_%14 z(Z5_UN0Y|Yj2ZNuQCdC}Ra6$*ma6PxbM_|S^2?RYSr2Z7i+~a4M8=+718DwcMbJR^ z8En!%E1?6;OW|2;(c%|l?^S+&TQ+Y5OR&+5Uy%Lgsxay2Y?|29a+}s`)oN?&FaLYJ z-maa8x7{6${MFau&jz9!`W+@aSfv~K6V~V+Jsul$j~!{!J&SH^x^d_xpqmNZgrrlG z{I$qmoBVaw4ugZJ<6kD5`-ju$aR;Hyo|V~i#61mX_A*E6y7-%pUle+<=+6FpG6;@? zOXL^W*$N&cpLe6#>*V|SgXnO46dXPb!edDLdq|re2b2A%qtY(u4r0R4Jxv!6WU|no zbR_=dyhOS=jt(Ad5)r;c_8%Qi=bQ5nIw-rV5xlxSk*%AT?P}b#n>1y4jCWbW;w<~K zmjC%WY0a*z{ZaI!Yr{K#tf@x(<6ysw;SKpjpCL;)OwXMIX(jEVAPm4YK-Wp!Ld-NmViS=)t6kOg{>&l@GUZPs6i;s=b2$xs^QohR1XrpEglKJ zGBW^=+BJSYFe>DzD40a5W>LMetiYHAA=N%+k`|wu18a4wVW5Vg)oSO~uU>7`)@$p;8QMWA|A6=hjepQD97M-K z=l*mp_Jnp2-Dq@!|FF*7sVZ})&X_xO|Nh6(7Wh(4aHYndZxeSaB5qb=M%}D7{B{^U zKJJ3GpzcV2xP12f<q{B=)A|5z3r-^i-IYUf3a1Do!W)x)w+rksZ z5s?)I6C}urW{IpkLERu=R*^N}P?}6ujmZia!xAAh9l(b=t_A60H#Ul*qO1b08kN-! zO+i*w|9y_D&Tut}tSG_N$_%_lkj1f^{c$%D*2;R>jW8A#0kF_1^RkzUr>9WrL_8-9 zMd^$>xllYV~(&wf0qrJ9wvd{_lT8;twvo^TXKOn92Xv}6aXOh~CQu_uE2h3yy)Vg66i}QTO1!YVY-3kUH zws8>R0(=+L_D-@os1seW^f1vuRdZ%mWkILZT+9qh6x8B^Mhwx($(D@@iY8ppY1Xpo z%(7{46QIUI)sdMZs_Iyq6)YRv-x;D26*N#q8?5SF&>0hST3JvqUKG(;PEcaiaESQG zBT+Ok!6yv;j0u{#S*SXgIBM3+nT^eiiKE{m6Hmd!)jk0ecZHa`dh~C^)UEyZU1I9i zzyBK9%0ChTiGV~vA|Mfv2uK7Z0uq6zhd?3zo-3U?r zG9Lg^%|tw8KEU#1j0jr$rG{62jHuMVv=xE<^v?rzcL@7LZW9=<^v?L-;A|Dh|T4p^{YsPsum%i zGkh{1pnBZ<;;?rfo}YbmllcIxG&VmAjm!s#(}Q4zxfN#$(G;iWC?DY5-@W!n_1X)S z;y`&osIfG3N(O`ycAzg_K0Uakizwq1GR8NjU|S zMO;8>cwZdEmycN%si8>Ba*&OiTf`8xOuUpdN{p4m%Ys*FXjd+HwN^X-4?m0(K4kpA zT^385NgT+>(jp;oARkQooJYyZ_?tv-JGO{}=r4iMhst|KHF7brRPg`vU}J3Z%!FAu3DP?ad=316XktyChX4Pb^#5mhHCC~VevbVA zKX``zf9d|0?*C6uo+;h`3+Xi_9biJR!T zq7W!o;u4c|fP}O$b%#khK+3!;=>P>PSmt6+Sh2XveZ}1~J1R?r3rj*N2-ti?uCBnM}e0OZkQDV*{ z9bj5#q_|XV{_N8MHjiFCsMju@&i&8h0I-Y$ki<}3lqZIgaR9(!Rjd?shB$zP4veR& z1}AdSuqXwRz)IYKVU~+#Q64LmE)J=Py;=oXaq8$w6J5oag_wkJBo#hF);+TcI zodS~<_r^>9KT1g|`TrOZTq#MC8byp z6IMDb_$$u;7l|n=5mF|ir_m>?mKgH?n?G&dtTkS(t#f|abxy&%&Y4BmF(cQ#0IXl8 zX{hU*fbasN6c8OUFVFb?fKCMoe#Cn!N(7e=SNZJ_;Kehjme9qcZ2;$(fG-O=-Lp7l;=lJ z-pU<3opg5R-;ep2#iQ0Pa7K!!aPsDPdh)y|#~@~>_vAQokB)*TT%@NUz_}(7;LRcw z+mH7531m;P_w#EE+baF%F)AOfa}D@cuXb$n6vv)F<+0}~%CH9KJjO`n4V~76YwubQB$i(Y080zf+~j z7LW^*qvJBCul`eAmN{LqpJdRp2d3@mzKSguik`YAR5*2!-yfJm2YFf_TgB=jr|<|r zoieA@q+aU6kY!FY#XES}3t8rLSy5mhcp5^TQ>dia>-T(PsP}x=v4@~CLu?McUayCs zu1GF^;tZS!&zjbx+I20}CmGiyHO#k!w*TvHz#uGP2tK6YKWiwzLyB^nyOZ4ER> zcl)m4Kn1g$UY_DEb_NxGK4?v<0kc%GWtmeNTrT69HVILUEOQFQ9|whE_RlD;NykH| zuLOnuhDOhX$B=>HJ6P-c*1*(yc&HEHf5Fo67%QUZKeMzZ)u35!>ttM0Ng#kMbIMmo z@s?!i%QB})c;PdmHR)lb!drjO@AW;^H!LuLt^?(s9S>>(xwc`L-mqZ!KDV?c)vk8A zEt6$VGxTVQ%F4K=FL+$j`Tx0kv9YwwDJe#3u-d1zmZ?E&nHsc~sX=R*8nl+FL2H>B zw3ewsYnd7$JnoHk723)Af1hP#Q(6D-A(WT~J>>x= zvi@IJ*8j^#T*~@?JSIqPB?1xwiGV~vA|Mfv2uK8;Uj!KcUmAbU*EmQ`>pu!&P#MBI(PtSACT|yC9?nMa5~?df6zhMU2ToHR{Yn=X8s^L93KUT z4?!j1t>(k4;NuZRE%-Z~X5I$Bo*0k(ITufa+@@ym&zsHf}x#eJZ zSOiHw*v`2N;_ho~e62Xguti}8oWDSWRKig)XV@?e765I*mf3&7Y?UP!qeFYxI z->KE3e<2U$ji3Irz^<6*`uqIF|FiXfy8ceq|5m#GcPz(n(DW(t|J!W+KP|5R!LQaP z>?sj@3xMcb0Fw+JwJ+>g)cwX!NrB?ggOMr)~M zOw^fMM$Ur36{V=o(lEwvcr;ZFM8*Dm7{(vv4I?jl!H4@Zvx~pWB}>ggY_U;dvEx!4 zv6QzV&HN!)@-w}rD;R7my(=eg?!;j=D%)!?(e2k_j*D_01iAiCSwQ6ae;PgRXx8O; z1>2#aa=M<`!*tEff(z*m@G8VK5tm3S*n!1&@)-yh$QrwoUt^1Fca?U*mx|(^ri%wM zS@`Nl{7J6=AsmaZI}krBf0(;--d8Hs=C%VdvQ9s{y*s@gmd3Mp&Ll_H65#u=Rhs{!Z5awy^%U1Jlu_;ZyMc|39TA@_qmS From 42de5941b94038b59de04309ae5a35abd5f75bc9 Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 13:28:14 +0300 Subject: [PATCH 03/12] Update UserDto.java 2 --- gateway/src/main/java/ru/practicum/shareit/user/UserDto.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/src/main/java/ru/practicum/shareit/user/UserDto.java b/gateway/src/main/java/ru/practicum/shareit/user/UserDto.java index 5288e6a..2afb7d8 100644 --- a/gateway/src/main/java/ru/practicum/shareit/user/UserDto.java +++ b/gateway/src/main/java/ru/practicum/shareit/user/UserDto.java @@ -11,7 +11,7 @@ @AllArgsConstructor @NoArgsConstructor public class UserDto { - private Long id; + @NotNull private String name; @Email From d9ea6d35c1155835fc30a335cd7a310483242485 Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 13:50:17 +0300 Subject: [PATCH 04/12] testagain 3 --- gateway/pom.xml | 5 +++++ gateway/src/main/java/ru/practicum/shareit/user/UserDto.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gateway/pom.xml b/gateway/pom.xml index ce8b4aa..491178e 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -29,6 +29,11 @@ spring-boot-starter-actuator + + org.hibernate.validator + hibernate-validator + + org.apache.httpcomponents httpclient diff --git a/gateway/src/main/java/ru/practicum/shareit/user/UserDto.java b/gateway/src/main/java/ru/practicum/shareit/user/UserDto.java index 2afb7d8..5288e6a 100644 --- a/gateway/src/main/java/ru/practicum/shareit/user/UserDto.java +++ b/gateway/src/main/java/ru/practicum/shareit/user/UserDto.java @@ -11,7 +11,7 @@ @AllArgsConstructor @NoArgsConstructor public class UserDto { - + private Long id; @NotNull private String name; @Email From b9e20dd96b371abf219434296c9bb2705c3ecc1e Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 13:55:55 +0300 Subject: [PATCH 05/12] Update docker-compose.yml timezone --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 2807e14..9b81721 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,7 @@ services: - server environment: - SHAREIT_SERVER_URL=http://server:9090 + - TZ=Europe/Moscow server: build: server @@ -26,6 +27,7 @@ services: - SPRING_DATASOURCE_PASSWORD=password - DB_HOST=db - DB_PORT=6541 + - TZ=Europe/Moscow db: image: postgres:13.7-alpine From 205d55166dfd04dd774461adf80514786030fac1 Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 14:49:36 +0300 Subject: [PATCH 06/12] Update application.properties 4 --- .../src/main/resources/application.properties | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index b30fa80..c7f794a 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -5,18 +5,18 @@ spring.jpa.hibernate.dialect=org.hibernate.dialect.PostgresSQLDialect spring.jpa.hibernate.show_sql=true spring.sql.init.mode=always -#spring.datasource.driver-class-name=org.postgresql.Driver -#spring.datasource.url=jdbc:postgresql://localhost:5432/postgres -#spring.datasource.username=postgres -#spring.datasource.password=7979 +spring.datasource.driverClassName=org.postgresql.Driver +spring.datasource.url=jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME} +spring.datasource.username=${POSTGRES_USER} +spring.datasource.password=${POSTGRES_PASSWORD} logging.level.org.springframework.orm.jpa=INFO logging.level.org.springframework.transaction=INFO logging.level.org.springframework.transaction.interceptor=TRACE logging.level.org.springframework.orm.jpa.JpaTransactionManager=DEBUG -spring.datasource.url=jdbc:h2:file:./db/filmorate;AUTO_SERVER=TRUE -spring.datasource.driverClassName=org.h2.Driver -spring.datasource.username=sa -spring.datasource.password=password -spring.datasource.hikari.maximum-pool-size=500 \ No newline at end of file +#spring.datasource.url=jdbc:h2:file:./db/filmorate;AUTO_SERVER=TRUE +#spring.datasource.driverClassName=org.h2.Driver +#spring.datasource.username=sa +#spring.datasource.password=password +#spring.datasource.hikari.maximum-pool-size=500 \ No newline at end of file From 1a7b313cc46bafd8415782a9b8d84c0557bcf7ab Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 14:55:42 +0300 Subject: [PATCH 07/12] Update UserController.java --- .../src/main/java/ru/practicum/shareit/user/UserController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/gateway/src/main/java/ru/practicum/shareit/user/UserController.java b/gateway/src/main/java/ru/practicum/shareit/user/UserController.java index 37a147a..d51e6fc 100644 --- a/gateway/src/main/java/ru/practicum/shareit/user/UserController.java +++ b/gateway/src/main/java/ru/practicum/shareit/user/UserController.java @@ -44,7 +44,6 @@ public ResponseEntity findAllUsers() { public ResponseEntity updateUser(@NotNull(message = NULL_USER_ID_MESSAGE) @Min(MIN_ID_VALUE) @PathVariable Long userId, - @Valid @RequestBody UserDto userDto) { log.info("Updating userId={}, user {}", userId, userDto); return userClient.updateUser(userId, userDto); From 1cdd03b1f12375edf71e26c80a9f03d48b936c28 Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 14:59:39 +0300 Subject: [PATCH 08/12] Update ItemController.java --- .../src/main/java/ru/practicum/shareit/item/ItemController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java b/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java index 0901cdd..be28a03 100644 --- a/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java +++ b/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java @@ -46,7 +46,7 @@ public ResponseEntity createComment(@Valid } @PatchMapping("/{itemId}") - public ResponseEntity updateItem(@Valid + public ResponseEntity updateItem( @RequestBody ItemDto itemDto, @NotNull(message = NULL_ITEM_ID_MESSAGE) @Min(MIN_VALUE) From c2c91e6c61adce157e1c0d25736b9f88091b6111 Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 15:05:36 +0300 Subject: [PATCH 09/12] Update docker-compose.yml --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9b81721..2807e14 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,6 @@ services: - server environment: - SHAREIT_SERVER_URL=http://server:9090 - - TZ=Europe/Moscow server: build: server @@ -27,7 +26,6 @@ services: - SPRING_DATASOURCE_PASSWORD=password - DB_HOST=db - DB_PORT=6541 - - TZ=Europe/Moscow db: image: postgres:13.7-alpine From f1072e9d12edd1097f3d7e5dde4ff7900285bbdf Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 15:31:09 +0300 Subject: [PATCH 10/12] BaseClient updated 6 --- .../shareit/booking/dto/BookingInItemDto.java | 3 ++ .../booking/dto/BookingIncomingDto.java | 6 ++-- .../practicum/shareit/client/BaseClient.java | 28 +++++++++++++------ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingInItemDto.java b/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingInItemDto.java index 58a3c5d..7e80fb5 100644 --- a/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingInItemDto.java +++ b/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingInItemDto.java @@ -5,6 +5,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; +import javax.validation.constraints.FutureOrPresent; import java.time.LocalDateTime; @Getter @@ -14,6 +15,8 @@ public class BookingInItemDto { private Long id; private Long bookerId; + @FutureOrPresent private LocalDateTime start; + @FutureOrPresent private LocalDateTime end; } diff --git a/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingIncomingDto.java b/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingIncomingDto.java index 0488a97..d76ca07 100644 --- a/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingIncomingDto.java +++ b/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingIncomingDto.java @@ -1,6 +1,9 @@ package ru.practicum.shareit.booking.dto; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import javax.validation.constraints.Future; import javax.validation.constraints.FutureOrPresent; @@ -9,7 +12,6 @@ @Getter @Setter -@Builder @AllArgsConstructor @NoArgsConstructor public class BookingIncomingDto { diff --git a/gateway/src/main/java/ru/practicum/shareit/client/BaseClient.java b/gateway/src/main/java/ru/practicum/shareit/client/BaseClient.java index 1a2d33a..eb0375b 100644 --- a/gateway/src/main/java/ru/practicum/shareit/client/BaseClient.java +++ b/gateway/src/main/java/ru/practicum/shareit/client/BaseClient.java @@ -32,38 +32,49 @@ protected ResponseEntity get(String path, Long userId, @Nullable Map ResponseEntity post(String path, T body) { - return post(path, null, null, body); + return post(path, null, null, + body); } protected ResponseEntity post(String path, long userId, T body) { return post(path, userId, null, body); } - protected ResponseEntity post(String path, Long userId, @Nullable Map parameters, T body) { + protected ResponseEntity post(String path, Long userId, @Nullable Map parameters, + T body) { return makeAndSendRequest(HttpMethod.POST, path, userId, parameters, body); } protected ResponseEntity put(String path, long userId, T body) { - return put(path, userId, null, body); + return put(path, userId, + null, body); } - protected ResponseEntity put(String path, long userId, @Nullable Map parameters, T body) { + protected ResponseEntity put(String path, long userId, @Nullable Map parameters, + T body) { return makeAndSendRequest(HttpMethod.PUT, path, userId, parameters, body); } + protected ResponseEntity patch(String path, long userId, @Nullable Map parameters) { + return patch(path, userId, parameters, null); + } + protected ResponseEntity patch(String path, T body) { - return patch(path, null, null, body); + return patch(path, null, null, + body); } protected ResponseEntity patch(String path, long userId) { - return patch(path, userId, null, null); + return patch(path, userId, null, + null); } protected ResponseEntity patch(String path, long userId, T body) { return patch(path, userId, null, body); } - protected ResponseEntity patch(String path, Long userId, @Nullable Map parameters, T body) { + protected ResponseEntity patch(String path, Long userId, @Nullable Map parameters, + T body) { return makeAndSendRequest(HttpMethod.PATCH, path, userId, parameters, body); } @@ -79,7 +90,8 @@ protected ResponseEntity delete(String path, Long userId, @Nullable Map< return makeAndSendRequest(HttpMethod.DELETE, path, userId, parameters, null); } - private ResponseEntity makeAndSendRequest(HttpMethod method, String path, Long userId, @Nullable Map parameters, @Nullable T body) { + private ResponseEntity makeAndSendRequest(HttpMethod method, String path, Long userId, + @Nullable Map parameters, @Nullable T body) { HttpEntity requestEntity = new HttpEntity<>(body, defaultHeaders(userId)); ResponseEntity shareitServerResponse; From eba6615e08cb2568e7f663325573436ed371f13a Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 20:38:22 +0300 Subject: [PATCH 11/12] Update pom.xml --- gateway/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gateway/pom.xml b/gateway/pom.xml index 491178e..ce8b4aa 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -29,11 +29,6 @@ spring-boot-starter-actuator - - org.hibernate.validator - hibernate-validator - - org.apache.httpcomponents httpclient From 2b457d8125678fb9222dcd45c197be9258eb9add Mon Sep 17 00:00:00 2001 From: Ilusha92 Date: Tue, 2 May 2023 20:52:44 +0300 Subject: [PATCH 12/12] uniformity --- .../shareit/booking/BookingController.java | 32 ++++------ .../shareit/item/ItemController.java | 61 ++++++++----------- .../request/ItemRequestController.java | 21 +++---- .../shareit/user/UserController.java | 15 ++--- 4 files changed, 54 insertions(+), 75 deletions(-) diff --git a/gateway/src/main/java/ru/practicum/shareit/booking/BookingController.java b/gateway/src/main/java/ru/practicum/shareit/booking/BookingController.java index 137edcc..4226c54 100644 --- a/gateway/src/main/java/ru/practicum/shareit/booking/BookingController.java +++ b/gateway/src/main/java/ru/practicum/shareit/booking/BookingController.java @@ -18,17 +18,11 @@ @RequestMapping(path = "/bookings") public class BookingController { - public static final int MIN_VALUE = 0; - public static final String DEFAULT_FROM_VALUE = "0"; - public static final String DEFAULT_SIZE_VALUE = "20"; - public static final String DEFAULT_STATE_VALUE = "ALL"; - public static final String USER_ID_HEADER = "X-Sharer-User-Id"; - private final BookingClient bookingClient; @PostMapping public ResponseEntity createBooking(@RequestBody @Valid BookingIncomingDto dto, - @RequestHeader(USER_ID_HEADER) Long userId) { + @RequestHeader("X-Sharer-User-Id") Long userId) { log.info("Creating booking {}, userId={}", dto, userId); return bookingClient.createBooking(dto, userId); } @@ -36,35 +30,35 @@ public ResponseEntity createBooking(@RequestBody @Valid BookingIncomingD @PatchMapping("/{bookingId}") public ResponseEntity patchBooking(@PathVariable Long bookingId, @RequestParam Boolean approved, - @RequestHeader(USER_ID_HEADER) Long userId) { + @RequestHeader("X-Sharer-User-Id") Long userId) { log.info("Path booking {}, approved={}. userId={}", bookingId, approved, userId); return bookingClient.patchBooking(bookingId, approved, userId); } @GetMapping("/{bookingId}") public ResponseEntity findById(@PathVariable Long bookingId, - @RequestHeader(USER_ID_HEADER) Long userId) { + @RequestHeader("X-Sharer-User-Id") Long userId) { log.info("Get booking {}, userId={}", bookingId, userId); return bookingClient.findById(bookingId, userId); } @GetMapping - public ResponseEntity findAllBookings(@RequestParam(defaultValue = DEFAULT_STATE_VALUE) String state, - @RequestHeader(USER_ID_HEADER) Long userId, - @RequestParam(defaultValue = DEFAULT_FROM_VALUE) - @Min(MIN_VALUE) int from, - @RequestParam(defaultValue = DEFAULT_SIZE_VALUE) + public ResponseEntity findAllBookings(@RequestParam(defaultValue = "ALL") String state, + @RequestHeader("X-Sharer-User-Id") Long userId, + @RequestParam(defaultValue = "0") + @Min(0) int from, + @RequestParam(defaultValue = "20") @PositiveOrZero int size) { log.info("Get booking with state {}, userId={}, from={}, size={}", state, userId, from, size); return bookingClient.findAllByBooker(state, userId, from, size); } @GetMapping("/owner") - public ResponseEntity findAllByItemOwner(@RequestParam(defaultValue = DEFAULT_STATE_VALUE) String state, - @RequestHeader(USER_ID_HEADER) Long userId, - @RequestParam(defaultValue = DEFAULT_FROM_VALUE) - @Min(MIN_VALUE) int from, - @RequestParam(defaultValue = DEFAULT_SIZE_VALUE) + public ResponseEntity findAllByItemOwner(@RequestParam(defaultValue = "ALL") String state, + @RequestHeader("X-Sharer-User-Id") Long userId, + @RequestParam(defaultValue = "0") + @Min(0) int from, + @RequestParam(defaultValue = "20") @PositiveOrZero int size) { log.info("Get bookings owner with state{}, userId={}, from={}, size={}", state, userId, from, size); return bookingClient.findAllByItemOwner(state, userId, from, size); diff --git a/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java b/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java index be28a03..4d9811a 100644 --- a/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java +++ b/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java @@ -15,73 +15,66 @@ @RequestMapping(path = "/items") public class ItemController { - public static final int MIN_VALUE = 1; - public static final String DEFAULT_FROM_VALUE = "0"; - public static final String DEFAULT_SIZE_VALUE = "20"; - public static final String USER_ID_HEADER = "X-Sharer-User-Id"; - public static final String NULL_ITEM_ID_MESSAGE = "itemID is null"; - public static final String NULL_USER_ID_MESSAGE = "userID is null"; - private final ItemClient itemClient; @PostMapping public ResponseEntity createItem(@Valid @RequestBody ItemDto itemDto, - @NotNull(message = (NULL_ITEM_ID_MESSAGE)) - @Min(MIN_VALUE) - @RequestHeader(USER_ID_HEADER) Long userId) { + @NotNull(message = ("itemID is null")) + @Min(1) + @RequestHeader("X-Sharer-User-Id") Long userId) { return itemClient.createItem(itemDto, userId); } @PostMapping("/{itemId}/comment") public ResponseEntity createComment(@Valid @RequestBody CreateCommentDto commentDto, - @NotNull(message = (NULL_ITEM_ID_MESSAGE)) - @Min(MIN_VALUE) + @NotNull(message = ("itemID is null")) + @Min(1) @PathVariable Long itemId, - @NotNull(message = (NULL_USER_ID_MESSAGE)) - @Min(MIN_VALUE) - @RequestHeader(USER_ID_HEADER) Long userId) { + @NotNull(message = ("userID is null")) + @Min(1) + @RequestHeader("X-Sharer-User-Id") Long userId) { return itemClient.createComment(commentDto, itemId, userId); } @PatchMapping("/{itemId}") public ResponseEntity updateItem( @RequestBody ItemDto itemDto, - @NotNull(message = NULL_ITEM_ID_MESSAGE) - @Min(MIN_VALUE) + @NotNull(message = "itemID is null") + @Min(1) @PathVariable Long itemId, - @NotNull(message = NULL_USER_ID_MESSAGE) - @Min(MIN_VALUE) - @RequestHeader(USER_ID_HEADER) Long userId) { + @NotNull(message = "userID is null") + @Min(1) + @RequestHeader("X-Sharer-User-Id") Long userId) { return itemClient.updateItem(itemDto, itemId, userId); } @GetMapping("/{itemId}") - public ResponseEntity findItemById(@NotNull(message = NULL_ITEM_ID_MESSAGE) - @Min(MIN_VALUE) + public ResponseEntity findItemById(@NotNull(message = "itemID is null") + @Min(1) @PathVariable Long itemId, - @RequestHeader(USER_ID_HEADER) Long userId) { + @RequestHeader("X-Sharer-User-Id") Long userId) { return itemClient.findItemById(itemId, userId); } @GetMapping - public ResponseEntity findAllItems(@NotNull(message = NULL_USER_ID_MESSAGE) - @RequestHeader(USER_ID_HEADER) Long userId, - @RequestParam(defaultValue = DEFAULT_FROM_VALUE) - @Min(MIN_VALUE) int from, - @RequestParam(defaultValue = DEFAULT_SIZE_VALUE) - @Min(MIN_VALUE) int size) { + public ResponseEntity findAllItems(@NotNull(message = "userID is null") + @RequestHeader("X-Sharer-User-Id") Long userId, + @RequestParam(defaultValue = "0") + @Min(1) int from, + @RequestParam(defaultValue = "20") + @Min(1) int size) { return itemClient.findAllItems(userId, from, size); } @GetMapping("/search") public ResponseEntity findItemsByRequest(@RequestParam String text, - @RequestHeader(USER_ID_HEADER) Long userId, - @RequestParam(defaultValue = DEFAULT_FROM_VALUE) - @Min(MIN_VALUE) int from, - @RequestParam(defaultValue = DEFAULT_SIZE_VALUE) - @Min(MIN_VALUE) int size) { + @RequestHeader("X-Sharer-User-Id") Long userId, + @RequestParam(defaultValue = "0") + @Min(1) int from, + @RequestParam(defaultValue = "20") + @Min(1) int size) { return itemClient.findItemsByRequest(text, userId, from, size); } } \ No newline at end of file diff --git a/gateway/src/main/java/ru/practicum/shareit/request/ItemRequestController.java b/gateway/src/main/java/ru/practicum/shareit/request/ItemRequestController.java index 4c89d17..8b69ad0 100644 --- a/gateway/src/main/java/ru/practicum/shareit/request/ItemRequestController.java +++ b/gateway/src/main/java/ru/practicum/shareit/request/ItemRequestController.java @@ -15,37 +15,32 @@ @RequestMapping(path = "/requests") public class ItemRequestController { - public static final int MIN_VALUE = 0; - public static final String DEFAULT_FROM_VALUE = "0"; - public static final String DEFAULT_SIZE_VALUE = "20"; - public static final String USER_ID_HEADER = "X-Sharer-User-Id"; - private final RequestClient requestClient; @PostMapping public ResponseEntity createRequest(@Valid @RequestBody ItemRequestIncomingDto incomingItemRequestDto, - @RequestHeader(USER_ID_HEADER) Long userId) { + @RequestHeader("X-Sharer-User-Id") Long userId) { return requestClient.createRequest(incomingItemRequestDto, userId); } @GetMapping - public ResponseEntity findAllByUserId(@RequestHeader(USER_ID_HEADER) Long userId) { + public ResponseEntity findAllByUserId(@RequestHeader("X-Sharer-User-Id") Long userId) { return requestClient.findAllByUserId(userId); } @GetMapping ("/all") - public ResponseEntity findAll(@RequestParam(defaultValue = DEFAULT_FROM_VALUE) - @Min(MIN_VALUE) int from, - @RequestParam(defaultValue = DEFAULT_SIZE_VALUE) - @Min(MIN_VALUE) int size, - @RequestHeader(USER_ID_HEADER) Long userId) { + public ResponseEntity findAll(@RequestParam(defaultValue = "0") + @Min(0) int from, + @RequestParam(defaultValue = "20") + @Min(0) int size, + @RequestHeader("X-Sharer-User-Id") Long userId) { return requestClient.findAll(from, size, userId); } @GetMapping("/{requestId}") public ResponseEntity findById(@PathVariable Long requestId, - @RequestHeader(USER_ID_HEADER) Long userId) { + @RequestHeader("X-Sharer-User-Id") Long userId) { return requestClient.findById(requestId, userId); } } diff --git a/gateway/src/main/java/ru/practicum/shareit/user/UserController.java b/gateway/src/main/java/ru/practicum/shareit/user/UserController.java index d51e6fc..5e91df2 100644 --- a/gateway/src/main/java/ru/practicum/shareit/user/UserController.java +++ b/gateway/src/main/java/ru/practicum/shareit/user/UserController.java @@ -15,9 +15,6 @@ @RequestMapping(path = "/users") public class UserController { - public static final int MIN_ID_VALUE = 1; - public static final String NULL_USER_ID_MESSAGE = "userID is null"; - private final UserClient userClient; @PostMapping @@ -27,8 +24,8 @@ public ResponseEntity createUser(@Valid @RequestBody UserDto userDto) { } @GetMapping("/{userId}") - public ResponseEntity findUserById(@NotNull(message = (NULL_USER_ID_MESSAGE)) - @Min(MIN_ID_VALUE) + public ResponseEntity findUserById(@NotNull(message = ("userID is null")) + @Min(1) @PathVariable Long userId) { log.info("Searching userId={}", userId); return userClient.findUserById(userId); @@ -41,8 +38,8 @@ public ResponseEntity findAllUsers() { } @PatchMapping("/{userId}") - public ResponseEntity updateUser(@NotNull(message = NULL_USER_ID_MESSAGE) - @Min(MIN_ID_VALUE) + public ResponseEntity updateUser(@NotNull(message = "userID is null") + @Min(1) @PathVariable Long userId, @RequestBody UserDto userDto) { log.info("Updating userId={}, user {}", userId, userDto); @@ -50,8 +47,8 @@ public ResponseEntity updateUser(@NotNull(message = NULL_USER_ID_MESSAGE } @DeleteMapping("/{userId}") - public void deleteUserById(@NotNull(message = (NULL_USER_ID_MESSAGE)) - @Min(MIN_ID_VALUE) + public void deleteUserById(@NotNull(message = ("userID is null")) + @Min(1) @PathVariable Long userId) { log.info("Deleting userId={}", userId); userClient.deleteUserById(userId);