Refactor petstore tests and refresh build setup

This commit is contained in:
2026-02-15 14:02:49 +03:00
parent 32f7be7cf0
commit b97c369f46
16 changed files with 655 additions and 316 deletions

120
pom.xml
View File

@@ -1,37 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- Основная информация о проекте -->
<groupId>ru.otus</groupId>
<artifactId>petstore</artifactId>
<artifactId>hw3</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>petstore</name>
<name>hw3</name>
<!-- Глобальные свойства проекта -->
<properties>
<!-- Используем Java 24 -->
<maven.compiler.source>24</maven.compiler.source>
<maven.compiler.target>24</maven.compiler.target>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Версии зависимостей -->
<restassured.version>4.5.1</restassured.version>
<junit.jupiter.version>5.9.1</junit.jupiter.version>
<base.uri>https://petstore.swagger.io</base.uri>
<base.path>/v2</base.path>
<restassured.version>6.0.0</restassured.version>
<junit.jupiter.version>6.0.2</junit.jupiter.version>
<jackson.version>2.21.0</jackson.version>
<maven.compiler.version>3.15.0</maven.compiler.version>
<surefire.version>3.5.4</surefire.version>
<checkstyle.plugin.version>3.6.0</checkstyle.plugin.version>
<spotbugs.plugin.version>4.9.8.2</spotbugs.plugin.version>
<spotbugs.version>4.9.8</spotbugs.version>
</properties>
<!-- Зависимости проекта -->
<dependencies>
<!-- Rest-assured для работы с REST API с исключением транзитивой зависимости commons-codec -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${restassured.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
@@ -40,56 +41,111 @@
</exclusions>
</dependency>
<!-- Явное подключение обновлённой, безопасной версии commons-codec -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
<scope>test</scope>
<version>1.21.0</version>
</dependency>
<!-- JSON-парсинг через Rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>${restassured.version}</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>${restassured.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- JUnit Jupiter API для написания автотестов (включает ExtensionContext и TestWatcher) -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<!-- JUnit Jupiter Engine для выполнения тестов -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- Конфигурация сборки проекта -->
<build>
<plugins>
<!-- Maven Compiler Plugin для компиляции проекта с поддержкой Java 24 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>${maven.compiler.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<release>${java.version}</release>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<!-- Maven Surefire Plugin для запуска тестов -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>${surefire.version}</version>
<configuration>
<useModulePath>false</useModulePath>
<systemPropertyVariables>
<base.uri>${base.uri}</base.uri>
<base.path>${base.path}</base.path>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<executions>
<execution>
<id>checkstyle-validation</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs.plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>${spotbugs.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</build>