This guide will help you test the Matrikkel integration setup step-by-step.
✅ PostgreSQL database is running on 10.0.2.15:5435
✅ Database name: matrikkel
✅ User: hc483 with password Fmsigg10
✅ Maven project compiles successfully
Run Flyway migrations to create the tables:
cd /opt/matrikkel_java
mvn flyway:migrateExpected output:
[INFO] Successfully applied 3 migrations to schema "public"
[INFO] Schema version: 3
Migrations applied:
- V1__initial_schema.sql - Creates
matrikkel_matrikkelenhetertable - V2__create_kommuner_table.sql - Creates
matrikkel_kommunertable - V3__add_kommuner_foreign_key.sql - Adds foreign key constraint
Insert Bergen (kommune 4601) into the database:
psql -h 10.0.2.15 -p 5435 -U hc483 -d matrikkel -f scripts/insert_bergen.sqlOr using psql interactively:
psql -h 10.0.2.15 -p 5435 -U hc483 -d matrikkelThen run:
INSERT INTO matrikkel_kommuner (
kommunenummer, kommunenavn, fylkesnummer, fylkesnavn,
koordinatsystem_kode, timestamp_created, timestamp_updated
) VALUES (
4601, 'Bergen', 46, 'Vestland', 'EPSG:25832',
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
) ON CONFLICT (kommunenummer) DO NOTHING;
SELECT * FROM matrikkel_kommuner WHERE kommunenummer = 4601;Expected output:
kommune_id | kommunenummer | kommunenavn | fylkesnummer | fylkesnavn | ...
------------+---------------+-------------+--------------+------------+-----
1 | 4601 | Bergen | 46 | Vestland | ...
Check that both tables exist and are empty:
-- Check tables
\dt matrikkel*
-- Check matrikkel_kommuner
SELECT COUNT(*) FROM matrikkel_kommuner; -- Should be 1 (Bergen)
-- Check matrikkel_matrikkelenheter
SELECT COUNT(*) FROM matrikkel_matrikkelenheter; -- Should be 0 initiallyNow run the integration test:
cd /opt/matrikkel_java
mvn spring-boot:run -Dspring-boot.run.arguments="--test"The test runs 3 validation steps:
- ✅ Checks if Bergen kommune (4601) exists in database
- ✅ Verifies matrikkelenhet table is accessible
- ✅ Counts existing matrikkelenheter
- ✅ Connects to Matrikkel API (test environment)
- ✅ Fetches matrikkelenheter from Bergen using NedlastningServiceWS
- ✅ Validates SOAP authentication and pagination
- ✅ Maps SOAP objects to JPA entities using MatrikkelenhetMapper
- ✅ Validates field conversions (dates, booleans, etc.)
- ✅ Checks repository read/write operations
=== Starting Matrikkel Integration Test ===
--- Test 1: Database Connection ---
✅ Bergen kommune found: Kommune[id=1, kommunenummer=4601, navn=Bergen, fylke=Vestland]
✅ Matrikkelenhet table accessible. Current count: 0
--- Test 2: SOAP Client Connection ---
Attempting to fetch first batch of matrikkelenheter from Bergen (4601)...
✅ SOAP connection successful! Received 5000 object(s)
Sample matrikkelenhet ID: 123456789
Kommune: 4601, Gnr: 123, Bnr: 45
--- Test 3: Mapping and Persistence ---
Fetching matrikkelenheter from Bergen (4601)...
Received 5000 matrikkelenheter total
Testing mapper with 5 sample objects...
✅ Mapped: 4601-123/45/0/0 (ID: 123456789)
✅ Mapped: 4601-124/1/0/0 (ID: 123456790)
✅ Mapped: 4601-125/10/0/0 (ID: 123456791)
✅ Mapped: 4601-126/2/0/0 (ID: 123456792)
✅ Mapped: 4601-127/5/0/0 (ID: 123456793)
Mapping results: 5 successful, 0 failed
✅ Mapper is working correctly!
Testing persistence (dry-run, no commit)...
Matrikkelenhet 123456789 is new (not yet in database)
✅ Repository is accessible and ready for import
=== Test Complete ===
Solution: Run Step 2 again to insert Bergen into matrikkel_kommuner.
Possible causes:
- Wrong credentials in
application-dev.yml - Network/firewall blocking connection to Matrikkel API
- Test environment is down
Check configuration:
cat src/main/resources/application-dev.yml | grep -A 5 "matrikkel:"Should show:
matrikkel:
api:
base-url: https://wsweb-test.matrikkel.no/matrikkel-ws-v1.0/
username: [municipality]_test
password: <your-password>This could indicate issues with the generated SOAP classes or mapper logic.
Debug steps:
- Check the mapper logs for specific field errors
- Verify the SOAP response structure matches expectations
- Run with debug logging:
mvn spring-boot:run -Dspring-boot.run.arguments="--test" -Dlogging.level.no.matrikkel=DEBUG
Check PostgreSQL is running:
psql -h 10.0.2.15 -p 5435 -U hc483 -d matrikkel -c "SELECT version();"Check Flyway migration status:
mvn flyway:infoOnce all 3 tests pass ✅, you're ready to:
- Create the full import service - Business logic with transactions
- Create the import CLI command - To import all matrikkelenheter
- Run a full import - Import all properties from Bergen
- Add more municipalities - Extend to other kommuner
-- Check imported matrikkelenheter
SELECT COUNT(*), kommunenummer
FROM matrikkel_matrikkelenheter
GROUP BY kommunenummer;
-- View sample matrikkelenheter
SELECT matrikkelenhet_id, matrikkelnummer_tekst, timestamp_updated
FROM matrikkel_matrikkelenheter
LIMIT 10;
-- Find specific property by cadastral number
SELECT * FROM matrikkel_matrikkelenheter
WHERE kommunenummer = 4601
AND gardsnummer = 123
AND bruksnummer = 45;
-- Check data freshness
SELECT
kommunenummer,
COUNT(*) as total,
MIN(timestamp_updated) as oldest,
MAX(timestamp_updated) as newest
FROM matrikkel_matrikkelenheter
GROUP BY kommunenummer;# Compile only
mvn compile
# Run with test flag
mvn spring-boot:run -Dspring-boot.run.arguments="--test"
# Run with debug logging
mvn spring-boot:run -Dspring-boot.run.arguments="--test" -Dlogging.level.root=DEBUG
# Clean and rebuild
mvn clean install
# Run Flyway migrations
mvn flyway:migrate
# Check Flyway status
mvn flyway:info
# Rollback last migration (if needed)
mvn flyway:undo- Database connection defaults
- JPA/Hibernate settings
- Flyway configuration
- Local database:
10.0.2.15:5435 - Matrikkel API test environment
- Test credentials
- Dependencies: Spring Boot, PostgreSQL, JAX-WS, Lombok
- Build plugins: jaxws-maven-plugin for SOAP code generation
- Flyway plugin for database migrations
If you encounter issues:
- Check the full logs (not just the summary)
- Verify all prerequisites are met
- Check the GitHub Copilot instructions file:
.github/copilot-instructions.md - Review the database schema documentation:
docs/DATABASE_SCHEMA.md
Good luck with your testing! 🎉