Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
eb75136
integration tests for controller endpoints
Daggerpov Jun 3, 2025
9f47541
fix activity controller integration tests
Daggerpov Jun 3, 2025
2158b5b
tests for more classes
Daggerpov Jun 3, 2025
0e708ef
cache controller
Daggerpov Jun 3, 2025
9e0dd1e
README for controller integration tests
Daggerpov Jun 3, 2025
4cf9610
Fix S3 issues in config
Daggerpov Jun 3, 2025
743a9e3
test mock s3 config
Daggerpov Jun 3, 2025
d14b12c
Using test config for integration tests
Daggerpov Jun 3, 2025
c54ccc9
Update S3Config.java
Daggerpov Jun 3, 2025
e0db4db
little adjustments
Daggerpov Jun 3, 2025
901246b
mock tokens
Daggerpov Jun 3, 2025
5b47078
tokens for user controller integration tests
Daggerpov Jun 3, 2025
302f1cf
Repository validation github workflow edit
Daggerpov Jun 3, 2025
a512722
Split tests into separate github workflows
Daggerpov Jun 3, 2025
f971055
fix github workflows
Daggerpov Jun 3, 2025
4117cca
test security config
Daggerpov Jun 3, 2025
a9ceb7d
syntax change to work with H2
Daggerpov Jun 3, 2025
d63051a
adjustments for test security
Daggerpov Jun 3, 2025
2301005
fixed 8 integration tests
Daggerpov Jun 3, 2025
e772089
fixed 4 more integration tests
Daggerpov Jun 3, 2025
3386745
Fixing friend request & feedback submission controller tests
Daggerpov Jun 3, 2025
4725f79
fix activity id capitalization
Daggerpov Jun 3, 2025
be3c416
fix imports & syntax/naming
Daggerpov Jun 3, 2025
269e0a9
add notification controller integration tests
Daggerpov Jun 3, 2025
56c9b65
stricter exception handling in notificationcontroller
Daggerpov Jun 3, 2025
6949041
Test S3 config: many more methods
Daggerpov Jun 3, 2025
e94283f
config (maybe revert?)
Daggerpov Jun 3, 2025
82083ee
fix controllers themselves
Daggerpov Jun 3, 2025
1881577
@Transactional changes to service methods
Daggerpov Jun 3, 2025
236314d
notification preferences: change error/default handling
Daggerpov Jun 3, 2025
89508e2
fix more integration tests
Daggerpov Jun 3, 2025
8453757
fix notification controller tests
Daggerpov Jun 3, 2025
a54c185
more @Transactional and DirtiesContext changes
Daggerpov Jun 3, 2025
52b9f4e
Create TestRedisConfig.java
Daggerpov Jun 3, 2025
ddd9c1b
Revert "Create TestRedisConfig.java"
Daggerpov Jun 3, 2025
3408644
Revert "more @Transactional and DirtiesContext changes"
Daggerpov Jun 3, 2025
e41d7d5
Revert "fix notification controller tests"
Daggerpov Jun 3, 2025
7d7735c
Fixed AuthControllerIntegrationTest
ShaneMander Jun 4, 2025
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
111 changes: 111 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Integration Tests

on:
push:
branches:
- main
pull_request:
branches:
- '**'

permissions:
checks: write
contents: read
pull-requests: write

jobs:
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: testpassword
POSTGRES_USER: testuser
POSTGRES_DB: spawn_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

- name: Wait for PostgreSQL
run: |
until pg_isready -h localhost -p 5432 -U testuser; do
echo "Waiting for PostgreSQL..."
sleep 2
done

- name: Compile the project
run: mvn clean compile -DskipTests

- name: Compile test classes
run: mvn test-compile -DskipTests

- name: Run Integration Tests
env:
SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/spawn_test
SPRING_DATASOURCE_USERNAME: testuser
SPRING_DATASOURCE_PASSWORD: testpassword
SPRING_JPA_HIBERNATE_DDL_AUTO: create-drop
SPRING_PROFILES_ACTIVE: test
run: mvn test -Dtest="com.danielagapov.spawn.ControllerTests.**"

- name: Publish Integration Test Results
uses: dorny/test-reporter@v1
if: always()
with:
name: Integration Test Results
path: target/surefire-reports/*.xml
reporter: java-junit
fail-on-error: true

- name: Upload Integration Test Reports
uses: actions/upload-artifact@v4
if: always()
with:
name: integration-test-reports
path: target/surefire-reports/

- name: Generate Integration Test Summary
if: always()
run: |
echo "📊 Integration Test Summary"
echo "Total controller test files: $(find src/test/java/com/danielagapov/spawn/ControllerTests -name "*Test.java" | wc -l)"
if [ -d "target/surefire-reports" ]; then
total_tests=$(grep -r "tests=" target/surefire-reports/*.xml | grep -o "tests=\"[0-9]*\"" | grep -o "[0-9]*" | awk '{sum += $1} END {print sum}')
failed_tests=$(grep -r "failures=" target/surefire-reports/*.xml | grep -o "failures=\"[0-9]*\"" | grep -o "[0-9]*" | awk '{sum += $1} END {print sum}')
echo "Tests run: ${total_tests:-0}"
echo "Tests failed: ${failed_tests:-0}"
fi

- name: Upload Integration Test Logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: integration-test-logs
path: |
*.log
target/surefire-reports/
target/*.log
57 changes: 8 additions & 49 deletions .github/workflows/repository-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@ jobs:
name: Repository Validation
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: testpassword
POSTGRES_USER: testuser
POSTGRES_DB: spawn_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -53,7 +38,7 @@ jobs:
- name: Install repository validation dependencies
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client ripgrep
sudo apt-get install -y ripgrep

- name: Repository Static Analysis
run: |
Expand Down Expand Up @@ -164,30 +149,6 @@ jobs:
fi
' _ {} \;

- name: Build and Test Repository Layer
env:
SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/spawn_test
SPRING_DATASOURCE_USERNAME: testuser
SPRING_DATASOURCE_PASSWORD: testpassword
SPRING_JPA_HIBERNATE_DDL_AUTO: create-drop
SPRING_PROFILES_ACTIVE: test
run: |
echo "🚀 Building project and running repository tests..."

# Compile the project
mvn clean compile -DskipTests

# Check if repository or persistence test files exist
if find src/test/java -name "*Repository*Test.java" -o -name "*Persistence*Test.java" | grep -q "."; then
echo "📝 Found repository/persistence tests, running them..."
mvn test -Dtest="**/*Repository*Test,**/*Persistence*Test"
else
echo "📝 No repository/persistence tests found, skipping test execution..."
echo "✅ This is expected if you haven't created repository tests yet"
fi

echo "✅ Repository layer compilation and basic tests completed"

- name: Repository Method Naming Convention Check
run: |
echo "🔍 Checking JPA method naming conventions..."
Expand Down Expand Up @@ -216,6 +177,12 @@ jobs:
echo "✅ $1 passed method naming validation"
' _ {} \;

- name: Compile Repository Layer for Validation
run: |
echo "🚀 Compiling project to validate repository layer..."
mvn clean compile -DskipTests
echo "✅ Repository layer compilation completed"

- name: Generate Repository Validation Report
if: always()
run: |
Expand All @@ -234,12 +201,4 @@ jobs:
echo "JPA method declarations found: $jpa_methods"

echo "✅ Repository validation completed successfully!"

- name: Upload Validation Results
uses: actions/upload-artifact@v4
if: always()
with:
name: repository-validation-results
path: |
target/surefire-reports/
*.log
echo "Note: Repository tests are executed in the dedicated unit-tests and integration-tests workflows"
44 changes: 6 additions & 38 deletions .github/workflows/syntax-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,10 @@ jobs:
- name: Compile tests (syntax check for test files)
run: mvn test-compile -DskipTests

test-suite:
name: Test Suite Check
runs-on: ubuntu-latest
needs: compilation-check

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

- name: Run test suite
run: mvn test

- name: Publish Test Results
uses: dorny/test-reporter@v1
- name: Generate Compilation Summary
if: always()
with:
name: Test Suite
path: target/surefire-reports/*.xml
reporter: java-junit
fail-on-error: false

- name: Upload Test Reports
uses: actions/upload-artifact@v4
with:
name: test-reports
path: target/surefire-reports/
run: |
echo "📊 Compilation Check Summary"
echo "✅ Main source compilation completed"
echo "✅ Test source compilation completed"
echo "Note: Actual test execution is handled by separate unit-tests and integration-tests workflows"
73 changes: 73 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Unit Tests

on:
push:
branches:
- main
pull_request:
branches:
- '**'

permissions:
checks: write
contents: read
pull-requests: write

jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

- name: Compile the project
run: mvn clean compile -DskipTests

- name: Compile test classes
run: mvn test-compile -DskipTests

- name: Run Unit Tests
run: mvn test -Dtest="com.danielagapov.spawn.ServiceTests.**"

- name: Publish Unit Test Results
uses: dorny/test-reporter@v1
if: always()
with:
name: Unit Test Results
path: target/surefire-reports/*.xml
reporter: java-junit
fail-on-error: true

- name: Upload Unit Test Reports
uses: actions/upload-artifact@v4
if: always()
with:
name: unit-test-reports
path: target/surefire-reports/

- name: Generate Unit Test Summary
if: always()
run: |
echo "📊 Unit Test Summary"
echo "Total service test files: $(find src/test/java/com/danielagapov/spawn/ServiceTests -name "*.java" | wc -l)"
if [ -d "target/surefire-reports" ]; then
total_tests=$(grep -r "tests=" target/surefire-reports/*.xml | grep -o "tests=\"[0-9]*\"" | grep -o "[0-9]*" | awk '{sum += $1} END {print sum}')
failed_tests=$(grep -r "failures=" target/surefire-reports/*.xml | grep -o "failures=\"[0-9]*\"" | grep -o "[0-9]*" | awk '{sum += $1} END {print sum}')
echo "Tests run: ${total_tests:-0}"
echo "Tests failed: ${failed_tests:-0}"
fi
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down Expand Up @@ -154,12 +159,30 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<parameters>true</parameters>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.util.Date;
Expand All @@ -17,6 +18,7 @@
* It creates an admin user if one doesn't already exist.
*/
@Configuration
@Profile("!test") // Exclude from test profile
public class AdminUserInitializer {

@Value("${ADMIN_USERNAME:admin}")
Expand Down
Loading
Loading