Files
paliad/internal/services/proceeding_mapping_test.go
mAi 216abbfc98 feat(t-paliad-206): switch Go layer to lowercase dot-form proceeding codes
Sweeps internal/services + internal/handlers + internal/models to use
the new proceeding codes landed by mig 096. Stable Code* constants
live in internal/services/proceeding_mapping.go so a future rename
needs to touch one file.

Substantive changes:
- proceeding_mapping.go gains ResolveCounterclaimRouting() — the
  cascade resolver that routes upc.ccr.cfi (illustrative peer) back
  to upc.inf.cfi with with_ccr=true as default flag (design doc S1).
- deadline_search_service.go forum-bucket map updated; upc.ccr.cfi
  added to upc_cfi since it is a CFI peer.
- project_service.go CreateCounterclaim default lookup parameterised
  so the SQL string carries the constant, not a literal.
- proceeding_codes_shape_test.go: new file. Validates the shape
  regex standalone (always runs) and walks live DB rows asserting
  every active fristenrechner row matches the new shape + every
  stable Code* constant resolves to exactly one active row.

Comments and test fixtures throughout the Go tree updated to the
new shape. Tests pass under `go test ./internal/... -short`.
2026-05-18 12:13:24 +02:00

84 lines
3.0 KiB
Go

package services
import (
"reflect"
"testing"
)
func TestMapLitigationToFristenrechner(t *testing.T) {
type tc struct {
litigation, jurisdiction string
wantCode string
wantFlags []string
wantOK bool
}
cases := []tc{
// Unambiguous UPC fold-ins.
{"INF", "UPC", CodeUPCInfringement, nil, true},
{"REV", "UPC", CodeUPCRevocation, nil, true},
{"APP", "UPC", CodeUPCAppealMerits, nil, true},
{"APM", "UPC", CodeUPCPreliminary, nil, true},
// CCR + UPC = upc.inf.cfi with the with_ccr flag.
{"CCR", "UPC", CodeUPCInfringement, []string{"with_ccr"}, true},
// AMD + UPC = upc.inf.cfi with the with_amend flag.
{"AMD", "UPC", CodeUPCInfringement, []string{"with_amend"}, true},
// DE first-instance / Nichtigkeit mappings.
{"INF", "DE", CodeDEInfringementLG, nil, true},
{"REV", "DE", CodeDENullityBPatG, nil, true},
{"CCR", "DE", CodeDENullityBPatG, nil, true},
// EPA opposition.
{"OPP", "EPA", CodeEPAOpposition, nil, true},
// Ambiguous: APP+DE has both OLG and BGH analogues; project
// model can't disambiguate, so degrade.
{"APP", "DE", "", nil, false},
// No analogue: ZPO_CIVIL → nothing in fristenrechner.
{"ZPO_CIVIL", "DE", "", nil, false},
// AMD only fires on UPC; DE has no analogue.
{"AMD", "DE", "", nil, false},
// APM only fires on UPC.
{"APM", "EPA", "", nil, false},
// Unknown codes / jurisdictions → ok=false.
{"XXX", "UPC", "", nil, false},
{"INF", "ZZZ", "", nil, false},
{"", "", "", nil, false},
}
for _, c := range cases {
gotCode, gotFlags, gotOK := MapLitigationToFristenrechner(c.litigation, c.jurisdiction)
if gotCode != c.wantCode || gotOK != c.wantOK || !reflect.DeepEqual(gotFlags, c.wantFlags) {
t.Errorf("MapLitigationToFristenrechner(%q, %q) = (%q, %v, %v); want (%q, %v, %v)",
c.litigation, c.jurisdiction,
gotCode, gotFlags, gotOK,
c.wantCode, c.wantFlags, c.wantOK)
}
}
}
func TestResolveCounterclaimRouting(t *testing.T) {
t.Run("upc.ccr.cfi routes to upc.inf.cfi with with_ccr", func(t *testing.T) {
gotCode, gotFlags, routed := ResolveCounterclaimRouting(CodeUPCCounterclaim)
if gotCode != CodeUPCInfringement {
t.Errorf("effective code = %q, want %q", gotCode, CodeUPCInfringement)
}
if !reflect.DeepEqual(gotFlags, []string{"with_ccr"}) {
t.Errorf("default flags = %v, want [with_ccr]", gotFlags)
}
if !routed {
t.Errorf("routed = false, want true")
}
})
t.Run("non-ccr code passes through unchanged", func(t *testing.T) {
for _, code := range []string{CodeUPCInfringement, CodeUPCRevocation, CodeDEInfringementLG, "anything-else"} {
gotCode, gotFlags, routed := ResolveCounterclaimRouting(code)
if gotCode != code {
t.Errorf("ResolveCounterclaimRouting(%q) returned %q, want pass-through", code, gotCode)
}
if gotFlags != nil {
t.Errorf("ResolveCounterclaimRouting(%q) flags = %v, want nil", code, gotFlags)
}
if routed {
t.Errorf("ResolveCounterclaimRouting(%q) routed = true, want false", code)
}
}
})
}