New API version with additional structures and params

Change-Id: I02855719e75a9f8d9a0f56e762e56bdc143803ce
Signed-off-by: Mohamed Abukar <abukar.mohamed@nokia.com>
diff --git a/pkg/xapp/subscription_test.go b/pkg/xapp/subscription_test.go
index a685a81..2913246 100755
--- a/pkg/xapp/subscription_test.go
+++ b/pkg/xapp/subscription_test.go
@@ -16,47 +16,62 @@
 
 var suite *testing.T
 
-var requestorId = int64(0x4EEC)
+var meid = "gnb123456"
+var funId = int64(1)
+var clientEndpoint = "localhost:4561"
 var direction = int64(0)
 var procedureCode = int64(27)
 var typeOfMessage = int64(1)
 
 var reportParams = apimodel.ReportParams{
-	RequestorID: &requestorId,
+	Meid: meid,
+	RANFunctionID: &funId,
+	ClientEndpoint: &clientEndpoint,
 	EventTriggers: apimodel.EventTriggerList{
 		&apimodel.EventTrigger{
-			InterfaceDirection: &direction,
-			ProcedureCode:      &procedureCode,
-			TypeOfMessage:      &typeOfMessage,
+			InterfaceDirection: direction,
+			ProcedureCode:      procedureCode,
+			TypeOfMessage:      typeOfMessage,
 		},
 	},
 }
 
-var controlParams = apimodel.ControlParams{
-	RequestorID: requestorId,
-}
-
 var policyParams = apimodel.PolicyParams{
-	RequestorID: requestorId,
+	Meid: &meid,
+	RANFunctionID: &funId,
+	ClientEndpoint: &clientEndpoint,
+	EventTriggers: apimodel.EventTriggerList{
+		&apimodel.EventTrigger{
+			InterfaceDirection: direction,
+			ProcedureCode:      procedureCode,
+			TypeOfMessage:      typeOfMessage,
+		},
+	},
+	PolicyActionDefinitions: &apimodel.PolicyActionDefinition{},
 }
 
-func subscriptionHandler(stype models.SubscriptionType, params interface{}) (models.SubscriptionResult, error) {
+func subscriptionHandler(stype models.SubscriptionType, params interface{}) (models.SubscriptionResponse, error) {
 	switch stype {
 	case models.SubscriptionTypeReport:
 		p := params.(*models.ReportParams)
-		assert.Equal(suite, requestorId, *p.RequestorID)
-		assert.Equal(suite, direction, *p.EventTriggers[0].InterfaceDirection)
-		assert.Equal(suite, procedureCode, *p.EventTriggers[0].ProcedureCode)
-		assert.Equal(suite, typeOfMessage, *p.EventTriggers[0].TypeOfMessage)
-	case models.SubscriptionTypeControl:
-		p := params.(*models.ControlParams)
-		assert.Equal(suite, requestorId, p.RequestorID)
+		assert.Equal(suite, meid, p.Meid)
+		assert.Equal(suite, funId, *p.RANFunctionID)
+		assert.Equal(suite, clientEndpoint, *p.ClientEndpoint)
+		assert.Equal(suite, direction, p.EventTriggers[0].InterfaceDirection)
+		assert.Equal(suite, procedureCode, p.EventTriggers[0].ProcedureCode)
+		assert.Equal(suite, typeOfMessage, p.EventTriggers[0].TypeOfMessage)
 	case models.SubscriptionTypePolicy:
 		p := params.(*models.PolicyParams)
-		assert.Equal(suite, requestorId, p.RequestorID)
+		assert.Equal(suite, clientEndpoint, *p.ClientEndpoint)
 	}
 
-	return models.SubscriptionResult{11, 22, 33}, nil
+	subId := "xapp-11"
+	reqId := int64(11)
+	instanceId := int64(22)
+	return models.SubscriptionResponse{
+		&models.SubscriptionResponseItem{SubscriptionID: &subId, RequestorID: &reqId, InstanceID: &instanceId}, 
+		&models.SubscriptionResponseItem{SubscriptionID: &subId, RequestorID: &reqId, InstanceID: &instanceId},
+	}, nil
 }
 
 func queryHandler() (models.SubscriptionList, error) {
@@ -71,11 +86,17 @@
 	return resp, nil
 }
 
+func deleteHandler(ep string) error {
+	assert.Equal(suite, clientEndpoint, ep)
+
+	return nil
+}
+
 func TestSetup(t *testing.T) {
 	suite = t
 
 	// Start the server to simulate SubManager
-	go Subscription.Listen(subscriptionHandler, queryHandler)
+	go Subscription.Listen(subscriptionHandler, queryHandler, deleteHandler)
 	time.Sleep(time.Duration(2) * time.Second)
 }
 
@@ -92,24 +113,24 @@
 	result, err := Subscription.SubscribeReport(&reportParams)
 
 	assert.Equal(t, err, nil)
-	assert.Equal(t, len(result), 3)
-	assert.Equal(t, result[0], int64(11))
-	assert.Equal(t, result[1], int64(22))
-	assert.Equal(t, result[2], int64(33))
-}
-
-func TestSubscriptionControltHandling(t *testing.T) {
-	result, err := Subscription.SubscribeControl(&controlParams)
-
-	assert.Equal(t, err, nil)
-	assert.Equal(t, len(result), 3)
-	assert.Equal(t, result[0], int64(11))
+	assert.Equal(t, len(result), 2)
+	assert.Equal(t, *result[0].RequestorID, int64(11))
+	assert.Equal(t, *result[0].InstanceID, int64(22))
+	assert.Equal(t, *result[1].RequestorID, int64(11))
+	assert.Equal(t, *result[1].InstanceID, int64(22))
 }
 
 func TestSubscriptionPolicytHandling(t *testing.T) {
 	result, err := Subscription.SubscribePolicy(&policyParams)
 
 	assert.Equal(t, err, nil)
-	assert.Equal(t, len(result), 3)
-	assert.Equal(t, result[0], int64(11))
+	assert.Equal(t, len(result), 2)
+	assert.Equal(t, *result[0].RequestorID, int64(11))
+	assert.Equal(t, *result[0].InstanceID, int64(22))
 }
+
+func TestSubscriptionDeleteHandling(t *testing.T) {
+	err := Subscription.UnSubscribe(clientEndpoint)
+
+	assert.Equal(t, err, nil)
+}
\ No newline at end of file