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..4226c54 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/booking/BookingController.java @@ -0,0 +1,66 @@ +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 { + + private final BookingClient bookingClient; + + @PostMapping + public ResponseEntity createBooking(@RequestBody @Valid BookingIncomingDto dto, + @RequestHeader("X-Sharer-User-Id") 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("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("X-Sharer-User-Id") Long userId) { + log.info("Get booking {}, userId={}", bookingId, userId); + return bookingClient.findById(bookingId, userId); + } + + @GetMapping + 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 = "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); + } +} \ 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..7e80fb5 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingInItemDto.java @@ -0,0 +1,22 @@ +package ru.practicum.shareit.booking.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import javax.validation.constraints.FutureOrPresent; +import java.time.LocalDateTime; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +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 new file mode 100644 index 0000000..d76ca07 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/booking/dto/BookingIncomingDto.java @@ -0,0 +1,28 @@ +package ru.practicum.shareit.booking.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import javax.validation.constraints.Future; +import javax.validation.constraints.FutureOrPresent; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@Getter +@Setter +@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..eb0375b --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/client/BaseClient.java @@ -0,0 +1,133 @@ +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, long userId, @Nullable Map parameters) { + return patch(path, userId, parameters, null); + } + + 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..4d9811a --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/item/ItemController.java @@ -0,0 +1,80 @@ +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 { + + private final ItemClient itemClient; + + @PostMapping + public ResponseEntity createItem(@Valid + @RequestBody ItemDto itemDto, + @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 = ("itemID is null")) + @Min(1) + @PathVariable Long itemId, + @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 = "itemID is null") + @Min(1) + @PathVariable Long itemId, + @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 = "itemID is null") + @Min(1) + @PathVariable Long itemId, + @RequestHeader("X-Sharer-User-Id") Long userId) { + return itemClient.findItemById(itemId, userId); + } + + @GetMapping + 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("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/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..8b69ad0 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/request/ItemRequestController.java @@ -0,0 +1,46 @@ +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 { + + private final RequestClient requestClient; + + @PostMapping + public ResponseEntity createRequest(@Valid + @RequestBody ItemRequestIncomingDto incomingItemRequestDto, + @RequestHeader("X-Sharer-User-Id") Long userId) { + return requestClient.createRequest(incomingItemRequestDto, userId); + } + + @GetMapping + public ResponseEntity findAllByUserId(@RequestHeader("X-Sharer-User-Id") Long userId) { + return requestClient.findAllByUserId(userId); + } + + @GetMapping ("/all") + 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("X-Sharer-User-Id") 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..5e91df2 --- /dev/null +++ b/gateway/src/main/java/ru/practicum/shareit/user/UserController.java @@ -0,0 +1,56 @@ +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 { + + 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 = ("userID is null")) + @Min(1) + @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 = "userID is null") + @Min(1) + @PathVariable Long userId, + @RequestBody UserDto userDto) { + log.info("Updating userId={}, user {}", userId, userDto); + return userClient.updateUser(userId, userDto); + } + + @DeleteMapping("/{userId}") + public void deleteUserById(@NotNull(message = ("userID is null")) + @Min(1) + @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/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/server/src/main/resources/application.properties b/server/src/main/resources/application.properties new file mode 100644 index 0000000..c7f794a --- /dev/null +++ b/server/src/main/resources/application.properties @@ -0,0 +1,22 @@ +server.port=9090 + +spring.jpa.hibernate.ddl-auto=none +spring.jpa.hibernate.dialect=org.hibernate.dialect.PostgresSQLDialect +spring.jpa.hibernate.show_sql=true +spring.sql.init.mode=always + +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 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 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index ddeb46e..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1,20 +0,0 @@ -spring.jpa.hibernate.ddl-auto=none -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 - -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