package iace import ( "testing" "github.com/google/uuid" ) func TestBuildRiskSuggestion_DualModel(t *testing.T) { hz := &Hazard{ ID: uuid.New(), Name: "Quetschung unter absenkender Hubplattform", Scenario: "Bediener wird zwischen Plattform und Boden eingeklemmt (Quetschung)", Category: "mechanical_hazard", LifecyclePhase: "normal_operation, maintenance", } rs := BuildRiskSuggestion(hz) if rs.ContactMode != "crushing" { t.Errorf("contact mode = %q, want crushing", rs.ContactMode) } // EN-62061 side populated + formula exposed if rs.EN62061.Severity.Value < 1 || rs.EN62061.Score < 1 || rs.EN62061.Level == "" { t.Errorf("EN62061 not populated: %+v", rs.EN62061) } if rs.EN62061.Formula == "" || rs.FineKinney.Formula == "" { t.Error("both formulas must be exposed for the professional") } // Fine-Kinney side populated, score == P*E*C fk := rs.FineKinney if fk.Probability.Value <= 0 || fk.Exposure.Value <= 0 || fk.Consequence.Value <= 0 { t.Errorf("FK params not populated: %+v", fk) } if want := fk.Probability.Value * fk.Exposure.Value * fk.Consequence.Value; fk.Score != want { t.Errorf("FK score = %v, want P*E*C = %v", fk.Score, want) } if fk.Band == "" { t.Error("FK band must be set") } // Justifications are the whole point (nachvollziehbar) if rs.EN62061.Probability.Justification == "" || fk.Consequence.Justification == "" { t.Error("justifications must be present on both models") } }