<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.adorsys.psd2.sandbox</groupId>
		<artifactId>psd2-dynamic-sandbox</artifactId>
		<version>0.2.4.2</version>
		<relativePath>..</relativePath>
	</parent>

	<artifactId>psd2-sandbox-integration-tests</artifactId>
	<name>psd2-sandbox-integration-tests</name>

	<properties>
		<ruleset.basedir>..</ruleset.basedir>
		<skipOBA>${skipITs}</skipOBA>
		<skipSMTP>${skipITs}</skipSMTP>
		<skipLedgers>${skipITs}</skipLedgers>
		<skipProfile>${skipITs}</skipProfile>
		<skipCMS>${skipITs}</skipCMS>
		<skipGateway>${skipITs}</skipGateway>
		<UI>false</UI>
	</properties>

	<dependencies>

		<!-- Spring -->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-openfeign</artifactId>
			<version>2.0.2.RELEASE</version>
		</dependency>


		<!-- Test dependencies -->
		<dependency>
			<groupId>de.adorsys.psd2.sandbox</groupId>
			<artifactId>oba-rest-client</artifactId>
			<version>${project.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>de.adorsys.ledgers</groupId>
			<artifactId>xs2a-rest-client</artifactId>
			<version>${connector.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>de.adorsys.psd2</groupId>
			<artifactId>xs2a-server-api</artifactId>
			<version>${xs2a.version}</version>
			<scope>test</scope>
		</dependency>

		<!-- Commons -->
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<scope>test</scope>
		</dependency>

		<!-- Jackson -->
		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-yaml</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.assertj</groupId>
			<artifactId>assertj-core</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<scope>test</scope>
		</dependency>

		<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-chrome-driver</artifactId>
			<version>3.141.59</version>
			<scope>test</scope>
		</dependency>

		<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
		<dependency>
			<groupId>io.github.bonigarcia</groupId>
			<artifactId>webdrivermanager</artifactId>
			<version>3.3.0</version>
			<scope>test</scope>
		</dependency>

	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<version>3.1.1</version>
				<executions>
					<execution>
						<id>copy</id>
						<phase>package</phase>
						<goals>
							<goal>copy</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<artifactItems>
						<artifactItem>
							<groupId>de.adorsys.ledgers</groupId>
							<artifactId>gateway-app</artifactId>
							<version>${connector.version}</version>
							<type>jar</type>
							<overWrite>true</overWrite>
							<outputDirectory>${project.build.directory}/gateway</outputDirectory>
							<destFileName>gateway-app.jar</destFileName>
						</artifactItem>
						<artifactItem>
							<groupId>de.adorsys.ledgers</groupId>
							<artifactId>consent-management-server</artifactId>
							<version>${connector.version}</version>
							<type>jar</type>
							<overWrite>true</overWrite>
							<outputDirectory>${project.build.directory}/consents</outputDirectory>
							<destFileName>consent-management-server.jar</destFileName>
						</artifactItem>
						<artifactItem>
							<groupId>de.adorsys.ledgers</groupId>
							<artifactId>ledgers-app</artifactId>
							<version>${ledgers.version}</version>
							<type>jar</type>
							<overWrite>false</overWrite>
							<outputDirectory>${project.build.directory}/ledgers</outputDirectory>
							<destFileName>ledgers-app.jar</destFileName>
						</artifactItem>
						<artifactItem>
							<groupId>de.adorsys.psd2</groupId>
							<artifactId>aspsp-profile-server</artifactId>
							<version>${xs2a.version}</version>
							<type>jar</type>
							<overWrite>false</overWrite>
							<outputDirectory>${project.build.directory}/aspsp-profile</outputDirectory>
							<destFileName>aspsp-profile.jar</destFileName>
						</artifactItem>
						<artifactItem>
							<!-- https://mvnrepository.com/artifact/com.github.tntim96/fakesmtp -->
							<groupId>com.github.tntim96</groupId>
							<artifactId>fakesmtp</artifactId>
							<version>2.0</version>
							<type>jar</type>
							<overWrite>false</overWrite>
							<outputDirectory>${project.build.directory}/fakesmtp</outputDirectory>
							<destFileName>fakesmtp.jar</destFileName>
						</artifactItem>
						<artifactItem>
							<groupId>de.adorsys.psd2.sandbox</groupId>
							<artifactId>online-banking-app</artifactId>
							<version>${project.version}</version>
							<type>jar</type>
							<overWrite>true</overWrite>
							<outputDirectory>${project.build.directory}/online-banking</outputDirectory>
							<destFileName>online-banking-app.jar</destFileName>
						</artifactItem>
					</artifactItems>
					<overWriteReleases>false</overWriteReleases>
					<overWriteSnapshots>true</overWriteSnapshots>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.bazaarvoice.maven.plugins</groupId>
				<artifactId>process-exec-maven-plugin</artifactId>
				<version>0.7</version>
				<configuration>
					<skip>${skipITs}</skip>
				</configuration>
				<executions>
					<!-- ONLINE BANKING APP -->
					<execution>
						<id>online-banking-app</id>
						<phase>pre-integration-test</phase>
						<goals>
							<goal>start</goal>
						</goals>
						<configuration>
							<name>ONLINE BANKING</name>
							<skip>${skipOBA}</skip>
							<workingDir>${project.build.directory}/online-banking</workingDir>
							<waitForInterrupt>${waitAtOBA}</waitForInterrupt>
							<healthcheckUrl>http://localhost:8090/actuator/health</healthcheckUrl>
							<!-- java -jar target/online-banking/online-banking-app.jar - -spring.profiles.active=mockspi 
								- -security.basic.enabled=false -->
							<arguments>
								<argument>java</argument>
								<argument>-jar</argument>
								<argument>${project.build.directory}/online-banking/online-banking-app.jar</argument>
								<argument>--log4j.logger.org.springframework=WARN</argument>
								<argument>--logging.level.root=WARN</argument>
								<argument>--logging.level.org.springframework.boot=WARN</argument>
								<argument>--online-banking.sca.uiRedirect=${UI}</argument>
							</arguments>
						</configuration>
					</execution>
					<!-- MAIL SERVER -->
					<execution>
						<id>faksmtp-process</id>
						<phase>pre-integration-test</phase>
						<goals>
							<goal>start</goal>
						</goals>
						<configuration>
							<name>FAKE SMTP</name>
							<skip>${skipSMTP}</skip>
							<workingDir>${project.build.directory}/fakesmtp</workingDir>
							<waitForInterrupt>${waitAtSMTP}</waitForInterrupt>
							<!-- java -jar target/fakesmtp/fakesmtp.jar -s -b -p 2500 -o target/fakesmtp/mails -->
							<waitAfterLaunch>2</waitAfterLaunch><!-- 2 seconds -->
							<arguments>
								<argument>java</argument>
								<argument>-jar</argument>
								<argument>${project.build.directory}/fakesmtp/fakesmtp.jar</argument>
								<argument>-s</argument>
								<argument>-b</argument>
								<argument>-p</argument>
								<argument>2500</argument>
								<argument>-o</argument>
								<argument>${project.build.directory}/fakesmtp/mails</argument>
							</arguments>
						</configuration>
					</execution>
					<!-- START LEDGERS -->
					<execution>
						<id>ledgers-process</id>
						<phase>pre-integration-test</phase>
						<goals>
							<goal>start</goal>
						</goals>
						<configuration>
							<name>LEDGERS</name>
							<skip>${skipLedgers}</skip>
							<workingDir>${project.build.directory}/ledgers</workingDir>
							<waitForInterrupt>${waitAtLedgers}</waitForInterrupt>
							<healthcheckUrl>http://localhost:8088/actuator/health</healthcheckUrl>
							<!-- java -jar target/ledgers/ledgers-app.jar - -spring.profiles.active=h2 
								- -ledgers.mockbank.data.load=true -->
							<waitAfterLaunch>10</waitAfterLaunch>
							<arguments>
								<argument>java</argument>
								<argument>-jar</argument>
								<argument>${project.build.directory}/ledgers/ledgers-app.jar</argument>
								<argument>--spring.profiles.active=h2</argument>
								<argument>--ledgers.mockbank.data.load=true</argument>
								<argument>--spring.jpa.show-sql=false</argument>
								<argument>--log4j.logger.org.springframework=WARN</argument>
								<argument>--logging.level.root=WARN</argument>
								<argument>--logging.level.org.springframework.boot=WARN</argument>
							</arguments>
						</configuration>
					</execution>
					<!-- ASPSP PROFILE -->
					<execution>
						<id>aspsp-profile-server</id>
						<phase>pre-integration-test</phase>
						<goals>
							<goal>start</goal>
						</goals>
						<configuration>
							<name>ASPSP PROFILE</name>
							<skip>${skipProfile}</skip>
							<workingDir>${project.build.directory}/aspsp-profile</workingDir>
							<waitForInterrupt>${waitAtProfile}</waitForInterrupt>
							<healthcheckUrl>http://localhost:48080/api/v1/health</healthcheckUrl>
							<!-- java -jar target/aspsp-profile/aspsp-profile.jar - -bank_profile.path=src/test/resources/bank_profile_ledgers.yml -->
							<arguments>
								<argument>java</argument>
								<argument>-jar</argument>
								<argument>${project.build.directory}/aspsp-profile/aspsp-profile.jar</argument>
								<argument>--bank_profile.path=${project.build.directory}/test-classes/bank_profile_ledgers.yml</argument>
								<argument>--log4j.logger.org.springframework=WARN</argument>
								<argument>--logging.level.root=WARN</argument>
								<argument>--logging.level.org.springframework.boot=WARN</argument>
							</arguments>
						</configuration>
					</execution>
					<!-- CONSENT MANAGEMENT SYSTEM -->
					<execution>
						<id>consent-management-server</id>
						<phase>pre-integration-test</phase>
						<goals>
							<goal>start</goal>
						</goals>
						<configuration>
							<name>CMS</name>
							<skip>${skipCMS}</skip>
							<workingDir>${project.build.directory}/consents</workingDir>
							<waitForInterrupt>${waitAtCMS}</waitForInterrupt>
							<healthcheckUrl>http://localhost:38080/health</healthcheckUrl>
							<!-- java -jar target/consents/consent-management-server.jar - -spring.profiles.active=h2 
								- -security.basic.enabled=false - -spring.config.location=target/test-classes/consent-management-application.yml -->
							<arguments>
								<argument>java</argument>
								<argument>-jar</argument>
								<argument>${project.build.directory}/consents/consent-management-server.jar</argument>
								<argument>--spring.profiles.active=h2</argument>
								<argument>--security.basic.enabled=false</argument>
								<argument>--spring.config.location=${project.build.directory}/test-classes/consent-management-application.yml</argument>
								<argument>--log4j.logger.org.springframework=WARN</argument>
								<argument>--logging.level.root=WARN</argument>
								<argument>--logging.level.org.springframework.boot=WARN</argument>
							</arguments>
						</configuration>
					</execution>
					<!-- Gateway -->
					<execution>
						<id>gateway-app</id>
						<phase>pre-integration-test</phase>
						<goals>
							<goal>start</goal>
						</goals>
						<configuration>
							<name>GATEWAY</name>
							<skip>${skipGateway}</skip>
							<workingDir>${project.build.directory}/gateway</workingDir>
							<waitForInterrupt>${waitAtGateway}</waitForInterrupt>
							<healthcheckUrl>http://localhost:8089/health</healthcheckUrl>
							<!-- java -jar target/gateway/gateway-app.jar - -spring.profiles.active=mockspi 
								- -security.basic.enabled=false -->
							<arguments>
								<argument>java</argument>
								<argument>-jar</argument>
								<argument>${project.build.directory}/gateway/gateway-app.jar</argument>
								<argument>--spring.profiles.active=mockspi</argument>
								<argument>--security.basic.enabled=false</argument>
								<argument>--log4j.logger.org.springframework=WARN</argument>
								<argument>--logging.level.root=WARN</argument>
								<argument>--logging.level.org.springframework.boot=WARN</argument>
							</arguments>
						</configuration>
					</execution>

					<!--STOP ALL -->
					<execution>
						<id>stop-all</id>
						<phase>post-integration-test</phase>
						<goals>
							<goal>stop-all</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>

