+func TestSetAlarmConfig(t *testing.T) {
+ xapp.Logger.Info("TestSetAlarmConfig")
+
+ var setAlarmConfig alarm.AlarmConfigParams
+ setAlarmConfig.MaxActiveAlarms = 500
+ setAlarmConfig.MaxAlarmHistory = 2000
+
+ pbodyEn, _ := json.Marshal(setAlarmConfig)
+ req, _ := http.NewRequest("POST", "/ric/v1/alarms/config", bytes.NewBuffer(pbodyEn))
+ handleFunc := http.HandlerFunc(alarmManager.SetAlarmConfig)
+ response := executeRequest(req, handleFunc)
+ checkResponseCode(t, http.StatusOK, response.Code)
+
+ var getAlarmConfig alarm.AlarmConfigParams
+ req, _ = http.NewRequest("GET", "/ric/v1/alarms/config", nil)
+ req = mux.SetURLVars(req, nil)
+ handleFunc = http.HandlerFunc(alarmManager.GetAlarmConfig)
+ response = executeRequest(req, handleFunc)
+ checkResponseCode(t, http.StatusOK, response.Code)
+
+ // Decode the json output from handler
+ json.NewDecoder(response.Body).Decode(&getAlarmConfig)
+ if getAlarmConfig.MaxActiveAlarms != 500 || getAlarmConfig.MaxAlarmHistory != 2000 {
+ t.Errorf("Incorrect alarm thresholds")
+ }
+
+ // Revert ot default
+ setAlarmConfig.MaxActiveAlarms = 5000
+ setAlarmConfig.MaxAlarmHistory = 20000
+
+ pbodyEn, _ = json.Marshal(setAlarmConfig)
+ req, _ = http.NewRequest("POST", "/ric/v1/alarms/config", bytes.NewBuffer(pbodyEn))
+ handleFunc = http.HandlerFunc(alarmManager.SetAlarmConfig)
+ response = executeRequest(req, handleFunc)
+ checkResponseCode(t, http.StatusOK, response.Code)
+
+ req, _ = http.NewRequest("GET", "/ric/v1/alarms/config", nil)
+ req = mux.SetURLVars(req, nil)
+ handleFunc = http.HandlerFunc(alarmManager.GetAlarmConfig)
+ response = executeRequest(req, handleFunc)
+ checkResponseCode(t, http.StatusOK, response.Code)
+
+ // Decode the json output from handler
+ json.NewDecoder(response.Body).Decode(&getAlarmConfig)
+ if getAlarmConfig.MaxActiveAlarms != 5000 || getAlarmConfig.MaxAlarmHistory != 20000 {
+ t.Errorf("Incorrect alarm thresholds")
+ }
+}
+
+func TestConfigChangeCB(t *testing.T) {
+ xapp.Logger.Info("TestConfigChangeCB")
+ alarmManager.ConfigChangeCB("AlarmManager")
+}
+