Increasing UT for Alarm-go
[ric-plt/alarm-go.git] / manager / cmd / restapi_test.go
index 90954af..9ef4df4 100755 (executable)
@@ -23,11 +23,11 @@ package main
 import (
        "bytes"
        "encoding/json"
-       "github.com/stretchr/testify/assert"
        "net/http"
        "net/http/httptest"
        "testing"
 
+       "github.com/stretchr/testify/assert"
        "gerrit.o-ran-sc.org/r/ric-plt/alarm-go/alarm"
 )
 
@@ -47,7 +47,7 @@ func TestGetActiveAlarmsRESTInterface(t *testing.T) {
 }
 
 func TestRaiseAlarmRESTInterface(t *testing.T) {
-       a := alarmer.NewAlarm(alarm.RIC_RT_DISTRIBUTION_FAILED, alarm.SeverityMajor, "Some App data", "eth 0 1")
+       a := alarmer.NewAlarm(alarm.E2_CONNECTION_PROBLEM, alarm.SeverityMajor, "Some App data", "eth 0 1")
        b, err := json.Marshal(&a)
        if err != nil {
                t.Errorf("Unexpected error %v", err)
@@ -67,7 +67,7 @@ func TestRaiseAlarmRESTInterface(t *testing.T) {
 }
 
 func TestClearAlarmRESTInterface(t *testing.T) {
-       a := alarmer.NewAlarm(alarm.RIC_RT_DISTRIBUTION_FAILED, alarm.SeverityMajor, "Some App data", "eth 0 1")
+       a := alarmer.NewAlarm(alarm.E2_CONNECTION_PROBLEM, alarm.SeverityMajor, "Some App data", "eth 0 1")
        b, err := json.Marshal(&a)
        if err != nil {
                t.Errorf("Unexpected error %v", err)
@@ -85,3 +85,19 @@ func TestClearAlarmRESTInterface(t *testing.T) {
        assert.Equal(t, true, rr != nil)
        assert.Equal(t, rr.Code, http.StatusOK)
 }
+
+func TestSymptomDataHandler(t *testing.T) {
+       req, err := http.NewRequest("POST", "/ric/v1/symptomdata", nil)
+       if err != nil {
+               t.Fatal(err)
+       }
+
+       rr := httptest.NewRecorder()
+       handler := http.HandlerFunc(alarmManager.SymptomDataHandler)
+       handler.ServeHTTP(rr, req)
+
+       assert.Equal(t, true, rr != nil)
+       assert.Equal(t, rr.Code, http.StatusOK)
+}
+
+