Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.DS_Store
.vscode
src/test/resources/config.properties
src/integration-test/resources/config.properties
87 changes: 85 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
<maven-checkstyle-plugin-version>3.6.0</maven-checkstyle-plugin-version>
<maven-bundle-plugin-version>5.1.9</maven-bundle-plugin-version>
<spotless-maven-plugin-version>3.9.0</spotless-maven-plugin-version>
<maven-surefire-plugin-version>3.5.6</maven-surefire-plugin-version>
<maven-test-plugins-version>3.5.6</maven-test-plugins-version>
<build-helper-maven-plugin-version>3.6.1</build-helper-maven-plugin-version>
<google-java-format-version>1.34.1</google-java-format-version>
<maven-enforcer-version>3.6.3</maven-enforcer-version>
</properties>
Expand All @@ -72,6 +73,48 @@
<url>git@github.com:Adyen/adyen-java-api-library.git</url>
</scm>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin-version}</version>
<executions>
<execution>
<id>add-integration-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
<goal>add-test-resource</goal>
</goals>
<configuration>
<sources>
<source>src/integration-test/java</source>
</sources>
<resources>
<resource>
<directory>src/integration-test/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-test-plugins-version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -222,6 +265,7 @@
<includes>
<include>src/main/java/**/*.java</include>
<include>src/test/java/**/*.java</include>
<include>src/integration-test/java/**/*.java</include>
</includes>
<googleJavaFormat>
<version>${google-java-format-version}</version>
Expand All @@ -238,7 +282,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin-version}</version>
<version>${maven-test-plugins-version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -290,6 +334,45 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>integration-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<groups>external</groups>
<excludedGroups>manual</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>manual-integration-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<groups>manual</groups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<!-- Compile -->
<dependency>
Expand Down
71 changes: 71 additions & 0 deletions src/integration-test/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<integration_test_guidelines>
## Scope

These instructions apply to files under `src/integration-test`.

## Before Writing a Test

- Read `src/integration-test/README.md`.
- Verify the public service method and model types in `src/main/java`.
- Do not edit generated production models or services to make an integration test pass.
- Determine whether the test is automated external coverage or requires manual infrastructure.

## Structure

- Mirror the production package under `src/integration-test/java`.
- Name integration-test classes `*IT` so Maven Failsafe discovers them.
- Extend `BaseIntegrationTest` and use its typed configuration accessors.
- Use the service-specific client accessor when an API requires dedicated credentials, such as
`getLegalEntityManagementClient()` or `getBalancePlatformClient()`.
- Do not instantiate or close `Client` directly. `BaseIntegrationTest` caches clients by credential
and closes them after each test.
- Annotate external tests with `@Tag(IntegrationTestTags.EXTERNAL)`.
- Also annotate tests requiring a person, terminal, or other dedicated infrastructure with
`@Tag(IntegrationTestTags.MANUAL)`.
- Use behavior-focused names such as `shouldReturnValidationErrorWhenReferenceIsMissing`.
- Keep one observable behavior per test and use Arrange, Act, Assert sections.
- Prefer explicit imports, response types, and checked exceptions. Do not use wildcard imports,
`var`, or `throws Exception`.

## Reliability and Safety

- Generate unique references and idempotency keys for requests that create remote state.
- Do not share mutable state or depend on test execution order.
- Clean up remotely created resources when the API supports cleanup.
- For eventually consistent APIs, use bounded polling rather than fixed sleeps.
- Add a suitable timeout when an operation can otherwise wait indefinitely.
- Integration-test clients are configured for the TEST environment. Do not add LIVE-only behavior
or credentials without updating `BaseIntegrationTest` and this documentation.
- Do not use `@Disabled` as the normal opt-in mechanism. Use the Maven profiles and JUnit tags.
- Do not run an external integration test unless the user explicitly asks for that API call.

## Configuration

- Add typed accessors to `BaseIntegrationTest` instead of reading configuration directly in tests.
- Configuration lookup precedence is Java system property, environment variable, then
`src/integration-test/resources/config.properties`.
- Use environment variables or the ignored properties file for secrets. Command-line system
properties can be exposed through shell history or process listings.

## Assertions and Comments

- Assert stable contract fields, identifiers, statuses, and documented error codes.
- Assert exact error messages only when the wording is part of the documented contract.
- Include assertion messages that explain the violated contract.
- Extract repeated request construction and response assertions into focused helpers.
- Keep comments limited to prerequisites, non-obvious API constraints, and Arrange, Act, Assert
markers. Do not narrate straightforward Java.

## Validation

Validate generated tests without contacting Adyen:

```bash
mvn spotless:apply
mvn -Pintegration-tests -DskipTests test-compile
mvn spotless:check checkstyle:check -DskipTests
```

Use the opt-in execution commands from `src/integration-test/README.md` only when external execution
is explicitly requested.
</integration_test_guidelines>
Loading