<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.activiti.cloud</groupId>
    <artifactId>activiti-cloud-notifications-graphql-dependencies</artifactId>
    <version>9.1.0-alpha.24</version>
    <relativePath>../dependencies</relativePath>
  </parent>

  <artifactId>activiti-cloud-notifications-graphql-gatling-tests</artifactId>
  <name>Activiti Cloud :: Notifications GraphQL Gatling Tests</name>

  <properties>
    <hibernate.version>7.2.7.Final</hibernate.version>
    <gatling.version>3.15.0</gatling.version>
    <gatling-maven-plugin.version>4.21.5</gatling-maven-plugin.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.activiti.cloud</groupId>
      <artifactId>activiti-cloud-services-notifications-graphql-jpa-query</artifactId>
    </dependency>
    <dependency>
      <groupId>org.activiti.cloud</groupId>
      <artifactId>activiti-cloud-services-notifications-graphql-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-graphql</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-webmvc</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
      <groupId>org.activiti.cloud</groupId>
      <artifactId>activiti-cloud-services-query-liquibase</artifactId>
    </dependency>
    <dependency>
      <groupId>org.activiti.cloud</groupId>
      <artifactId>activiti-cloud-services-query-model</artifactId>
    </dependency>
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>io.gatling.highcharts</groupId>
      <artifactId>gatling-charts-highcharts</artifactId>
      <version>${gatling.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-testcontainers</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>1.21.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>postgresql</artifactId>
      <version>1.21.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <jmxPort>9001</jmxPort>
        </configuration>
        <executions>
          <execution>
            <id>pre-integration-test</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>start</goal>
            </goals>
            <configuration>
              <skip>${skipTests}</skip>
              <maxAttempts>120</maxAttempts>
              <mainClass>org.activiti.cloud.notifications.graphql.gatling.tests.TestApplication</mainClass>
              <useTestClasspath>true</useTestClasspath>
              <classesDirectory>${project.build.outputDirectory}</classesDirectory>
              <additionalClasspathElements>
                <classpathElement>${project.build.testOutputDirectory}</classpathElement>
              </additionalClasspathElements>
              <jvmArguments>
                -Xms512m
                -Xmx1024m
              </jvmArguments>
            </configuration>
          </execution>
          <execution>
            <id>post-integration-test</id>
            <phase>post-integration-test</phase>
            <configuration>
              <skip>${skipTests}</skip>
            </configuration>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>io.gatling</groupId>
        <artifactId>gatling-maven-plugin</artifactId>
        <version>${gatling-maven-plugin.version}</version>
        <executions>
          <execution>
            <id>test</id>
            <phase>integration-test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
          <execution>
            <id>verify</id>
            <phase>verify</phase>
            <goals>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <continueOnAssertionFailure>true</continueOnAssertionFailure>
          <failOnError>false</failOnError>
          <skip>${skipTests}</skip>
          <runMultipleSimulations>true</runMultipleSimulations>
          <jvmArgs>
            <arg>-XX:ActiveProcessorCount=2</arg>
            <arg>-Djava.net.preferIPv6Addresses=false</arg>
          </jvmArgs>
          <resultsFolder>${project.build.directory}/gatling</resultsFolder>
        </configuration>
      </plugin>
      <!-- 3. Use Failsafe to verify results AFTER app shutdown -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>3.5.5</version>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
