package notification

import (
	"testing"

	"gopkg.in/yaml.v3"
)

const predefinedPoliciesStr = `
default:
  Inited:
    CreatedEvent:
      state: Created
      action:
        cmd: ["notify"]
        on_sucess: NotifyEvent
  Created:
    NotifyEvent:
      state: Notified1Times
      action:
        cmd: ["timeout", "20"]
        on_sucess: TimeoutEvent
  Notified1Times:
    TimeoutEvent:
      state: Notified1TimesTimeout
      action:
        cmd: ["notify", "urgent"]
        on_sucess: NotifyEvent
        on_failure: AcknowledgeEvent
    AcknowledgeEvent:
      state: Acknowledged
  Notified1TimesTimeout:
    NotifyEvent:
      state: Notified2Times
      action:
        cmd: ["timeout", "20"]
        on_sucess: TimeoutEvent
    AcknowledgeEvent:
      state: Acknowledged
  Notified2Times:
    TimeoutEvent:
      state: Notified2TimesTimeout
      action:
        cmd: ["notify", "phone"]
        on_sucess: NotifyEvent
    AcknowledgeEvent:
      state: Acknowledged
  Notified2TimesTimeout:
    NotifyEvent:
      state: Notified3Times
      action:
        cmd: ["timeout", "20"]
        on_sucess: TimeoutEvent
    AcknowledgeEvent:
      state: Acknowledged
  Notified3Times:
    TimeoutEvent:
      state: Notified3TimesTimeout
      action:
        cmd: ["notify", "card", "escalation"]
        on_sucess: NotifyEvent
    AcknowledgeEvent:
      state: Acknowledged
  Notified3TimesTimeout:
    NotifyEvent:
      state: NotifiedEscalation
      action:
        cmd: ["timeout", "20"]
        on_sucess: TimeoutEvent
    AcknowledgeEvent:
      state: Acknowledged
  NotifiedEscalation:
    TimeoutEvent:
      state: NotifiedEscalationTimeout
      action:
        cmd: ["notify", "card", "firemaster"]
        on_sucess: NotifyEvent
    AcknowledgeEvent:
      state: Acknowledged
  NotifiedEscalationTimeout:
    NotifyEvent:
      state: NotifiedFiremaster
      action:
        cmd: ["timeout", "20"]
        on_sucess: TimeoutEvent
    AcknowledgeEvent:
      state: Acknowledged
  NotifiedFiremaster:
    TimeoutEvent:
      state: NoResponse
    AcknowledgeEvent:
      state: Acknowledged
  NoResponse:
    AcknowledgeEvent:
      state: Acknowledged
  Acknowledged:
`

func TestNotificationPolicy(t *testing.T) {
	preDefinedPolicies := make(map[string]NotificationPolicy)
	err := yaml.Unmarshal([]byte(predefinedPoliciesStr), &preDefinedPolicies)
	if err != nil {
		t.Error(err)
	}
}
