<?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>xyz.tcheeric</groupId>
        <artifactId>wallet-plugin</artifactId>
        <version>1.2.3</version>
    </parent>

    <artifactId>wallet-e2e</artifactId>
    <version>1.2.3</version>
    <packaging>jar</packaging>

    <name>Wallet E2E Tests</name>
    <description>End-to-end test automation for wallet and voucher operations</description>

    <properties>
        <!-- Test execution controlled by parent profile properties -->
        <allure.version>2.29.1</allure.version>
        <allure-maven.version>2.14.0</allure-maven.version>
        <aspectj.version>1.9.22</aspectj.version>
        <cashu.gateway.version>0.4.1</cashu.gateway.version>
        <nostr.relay.uri>ws://localhost:5555</nostr.relay.uri>
    </properties>

    <dependencies>
        <!-- Wallet modules (for testing) -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-core-app</artifactId>
            <version>${project.parent.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-core-cashu</artifactId>
            <version>${project.parent.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-core-nostr</artifactId>
            <version>${project.parent.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- wallet-cli (for CLI command tests) -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-cli</artifactId>
            <version>${project.parent.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- phoenixd REST API client (for Lightning payment tests) -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>phoenixd-rest</artifactId>
            <version>0.1.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>cashu-gateway-phoenixd</artifactId>
            <version>${cashu.gateway.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- Note: Test utilities from existing ITs will be migrated to this module in Phase 0, Task 0.2 -->

        <!-- JUnit 5 (versions managed by parent) -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-api</artifactId>
        </dependency>

        <!-- AssertJ (version managed by parent) -->
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
        </dependency>

        <!-- Testcontainers (versions managed by parent) -->
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>

        <!-- WireMock (version managed by parent) -->
        <dependency>
            <groupId>org.wiremock</groupId>
            <artifactId>wiremock</artifactId>
        </dependency>

        <!-- Awaitility (version managed by parent) -->
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
        </dependency>

        <!-- Jackson (for JSON validation, versions managed by parent) -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>

        <!-- SLF4J & Logback (versions managed by parent) -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>

        <!-- H2 Database (version managed by parent) -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

        <!-- Allure reporting -->
        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-junit5</artifactId>
            <version>${allure.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Maven Compiler Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
            </plugin>

            <!-- Skip E2E tests during 'mvn test' - they require external services -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <configuration>
                    <excludes>
                        <exclude>**/*E2E.java</exclude>
                        <exclude>**/*E2ETest.java</exclude>
                    </excludes>
                    <systemPropertyVariables>
                        <nostr.relay.uri>${env.NOSTR_RELAY_URL}</nostr.relay.uri>
                    </systemPropertyVariables>
                    <environmentVariables>
                        <NOSTR_RELAY_URL>${nostr.relay.uri}</NOSTR_RELAY_URL>
                    </environmentVariables>
                </configuration>
            </plugin>

            <!-- Maven Failsafe Plugin for E2E tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${maven.failsafe.plugin.version}</version>
                <configuration>
                    <!-- Uses skipE2E.wallet from parent profiles -->
                    <skipITs>${skipE2E.wallet}</skipITs>

                    <!-- Parallel execution with 4 threads -->
                    <parallel>all</parallel>
                    <threadCount>4</threadCount>
                    <perCoreThreadCount>false</perCoreThreadCount>

                    <!-- Test naming patterns -->
                    <includes>
                        <include>**/*E2ETest.java</include>
                        <include>**/*E2E.java</include>
                    </includes>

                    <!-- Uses e2e.groups from parent profiles if set -->
                    <groups>${e2e.groups}</groups>

                    <!-- Exclude observability tests by default (require OTel Collector + Jaeger) -->
                    <excludedGroups>observability</excludedGroups>

                    <!-- System properties for tests -->
                    <systemPropertyVariables>
                        <junit.jupiter.execution.parallel.enabled>true</junit.jupiter.execution.parallel.enabled>
                        <junit.jupiter.execution.parallel.mode.default>concurrent</junit.jupiter.execution.parallel.mode.default>
                        <junit.jupiter.execution.parallel.config.strategy>fixed</junit.jupiter.execution.parallel.config.strategy>
                        <junit.jupiter.execution.parallel.config.fixed.parallelism>4</junit.jupiter.execution.parallel.config.fixed.parallelism>
                        <nostr.relay.uri>${env.NOSTR_RELAY_URL}</nostr.relay.uri>
                    </systemPropertyVariables>
                    <environmentVariables>
                        <NOSTR_RELAY_URL>${nostr.relay.uri}</NOSTR_RELAY_URL>
                    </environmentVariables>

                    <!-- Allure AspectJ weaver for test reporting -->
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    </argLine>

                    <!-- Reporting -->
                    <reportsDirectory>${project.build.directory}/failsafe-reports</reportsDirectory>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <!-- Allure Maven Plugin -->
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
                <version>${allure-maven.version}</version>
                <configuration>
                    <reportVersion>${allure.version}</reportVersion>
                    <resultsDirectory>${project.build.directory}/allure-results</resultsDirectory>
                    <reportDirectory>${project.build.directory}/allure-reports</reportDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!--
         E2E test profiles are centralized in parent POM.
         Use: mvn verify -Pe2e-wallet (all wallet E2E tests)
         Use: mvn verify -Pe2e-all (all E2E tests across repository)
    -->

</project>
