<?xml version="1.0" encoding="UTF-8"?>
<!--


    Copyright 2021-2025 gematik GmbH

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

    *******

    For additional notes and disclaimer from gematik and in case of changes by gematik find details in the "Readme" file.

-->
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>de.gematik.test</groupId>
    <artifactId>tiger</artifactId>
    <version>4.4.5</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <artifactId>tiger-testenv-mgr</artifactId>
  <name>${project.artifactId}</name>
  <description>tiger-testenv-mgr modul of the tiger test platform.</description>
  <properties>
    <frontend.work.dir>${project.basedir}/src/frontend</frontend.work.dir>
    <frontend.build.command>run build</frontend.build.command>
    <frontend.staleness.excludes>node_modules/**,node/**,package-lock.json,dist/**,**/*.tsbuildinfo</frontend.staleness.excludes>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.konghq</groupId>
      <artifactId>unirest-java-core</artifactId>
    </dependency>
    <dependency>
      <groupId>de.gematik.test</groupId>
      <artifactId>tiger-httpbin</artifactId>
    </dependency>
    <dependency>
      <groupId>de.gematik.test</groupId>
      <artifactId>tiger-proxy</artifactId>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>testcontainers</artifactId>
    </dependency>
    <dependency>
      <groupId>de.gematik.test</groupId>
      <artifactId>tiger-topology-visualizer</artifactId>
    </dependency>
    <dependency>
      <groupId>de.gematik.test</groupId>
      <artifactId>tiger-proxy-scrollable-webui</artifactId>
    </dependency>
    <dependency>
      <groupId>io.cucumber</groupId>
      <artifactId>cucumber-core</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.swagger.parser.v3</groupId>
      <artifactId>swagger-parser</artifactId>
    </dependency>
    <dependency>
      <groupId>org.awaitility</groupId>
      <artifactId>awaitility</artifactId>
    </dependency>

    <!-- for TigerExtension and TigerTest annotation which are in src so scope is not only test -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
    </dependency>
    <dependency>
      <groupId>org.junit.platform</groupId>
      <artifactId>junit-platform-launcher</artifactId>
    </dependency>
    <dependency>
      <groupId>org.mapstruct</groupId>
      <artifactId>mapstruct</artifactId>
    </dependency>
    <dependency>
      <groupId>org.openapitools</groupId>
      <artifactId>jackson-databind-nullable</artifactId>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok-mapstruct-binding</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-configuration-processor</artifactId>
      <optional>true</optional>
    </dependency>
    <!-- spring boot -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <!-- bridges JCL (org.apache.commons.logging) to SLF4J;
         required because spring-jcl was removed in Spring Framework 7.x
         and commons-logging is excluded (provided) in the BOM -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.konghq</groupId>
      <artifactId>unirest-modules-jackson</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.networknt</groupId>
      <artifactId>json-schema-validator</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.tngtech.archunit</groupId>
      <artifactId>archunit-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>de.gematik.test</groupId>
      <artifactId>tiger-httpbin</artifactId>
      <classifier>jar-with-dependencies</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>de.gematik.test</groupId>
      <artifactId>tiger-test-utils</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.cucumber</groupId>
      <artifactId>cucumber-junit-platform-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.jcip</groupId>
      <artifactId>jcip-annotations</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.serenity-bdd</groupId>
      <artifactId>serenity-cucumber</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.glassfish.tyrus.bundles</groupId>
      <artifactId>tyrus-standalone-client</artifactId>
      <version>2.2.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains</groupId>
      <artifactId>annotations</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.platform</groupId>
      <artifactId>junit-platform-suite</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- test -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.wiremock</groupId>
      <artifactId>wiremock-standalone</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>uk.org.webcompere</groupId>
      <artifactId>system-stubs-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>uk.org.webcompere</groupId>
      <artifactId>system-stubs-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.11.0</version>
        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>de.gematik.test</groupId>
              <artifactId>tiger-httpbin</artifactId>
              <version>${project.version}</version>
              <classifier>jar-with-dependencies</classifier>
              <overWrite>true</overWrite>
              <destFileName>tiger-httpbin.jar</destFileName>
            </artifactItem>
          </artifactItems>
          <outputDirectory>${project.build.directory}</outputDirectory>
        </configuration>
        <executions>
          <execution>
            <id>copy</id>
            <goals>
              <goal>copy</goal>
            </goals>
            <phase>pre-integration-test</phase>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>${version.maven-resources-plugin}</version>
        <executions>
          <execution>
            <id>Copy Vue frontend into Spring Boot target static folder</id>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <phase>process-resources</phase>
            <configuration>
              <outputDirectory>${project.build.directory}/classes/static</outputDirectory>
              <resources>
                <resource>
                  <directory>src/frontend/dist</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>${version.spring-boot}</version>
        <configuration>
          <mainClass>de.gematik.test.tiger.testenvmgr.TigerTestEnvMgrApplication</mainClass>
          <skip>false</skip>
          <classifier>springboot</classifier>
        </configuration>
        <executions>
          <execution>
            <id>repackage</id>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
          <execution>
            <id>build-info</id>
            <goals>
              <goal>build-info</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${version.maven.surefire}</version>
        <configuration>
          <!-- very pessimistic value for slow environment. Default is 30. Rare errors observed. -->
          <forkedProcessExitTimeoutInSeconds>1000</forkedProcessExitTimeoutInSeconds>
          <!-- A hung test must not hold the nightly for hours: surefire kills the fork and writes a thread dump. -->
          <forkedProcessTimeoutInSeconds>5400</forkedProcessTimeoutInSeconds>
          <forkCount>3</forkCount>
          <threadCount>1</threadCount>
          <reuseForks>true</reuseForks>
          <parallel>suitesAndClasses</parallel>
          <rerunFailingTestsCount>2</rerunFailingTestsCount>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>7.25.0</version>
        <executions>
          <execution>
            <id>generate java code</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <!-- TODO: the most correct way would be to refer the project.basedir, but a bug in the
                                                                      swagger-parser can't handle the 'C:' present in windows paths.
                                                                      Using ${project.baseUri} works in resolving the file, but the generated code creates duplicated
                                                                      classes for $refs even though they refer to the same class
                                                                      The direct path tiger-testenv-mgr should work but requires the generation always to be started from the
                                                                      root project.

                                                                      Follow up on one of these tickets to see if the issue is resolved:
                                                                      https://github.com/swagger-api/swagger-parser/issues/2136
                                                                      https://github.com/swagger-api/swagger-parser/pull/2105

                                                                      -->
              <!--<inputSpec>${project.baseUri}/src/main/resources/tiger-management-api.yaml</inputSpec>-->
              <inputSpec>tiger-testenv-mgr/src/main/resources/tiger-management-api.yaml</inputSpec>
              <generatorName>spring</generatorName>
              <modelNameSuffix>Dto</modelNameSuffix>
              <generateSupportingFiles>false</generateSupportingFiles>
              <configOptions>
                <sourceFolder>src/main/java</sourceFolder>
                <useSpringBoot3>true</useSpringBoot3>
                <interfaceOnly>true</interfaceOnly>
                <apiPackage>de.gematik.test.tiger.testenvmgr.api</apiPackage>
                <modelPackage>de.gematik.test.tiger.testenvmgr.api.model</modelPackage>
                <useBeanValidation>true</useBeanValidation>
                <performBeanValidation>true</performBeanValidation>
                <skipDefaultInterface>true</skipDefaultInterface>
                <openApiNullable>false</openApiNullable>
              </configOptions>
            </configuration>
          </execution>
          <execution>
            <id>generate ascii docs</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <!--<inputSpec>${project.baseUri}/src/main/resources/tiger-management-api.yaml</inputSpec>-->
              <inputSpec>tiger-testenv-mgr/src/main/resources/tiger-management-api.yaml</inputSpec>
              <generatorName>asciidoc</generatorName>
              <output>${project.parent.basedir}/doc/user_manual/rest_api</output>
              <configOptions>
                <headerAttributes>false</headerAttributes>
                <useIntroduction>true</useIntroduction>
                <!-- I don't know why the option is default to false, since examples are not supported by the asciidoc generator.
                                                                                 see https://openapi-generator.tech/docs/generators/asciidoc/#global-feature -->
                <skipExamples>true</skipExamples>
              </configOptions>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.github.victools</groupId>
        <artifactId>jsonschema-maven-plugin</artifactId>
        <version>4.38.0</version>
        <configuration>
          <classNames>
            <className>de.gematik.test.tiger.testenvmgr.config.Configuration</className>
          </classNames>
          <schemaVersion>DRAFT_2020_12</schemaVersion>
          <schemaFileName>{0}.json</schemaFileName>
          <schemaFilePath>target/schemas</schemaFilePath>
          <options>
            <enabled>
              <option>DEFINITIONS_FOR_ALL_OBJECTS</option>
              <option>NULLABLE_FIELDS_BY_DEFAULT</option>
              <option>INLINE_ALL_SCHEMAS</option>
              <option>MAP_VALUES_AS_ADDITIONAL_PROPERTIES</option>
            </enabled>
          </options>
          <modules>
            <module>
              <name>Jackson</name>
              <options>
                <option>FLATTENED_ENUMS_FROM_JSONVALUE</option>
              </options>
            </module>
          </modules>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${version.maven-compiler-plugin}</version>
        <configuration>
          <source>${maven.compiler.source}</source>
          <target>${maven.compiler.target}</target>
          <annotationProcessorPaths>
            <path>
              <groupId>org.mapstruct</groupId>
              <artifactId>mapstruct-processor</artifactId>
              <version>${version.mapstruct}</version>
            </path>
            <path>
              <groupId>org.projectlombok</groupId>
              <artifactId>lombok</artifactId>
              <version>${version.lombok}</version>
            </path>
            <path>
              <groupId>org.projectlombok</groupId>
              <artifactId>lombok-mapstruct-binding</artifactId>
              <version>${version.lombok-mapstruct-binding}</version>
            </path>
          </annotationProcessorPaths>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
