package module

import (
	"fmt"
	"testing"

	"gitlab.alibaba-inc.com/pai_biz_arch/pairec/recconf"
)

func TestTrigger(t *testing.T) {
	config := []recconf.TriggerConfig{
		recconf.TriggerConfig{
			TriggerKey: "sex",
		},
		recconf.TriggerConfig{
			TriggerKey: "age",
			Boundaries: []int{20, 30, 40, 50},
		},
		recconf.TriggerConfig{
			TriggerKey: "os",
		},
	}

	trigger := NewTrigger(config)

	features := []map[string]interface{}{
		map[string]interface{}{"sex": "Male",
			"os":  "IOS",
			"age": 23,
		},

		map[string]interface{}{"sex": "Male",
			"os": "Android",
		},
		map[string]interface{}{"sex": "Male",
			"os":  "Android",
			"age": 60,
		},
		map[string]interface{}{"sex": "Male",
			"os":  "Android",
			"age": 50,
		},
		map[string]interface{}{"sex": "Male",
			"os":  "Android",
			"age": 40,
		},
		map[string]interface{}{"sex": "Male",
			"os":  "Android",
			"age": 20,
		},
	}

	for _, f := range features {
		fmt.Println(trigger.GetValue(f))
	}
}
