AgentSkillsCN

melosys-eessi-debugger

在 melosys E2E 测试中调试 EUX/EESSI 模拟问题。适用于以下情况: - E2E 测试因 /eux/... 端点返回 404 错误而失败, - melosys-api 日志显示 “Kall mot eessi feilet” 错误, - melosys-eessi 日志显示针对 eux 端点的 NotFoundException, - 添加需要模拟支持的新 EESSI/EUX 功能, - 追踪数据流:melosys-api → melosys-eessi → melosys-mock。

SKILL.md
--- frontmatter
name: melosys-eessi-debugger
description: |
  Debug EUX/EESSI mock issues in melosys E2E tests. Use when:
  - E2E tests fail with 404 errors from /eux/... endpoints
  - melosys-api logs show "Kall mot eessi feilet" errors
  - melosys-eessi logs show NotFoundException for eux endpoints
  - Adding new EESSI/EUX functionality that requires mock support
  - Tracing data flow: melosys-api → melosys-eessi → melosys-mock

Melosys EESSI Debugger

Debug and fix mock endpoint issues for EUX/EESSI integration in E2E tests.

Architecture Overview

code
┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  melosys-api    │────▶│  melosys-eessi  │────▶│  melosys-mock   │
│  (port 8080)    │     │  (port 8081)    │     │  (port 8083)    │
└─────────────────┘     └─────────────────┘     └─────────────────┘
                                                        │
                                                        ▼
                                               ┌─────────────────┐
                                               │  EuxRinaApi.kt  │
                                               │  /eux/...       │
                                               └─────────────────┘

Key insight: melosys-eessi adds /cpi/ prefix to most EUX calls, so endpoints need BOTH versions:

  • /eux/buc/{id} - direct calls
  • /eux/cpi/buc/{id} - calls via melosys-eessi

Repo Locations

RepoPathPurpose
melosys-e2e-testsCurrent projectE2E tests with Playwright
melosys-api~/source/nav/melosys-apiMain backend
melosys-web~/source/nav/melosys-webFrontend
melosys-eessi~/source/nav/melosys-eessiEESSI integration
melosys-mock~/source/nav/melosys-docker-compose/mockMock service
eux-rina-api~/source/nav/eux-rina-apiReference only

Debugging Workflow

1. Identify the Missing Endpoint

Look for 404 errors in logs:

code
# melosys-api error pattern:
"Kall mot eessi feilet 404 NOT_FOUND"

# melosys-eessi error pattern:
"404 fra eux: {...\"path\":\"/eux/cpi/...\"}"

Extract the path from the error, e.g., /eux/cpi/buc/{id}/sed/{sedId}/handlinger

2. Check eux-rina-api for Reference

Find the endpoint in eux-rina-api to understand expected behavior:

bash
# Search for endpoint pattern
grep -r "handlinger" ~/source/nav/eux-rina-api/src --include="*.kt"

3. Add Endpoint to melosys-mock

Edit melosys-docker-compose/mock/src/main/kotlin/no/nav/melosys/melosysmock/eux/EuxRinaApi.kt

Pattern for CPI endpoints:

kotlin
@GetMapping("/cpi/buc/{rinaSaksnummer}/sed/{dokumentId}/handlinger")
fun hentSedHandlingerCpi(
    @PathVariable rinaSaksnummer: String,
    @PathVariable dokumentId: String
): List<String> {
    log.info("CPI: Henter handlinger for SED $dokumentId på BUC $rinaSaksnummer")
    return listOf("Read", "Update", "Send", "Cancel")
}

4. Restart Mock and Test

bash
cd ~/source/nav/melosys-docker-compose
docker compose restart melosys-mock

Common Endpoint Patterns

See references/cpi-endpoints.md for complete list of CPI endpoints.

BUC Operations

EndpointMethodReturns
/cpi/bucPOSTBUC ID string
/cpi/buc/{id}GETBUC JSON
/cpi/buc/{id}/mottakerePUTvoid
/cpi/buc/{id}/muligeaksjonerGETList<String>

SED Operations

EndpointMethodReturns
/cpi/buc/{id}/sedPOSTSED ID string
/cpi/buc/{id}/sed/{sedId}GETSED JSON
/cpi/buc/{id}/sed/{sedId}/handlingerGETList<String>
/cpi/buc/{id}/sed/{sedId}/sendPOSTvoid
/cpi/buc/{id}/sed/{sedId}/vedleggPOST (multipart)vedlegg ID

Utility

EndpointMethodReturns
/cpi/url/buc/{id}GETRINA URL string
/cpi/institusjonerGETInstitutions JSON
/cpi/sed/pdfPOSTPDF bytes

Tracing Request Flow

In melosys-api

Look for calls to EessiService or BucService:

bash
grep -r "eessiService\|bucService" ~/source/nav/melosys-api/app/src --include="*.kt" --include="*.java"

In melosys-eessi

The EuxConsumer.java makes actual HTTP calls:

bash
grep -r "exchange\|getForObject\|postForObject" ~/source/nav/melosys-eessi/src --include="*.java"

Key file: EuxConsumer.java - contains all REST client methods

In melosys-mock

All EUX endpoints: EuxRinaApi.kt

bash
grep -r "@.*Mapping" ~/source/nav/melosys-docker-compose/mock/src/main/kotlin/no/nav/melosys/melosysmock/eux/

Quick Fixes

Missing CPI endpoint

Most CPI endpoints mirror non-CPI endpoints. Copy the existing endpoint and:

  1. Add /cpi to the path
  2. Add Cpi suffix to method name
  3. Add "CPI:" prefix to log message

Wrong response type

Check eux-rina-api for expected return type. Common issues:

  • Returning void when String expected
  • Returning object when List expected

Multipart upload issues

Vedlegg endpoints require:

kotlin
@PostMapping("...", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
fun method(@RequestParam("file") file: MultipartFile?)