/*
 * Copyright (c) 2022  The AdvantEDGE Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package systemTest

import (
	"encoding/json"
	"fmt"
	"strconv"
	"testing"

	"context"
	"time"

	locServClient "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-loc-serv-client"
	log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger"
)

var locServAppClient *locServClient.APIClient
var locServServerUrl string

func init() {

	err := startSystemTest()
	if err != nil {
		log.Fatal("Cannot start system test")
	}
	//create client
	locServAppClientCfg := locServClient.NewConfiguration()
	if hostUrlStr == "" {
		hostUrlStr = "http://localhost"
	}

	locServAppClientCfg.BasePath = hostUrlStr + "/" + sandboxName + "/location/v2"

	locServAppClient = locServClient.NewAPIClient(locServAppClientCfg)
	if locServAppClient == nil {
		log.Error("Failed to create Location App REST API client: ", locServAppClientCfg.BasePath)
	}
	//NOTE: if localhost is set as the hostUrl, might not be reachable from the service, export MEEP_HOST_TEST_URL ="http://[yourhost]"
	locServServerUrl = hostUrlStr + ":" + httpListenerPort
}

func initialiseLocServTest() {
	log.Info("activating Scenario")
	err := activateScenario("loc-serv-system-test")
	if err != nil {
		log.Fatal("Scenario cannot be activated: ", err)
	}
	time.Sleep(1000 * time.Millisecond)
	if isAutomationReady(true, 10, 0) {
		geAutomationUpdate(true, false, true, true)
	}
}

func clearUpLocServTest() {
	log.Info("terminating Scenario")
	terminateScenario()
	time.Sleep(1000 * time.Millisecond)
}

//no really a test, but loading the scenarios needed that will be used in the following tests
//deletion of those scenarios at the end
func Test_loc_serv_load_scenarios(t *testing.T) {

	// no override if the name is already in the DB.. security not to override something important
	err := createScenario("loc-serv-system-test", "loc-serv-system-test.yaml")
	if err != nil {
		t.Fatal("Cannot create scenario, keeping the one already there and continuing testing with it :", err)
	}
}

func Test_periodic_success(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	referenceAddress := []string{"ue1"}
	frequency := int32(1)
	//don't care about initial position
	geMoveAssetCoordinates(referenceAddress[0], 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionPeriodic(referenceAddress, locServServerUrl, frequency)
	if err != nil {
		t.Fatal("Subscription failed: ", err)
	}

	//wait to receive few notifications
	time.Sleep(2500 * time.Millisecond)

	//only check the first one, the same one is repeated every second
	//hard to say if the period should cover 2 or 3 response... based on the timer timing
	if len(httpReqBody) == 2 || len(httpReqBody) == 3 {
		var body locServClient.InlineSubscriptionNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validatePeriodicSubscriptionNotification(body.SubscriptionNotification, referenceAddress[0])
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_all_within_distance_success(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	monitoredAddress := []string{"ue1", "ue2"}
	referenceAddress := []string{"ue3"}
	criteria := locServClient.ALL_WITHIN_DISTANCE_DistanceCriteria
	distance := float32(200.0)

	//moving to initial position
	geMoveAssetCoordinates(monitoredAddress[0], 7.413917, 43.733505)
	geMoveAssetCoordinates(monitoredAddress[1], 7.414917, 43.733505)
	geMoveAssetCoordinates(referenceAddress[0], 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionDistance(monitoredAddress, referenceAddress, &criteria, distance, locServServerUrl, false)
	if err != nil {
		t.Fatal("Subscription failed: ", err)
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(referenceAddress[0], 7.415917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//only check the first one, the same one is repeated every second
	if len(httpReqBody) >= 1 {
		var body locServClient.InlineSubscriptionNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr1 := validateDistanceSubscriptionNotification(body.SubscriptionNotification, monitoredAddress[0])
		errStr2 := validateDistanceSubscriptionNotification(body.SubscriptionNotification, monitoredAddress[1])
		if errStr1 != "" && errStr2 != "" {
			printHttpReqBody()
			t.Fatalf(errStr1 + "---" + errStr2)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_all_within_distance_fail(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	monitoredAddress := []string{"ue1", "ue2"}
	referenceAddress := []string{"ue3"}
	criteria := locServClient.ALL_WITHIN_DISTANCE_DistanceCriteria
	distance := float32(100.0)

	//moving to initial position
	geMoveAssetCoordinates(monitoredAddress[0], 7.413917, 43.733505)
	geMoveAssetCoordinates(monitoredAddress[1], 7.414917, 43.733505)
	geMoveAssetCoordinates(referenceAddress[0], 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionDistance(monitoredAddress, referenceAddress, &criteria, distance, locServServerUrl, false)
	if err != nil {
		t.Fatal("Subscription failed: ", err)
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(referenceAddress[0], 7.415917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}
}

func Test_any_within_distance_success(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	monitoredAddress := []string{"ue1", "ue2"}
	referenceAddress := []string{"ue3"}
	criteria := locServClient.ANY_WITHIN_DISTANCE_DistanceCriteria
	distance := float32(100.0)

	//moving to initial position
	geMoveAssetCoordinates(monitoredAddress[0], 7.413917, 43.733505)
	geMoveAssetCoordinates(monitoredAddress[1], 7.414917, 43.733505)
	geMoveAssetCoordinates(referenceAddress[0], 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionDistance(monitoredAddress, referenceAddress, &criteria, distance, locServServerUrl, false)
	if err != nil {
		t.Fatal("Subscription failed: ", err)
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(referenceAddress[0], 7.415917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//only check the first one, the same one is repeated every second
	if len(httpReqBody) >= 1 {
		var body locServClient.InlineSubscriptionNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateDistanceSubscriptionNotification(body.SubscriptionNotification, monitoredAddress[1])
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_any_within_distance_fail(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	monitoredAddress := []string{"ue1", "ue2"}
	referenceAddress := []string{"ue3"}
	criteria := locServClient.ANY_WITHIN_DISTANCE_DistanceCriteria
	distance := float32(10.0)

	//moving to initial position
	geMoveAssetCoordinates(monitoredAddress[0], 7.413917, 43.733505)
	geMoveAssetCoordinates(monitoredAddress[1], 7.414917, 43.733505)
	geMoveAssetCoordinates(referenceAddress[0], 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionDistance(monitoredAddress, referenceAddress, &criteria, distance, locServServerUrl, false)
	if err != nil {
		t.Fatal("Subscription failed: ", err)
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(referenceAddress[0], 7.415917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}
}

func Test_all_beyond_distance_success(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	monitoredAddress := []string{"ue1", "ue2"}
	referenceAddress := []string{"ue3"}
	criteria := locServClient.ALL_BEYOND_DISTANCE_DistanceCriteria
	distance := float32(20.0)

	//moving to initial position
	geMoveAssetCoordinates(monitoredAddress[0], 7.413917, 43.733505)
	geMoveAssetCoordinates(monitoredAddress[1], 7.414917, 43.733505)
	geMoveAssetCoordinates(referenceAddress[0], 7.414917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionDistance(monitoredAddress, referenceAddress, &criteria, distance, locServServerUrl, false)
	if err != nil {
		t.Fatal("Subscription failed: ", err)
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(referenceAddress[0], 7.415917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//only check the first one, the same one is repeated every second
	if len(httpReqBody) >= 1 {
		var body locServClient.InlineSubscriptionNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		//will be one or the other depending on the order they were processed
		errStr1 := validateDistanceSubscriptionNotification(body.SubscriptionNotification, monitoredAddress[0])
		errStr2 := validateDistanceSubscriptionNotification(body.SubscriptionNotification, monitoredAddress[1])
		if errStr1 != "" && errStr2 != "" {
			printHttpReqBody()
			t.Fatalf(errStr1 + "---" + errStr2)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_all_beyond_distance_fail(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	monitoredAddress := []string{"ue1", "ue2"}
	referenceAddress := []string{"ue3"}
	criteria := locServClient.ALL_BEYOND_DISTANCE_DistanceCriteria
	distance := float32(100.0)

	//moving to initial position
	geMoveAssetCoordinates(monitoredAddress[0], 7.413917, 43.733505)
	geMoveAssetCoordinates(monitoredAddress[1], 7.414917, 43.733505)
	geMoveAssetCoordinates(referenceAddress[0], 7.414917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionDistance(monitoredAddress, referenceAddress, &criteria, distance, locServServerUrl, false)
	if err != nil {
		t.Fatal("Subscription failed: ", err)
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(referenceAddress[0], 7.415917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}
}

func Test_any_beyond_distance_success(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	monitoredAddress := []string{"ue1", "ue2"}
	referenceAddress := []string{"ue3"}
	criteria := locServClient.ANY_BEYOND_DISTANCE_DistanceCriteria
	distance := float32(100.0)

	//moving to initial position
	geMoveAssetCoordinates(monitoredAddress[0], 7.413917, 43.733505)
	geMoveAssetCoordinates(monitoredAddress[1], 7.414917, 43.733505)
	geMoveAssetCoordinates(referenceAddress[0], 7.414917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionDistance(monitoredAddress, referenceAddress, &criteria, distance, locServServerUrl, false)
	if err != nil {
		t.Fatal("Subscription failed: ", err)
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(referenceAddress[0], 7.415917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//only check the first one, the same one is repeated every second
	if len(httpReqBody) >= 1 {
		var body locServClient.InlineSubscriptionNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateDistanceSubscriptionNotification(body.SubscriptionNotification, monitoredAddress[0])
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_any_beyond_distance_fail(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	monitoredAddress := []string{"ue1", "ue2"}
	referenceAddress := []string{"ue3"}
	criteria := locServClient.ANY_BEYOND_DISTANCE_DistanceCriteria
	distance := float32(200.0)

	//moving to initial position
	geMoveAssetCoordinates(monitoredAddress[0], 7.413917, 43.733505)
	geMoveAssetCoordinates(monitoredAddress[1], 7.414917, 43.733505)
	geMoveAssetCoordinates(referenceAddress[0], 7.414917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionDistance(monitoredAddress, referenceAddress, &criteria, distance, locServServerUrl, false)
	if err != nil {
		t.Fatal("Subscription failed: ", err)
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(referenceAddress[0], 7.415917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}
}

func Test_leaving_area_areaCircle_success(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := []string{"ue1"}
	criteria := locServClient.LEAVING_EnteringLeavingCriteria
	latitude := float32(43.733505)
	longitude := float32(7.414917)
	radius := float32(100.0)

	//moving to initial position
	geMoveAssetCoordinates(testAddress[0], 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionAreaCircle(testAddress, &criteria, latitude, longitude, radius, locServServerUrl, false)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset in")
	geMoveAssetCoordinates(testAddress[0], 7.414917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	log.Info("moving asset out")
	geMoveAssetCoordinates(testAddress[0], 7.484917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineSubscriptionNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateCircleSubscriptionNotification(body.SubscriptionNotification, testAddress[0])
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_leaving_area_areaCircle_fail(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := []string{"ue1"}
	criteria := locServClient.LEAVING_EnteringLeavingCriteria
	latitude := float32(43.733505)
	longitude := float32(7.414917)
	radius := float32(100.0)

	//moving to initial position
	geMoveAssetCoordinates(testAddress[0], 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionAreaCircle(testAddress, &criteria, latitude, longitude, radius, locServServerUrl, false)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset in")
	geMoveAssetCoordinates(testAddress[0], 7.414917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	log.Info("moving asset still in")
	geMoveAssetCoordinates(testAddress[0], 7.414927, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}
}

func Test_entering_area_areaCircle_success(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := []string{"ue1"}
	criteria := locServClient.ENTERING_EnteringLeavingCriteria
	latitude := float32(43.733505)
	longitude := float32(7.414917)
	radius := float32(100.0)

	//moving to initial position
	geMoveAssetCoordinates(testAddress[0], 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionAreaCircle(testAddress, &criteria, latitude, longitude, radius, locServServerUrl, false)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress[0], 7.414917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineSubscriptionNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateCircleSubscriptionNotification(body.SubscriptionNotification, testAddress[0])
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_entering_area_areaCircle_fail(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := []string{"ue1"}
	criteria := locServClient.ENTERING_EnteringLeavingCriteria
	latitude := float32(43.733505)
	longitude := float32(7.414917)
	radius := float32(50.0)

	//moving to initial position
	geMoveAssetCoordinates(testAddress[0], 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionAreaCircle(testAddress, &criteria, latitude, longitude, radius, locServServerUrl, false)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress[0], 8.414917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}
}

func Test_4g_to_4g_same_zone_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatal("Subscription failed: ", err)
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.415917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa-4g2", "poa-4g1", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_4g_to_4g_diff_zone_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.417917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 2 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa-4g1", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

		err = json.Unmarshal([]byte(httpReqBody[1]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr = validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone2", "poa-4g3", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_4g_to_5g_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.411917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa-5g1", "poa-4g1", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_4g_to_wifi_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.413917, 43.735005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa-wifi1", "poa-4g1", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_4g_to_generic_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.413917, 43.732005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa1", "poa-4g1", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_4g_to_none_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa-4g1", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_5g_same_zone_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.421917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone2", "poa-5g3", "poa-5g2", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_5g_diff_zone_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.423917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 2 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone2", "poa-5g2", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

		err = json.Unmarshal([]byte(httpReqBody[1]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr = validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone3", "poa-5g4", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_4g_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.417917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone2", "poa-4g3", "poa-5g2", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_wifi_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.419917, 43.735005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone2", "poa-wifi2", "poa-5g2", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_generic_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.419917, 43.732005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone2", "poa2", "poa-5g2", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_none_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone2", "poa-5g2", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_wifi_same_zone_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.427917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone3", "poa-wifi4", "poa-wifi3", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_wifi_diff_zone_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.429917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 2 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone3", "poa-wifi3", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

		err = json.Unmarshal([]byte(httpReqBody[1]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr = validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone4", "poa-wifi5", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_5g_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.423917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone3", "poa-5g4", "poa-wifi3", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_4g_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.425917, 43.735005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone3", "poa-4g4", "poa-wifi3", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_generic_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.425917, 43.732005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone3", "poa3", "poa-wifi3", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_none_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone3", "poa-wifi3", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_generic_same_zone_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.433917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone4", "poa5", "poa4", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_generic_diff_zone_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.435917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 2 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone4", "poa4", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

		err = json.Unmarshal([]byte(httpReqBody[1]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr = validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone5", "poa6", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_wifi_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.429917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone4", "poa-wifi5", "poa4", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_4g_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.431917, 43.735005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone4", "poa-4g5", "poa4", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_5g_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.431917, 43.732005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone4", "poa-5g5", "poa4", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_none_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone4", "poa4", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_none_to_4g_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa-4g1", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_none_to_5g_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.411917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa-5g1", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_none_to_wifi_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.413917, 43.735005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa-wifi1", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_none_to_generic_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.413917, 43.732005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa1", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_none_to_none_userTracking(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionUserTracking(testAddress, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 1.0, 1.0)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}
}

func Test_4g_to_4g_same_zone_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.415917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-4g2", "poa-4g1", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_4g_to_4g_diff_zone_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.417917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-4g1", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_4g_to_5g_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.411917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-5g1", "poa-4g1", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_4g_to_wifi_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.413917, 43.735005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-wifi1", "poa-4g1", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_4g_to_generic_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.413917, 43.732005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa1", "poa-4g1", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_4g_to_none_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-4g1", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_5g_same_zone_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone2"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.421917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-5g3", "poa-5g2", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_5g_diff_zone_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone2"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.423917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-5g2", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_4g_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone2"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.417917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-4g3", "poa-5g2", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_wifi_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone2"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.419917, 43.735005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-wifi2", "poa-5g2", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_generic_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone2"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.419917, 43.732005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa2", "poa-5g2", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_5g_to_none_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone2"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-5g2", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_wifi_same_zone_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone3"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)

	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.427917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-wifi4", "poa-wifi3", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_wifi_diff_zone_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone3"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.429917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-wifi3", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_5g_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone3"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.423917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-5g4", "poa-wifi3", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_4g_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone3"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.425917, 43.735005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-4g4", "poa-wifi3", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_generic_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone3"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.425917, 43.732005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa3", "poa-wifi3", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_wifi_to_none_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone3"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-wifi3", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_generic_same_zone_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone4"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.433917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa5", "poa4", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_generic_diff_zone_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone4"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.435917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa4", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_wifi_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone4"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.429917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-wifi5", "poa4", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_4g_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone4"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.431917, 43.735005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-4g5", "poa4", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_5g_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone4"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.431917, 43.732005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa-5g5", "poa4", "Transferring")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_generic_to_none_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone4"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, testZoneId, "poa4", "", "Leaving")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_none_to_4g_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa-4g1", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_none_to_5g_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.411917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa-5g1", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_none_to_wifi_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.413917, 43.735005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa-wifi1", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_none_to_generic_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 7.413917, 43.732005)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) == 1 {
		var body locServClient.InlineZonalPresenceNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZonalPresenceNotification(body.ZonalPresenceNotification, testAddress, "zone1", "poa1", "", "Entering")
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

func Test_none_to_none_zonalTraffic(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testAddress := "ue1"
	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates(testAddress, 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZonalTraffic(testZoneId, locServServerUrl)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates(testAddress, 1.0, 1.0)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}
}

func Test_zoneStatus_4g_AP_threshold(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates("ue1", 0.0, 0.0)
	geMoveAssetCoordinates("ue2", 0.0, 0.0)
	geMoveAssetCoordinates("ue3", 0.0, 0.0)
	geMoveAssetCoordinates("ue4", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZoneStatus(testZoneId, locServServerUrl, 2, 5)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates("ue1", 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue2", 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being equal to AP threshold
	if len(httpReqBody) == 1 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-4g1", 2, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue3", 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being greater than AP threshold
	if len(httpReqBody) == 2 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[1]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-4g1", 3, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue3", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being equal to AP threshold
	if len(httpReqBody) == 3 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[2]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-4g1", 2, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue4", 7.415917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification not received, no change to poa that has equal value to threshold
	if len(httpReqBody) != 3 {
		t.Fatalf("Notification received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue1", 0.0, 0.0)
	geMoveAssetCoordinates("ue2", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//notification not received, values below AP threshold
	if len(httpReqBody) != 3 {
		t.Fatalf("Notification received")
	}
}

func Test_zoneStatus_5g_AP_threshold(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testZoneId := "zone2"

	//moving to initial position
	geMoveAssetCoordinates("ue1", 0.0, 0.0)
	geMoveAssetCoordinates("ue2", 0.0, 0.0)
	geMoveAssetCoordinates("ue3", 0.0, 0.0)
	geMoveAssetCoordinates("ue4", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZoneStatus(testZoneId, locServServerUrl, 2, 5)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates("ue1", 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue2", 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being equal to AP threshold
	if len(httpReqBody) == 1 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-5g2", 2, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue3", 7.419917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being greater than AP threshold
	if len(httpReqBody) == 2 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[1]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-5g2", 3, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue3", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being equal to AP threshold
	if len(httpReqBody) == 3 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[2]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-5g2", 2, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue4", 7.421917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification not received, no change to poa that has equal value to threshold
	if len(httpReqBody) != 3 {
		t.Fatalf("Notification received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue1", 0.0, 0.0)
	geMoveAssetCoordinates("ue2", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//notification not received, values below AP threshold
	if len(httpReqBody) != 3 {
		t.Fatalf("Notification received")
	}
}

func Test_zoneStatus_wifi_AP_threshold(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testZoneId := "zone3"

	//moving to initial position
	geMoveAssetCoordinates("ue1", 0.0, 0.0)
	geMoveAssetCoordinates("ue2", 0.0, 0.0)
	geMoveAssetCoordinates("ue3", 0.0, 0.0)
	geMoveAssetCoordinates("ue4", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZoneStatus(testZoneId, locServServerUrl, 2, 5)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates("ue1", 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue2", 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being equal to AP threshold
	if len(httpReqBody) == 1 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-wifi3", 2, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue3", 7.425917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being greater than AP threshold
	if len(httpReqBody) == 2 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[1]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-wifi3", 3, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue3", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being equal to AP threshold
	if len(httpReqBody) == 3 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[2]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-wifi3", 2, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue4", 7.427917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification not received, no change to poa that has equal value to threshold
	if len(httpReqBody) != 3 {
		t.Fatalf("Notification received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue1", 0.0, 0.0)
	geMoveAssetCoordinates("ue2", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//notification not received, values below AP threshold
	if len(httpReqBody) != 3 {
		t.Fatalf("Notification received")
	}
}

func Test_zoneStatus_generic_AP_threshold(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testZoneId := "zone4"

	//moving to initial position
	geMoveAssetCoordinates("ue1", 0.0, 0.0)
	geMoveAssetCoordinates("ue2", 0.0, 0.0)
	geMoveAssetCoordinates("ue3", 0.0, 0.0)
	geMoveAssetCoordinates("ue4", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZoneStatus(testZoneId, locServServerUrl, 2, 5)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	geMoveAssetCoordinates("ue1", 7.431917, 43.733505)

	time.Sleep(2000 * time.Millisecond)

	if len(httpReqBody) >= 1 {
		printHttpReqBody()
		t.Fatalf("Notification received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue2", 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being equal to AP threshold
	if len(httpReqBody) == 1 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa4", 2, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue3", 7.431917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being greater than AP threshold
	if len(httpReqBody) == 2 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[1]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa4", 3, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue3", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being equal to AP threshold
	if len(httpReqBody) == 3 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[2]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa4", 2, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue4", 7.433917, 43.733505)
	time.Sleep(2000 * time.Millisecond)

	//notification not received, no change to poa that has equal value to threshold
	if len(httpReqBody) != 3 {
		t.Fatalf("Notification received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue1", 0.0, 0.0)
	geMoveAssetCoordinates("ue2", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//notification not received, values below AP threshold
	if len(httpReqBody) != 3 {
		t.Fatalf("Notification received")
	}
}

func Test_zoneStatus_zone_threshold(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates("ue1", 0.0, 0.0)
	geMoveAssetCoordinates("ue2", 0.0, 0.0)
	geMoveAssetCoordinates("ue3", 0.0, 0.0)
	geMoveAssetCoordinates("ue4", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZoneStatus(testZoneId, locServServerUrl, 2, 3)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	//moving to each different type of POA
	geMoveAssetCoordinates("ue1", 7.413917, 43.733505)
	geMoveAssetCoordinates("ue2", 7.411917, 43.733505)
	geMoveAssetCoordinates("ue3", 7.413917, 43.735005)
	geMoveAssetCoordinates("ue4", 7.413917, 43.732005)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being greater to zone threshold
	if len(httpReqBody) == 1 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "", -1, 4)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue4", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being equal to zone threshold
	if len(httpReqBody) == 2 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[1]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "", -1, 3)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}
	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}

	log.Info("moving asset")
	geMoveAssetCoordinates("ue1", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//notification not received, values below zone threshold
	if len(httpReqBody) != 2 {
		t.Fatalf("Notification received")
	}
}

func Test_zoneStatus_zone_AP_threshold(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

	initialiseLocServTest()
	defer clearUpLocServTest()

	testZoneId := "zone1"

	//moving to initial position
	geMoveAssetCoordinates("ue1", 0.0, 0.0)
	geMoveAssetCoordinates("ue2", 0.0, 0.0)
	geMoveAssetCoordinates("ue3", 0.0, 0.0)
	geMoveAssetCoordinates("ue4", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//subscription to test
	err := locServSubscriptionZoneStatus(testZoneId, locServServerUrl, 2, 3)
	if err != nil {
		t.Fatalf("Subscription failed")
	}

	//wait to make sure the subscription got registered
	time.Sleep(1500 * time.Millisecond)

	log.Info("moving asset")
	//moving to one POA and triggering a AP threshold, so 1 notification for AP threshold
	geMoveAssetCoordinates("ue1", 7.413917, 43.733505)
	geMoveAssetCoordinates("ue2", 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)
	//moving to same POA and triggering a AP and zone thresholds, so 1 notification for AP threshold, and 1 for zone threshold
	geMoveAssetCoordinates("ue3", 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)
	//moving to same POA and triggering a AP and zone thresholds, so 1 notification for AP threshold, and 1 for zone threshold
	geMoveAssetCoordinates("ue4", 7.413917, 43.733505)
	time.Sleep(2000 * time.Millisecond)
	//removing one ue from same POA and triggering a AP and zone thresholds, so 1 notification for AP threshold, and 1 for zone threshold
	geMoveAssetCoordinates("ue4", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)
	//removing one ue from same POA and triggering a AP threshold only, so 1 notification for AP threshold
	geMoveAssetCoordinates("ue3", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)
	//removing one ue from same POA and triggering no threshold
	geMoveAssetCoordinates("ue2", 0.0, 0.0)
	time.Sleep(2000 * time.Millisecond)

	//notification received for being greater to zone threshold
	if len(httpReqBody) == 8 {
		var body locServClient.InlineZoneStatusNotification
		err = json.Unmarshal([]byte(httpReqBody[0]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr := validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-4g1", 2, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

		err = json.Unmarshal([]byte(httpReqBody[1]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr = validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-4g1", 3, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

		err = json.Unmarshal([]byte(httpReqBody[2]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr = validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "", -1, 3)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

		err = json.Unmarshal([]byte(httpReqBody[3]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr = validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-4g1", 4, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

		err = json.Unmarshal([]byte(httpReqBody[4]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr = validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "", -1, 4)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

		err = json.Unmarshal([]byte(httpReqBody[5]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr = validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-4g1", 3, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

		err = json.Unmarshal([]byte(httpReqBody[6]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr = validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "", -1, 3)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

		err = json.Unmarshal([]byte(httpReqBody[7]), &body)
		if err != nil {
			t.Fatalf("cannot unmarshall response")
		}
		errStr = validateZoneStatusNotification(body.ZoneStatusNotification, testZoneId, "poa-4g1", 2, -1)
		if errStr != "" {
			printHttpReqBody()
			t.Fatalf(errStr)
		}

	} else {
		printHttpReqBody()
		t.Fatalf("Number of expected notifications not received")
	}
}

//not a real test, just the last test that stops the system test environment
func Test_loc_serv_stopSystemTest(t *testing.T) {
	err := deleteScenario("loc-serv-system-test")
	if err != nil {
		t.Fatal("cannot delete scenario :", err)
	}

	//call to stopSystemTest done outside in case other test cases are running
	//stopSystemTest()
}

func locServSubscriptionUserTracking(address string, callbackReference string) error {

	userTrackingSubscription := locServClient.UserTrackingSubscription{address, &locServClient.CallbackReference{"", nil, callbackReference}, "", "", nil}
	inlineUserTrackingSubscription := locServClient.InlineUserTrackingSubscription{&userTrackingSubscription}

	_, _, err := locServAppClient.LocationApi.UserTrackingSubPOST(context.TODO(), inlineUserTrackingSubscription)
	if err != nil {
		log.Error("Failed to send subscription: ", err)
		return err
	}

	return nil
}

func locServSubscriptionZonalTraffic(zoneId string, callbackReference string) error {

	zonalTrafficSubscription := locServClient.ZonalTrafficSubscription{&locServClient.CallbackReference{"", nil, callbackReference}, "", 0, nil, "", nil, zoneId}
	inlineZonalTrafficSubscription := locServClient.InlineZonalTrafficSubscription{&zonalTrafficSubscription}

	_, _, err := locServAppClient.LocationApi.ZonalTrafficSubPOST(context.TODO(), inlineZonalTrafficSubscription)
	if err != nil {
		log.Error("Failed to send subscription: ", err)
		return err
	}

	return nil
}

func locServSubscriptionZoneStatus(zoneId string, callbackReference string, nbApThreshold int32, nbZoneThreshold int32) error {

	zoneStatusSubscription := locServClient.ZoneStatusSubscription{&locServClient.CallbackReference{"", nil, callbackReference}, "", nbApThreshold, nbZoneThreshold, nil, "", zoneId}
	inlineZoneStatusSubscription := locServClient.InlineZoneStatusSubscription{&zoneStatusSubscription}

	_, _, err := locServAppClient.LocationApi.ZoneStatusSubPOST(context.TODO(), inlineZoneStatusSubscription)
	if err != nil {
		log.Error("Failed to send subscription: ", err)
		return err
	}

	return nil
}

func locServSubscriptionDistance(monitoredAddress []string, referenceAddress []string, criteria *locServClient.DistanceCriteria, distance float32, callbackReference string, checkImmediate bool) error {

	distanceSubscription := locServClient.DistanceNotificationSubscription{&locServClient.CallbackReference{"", nil, callbackReference}, checkImmediate, "", 0, criteria, distance, 0, 1, nil, monitoredAddress, referenceAddress, "", "", 1}
	inlineDistanceNotificationSubscription := locServClient.InlineDistanceNotificationSubscription{&distanceSubscription}

	_, _, err := locServAppClient.LocationApi.DistanceSubPOST(context.TODO(), inlineDistanceNotificationSubscription)
	if err != nil {
		log.Error("Failed to send subscription: ", err)
		return err
	}

	return nil
}

func locServSubscriptionAreaCircle(address []string, criteria *locServClient.EnteringLeavingCriteria, latitude float32, longitude float32, radius float32, callbackReference string, checkImmediate bool) error {

	areaCircleSubscription := locServClient.CircleNotificationSubscription{address, &locServClient.CallbackReference{"", nil, callbackReference}, checkImmediate, "", 0, 0, criteria, 1, latitude, nil, longitude, radius, "", "", 1}
	inlineCircleNotificationSubscription := locServClient.InlineCircleNotificationSubscription{&areaCircleSubscription}

	_, _, err := locServAppClient.LocationApi.AreaCircleSubPOST(context.TODO(), inlineCircleNotificationSubscription)
	if err != nil {
		log.Error("Failed to send subscription: ", err)
		return err
	}

	return nil
}

func locServSubscriptionPeriodic(referenceAddress []string, callbackReference string, frequency int32) error {

	periodicSubscription := locServClient.PeriodicNotificationSubscription{referenceAddress, &locServClient.CallbackReference{"", nil, callbackReference}, "", 0, frequency, nil, 1, "", ""}
	inlinePeriodicNotificationSubscription := locServClient.InlinePeriodicNotificationSubscription{&periodicSubscription}

	_, _, err := locServAppClient.LocationApi.PeriodicSubPOST(context.TODO(), inlinePeriodicNotificationSubscription)
	if err != nil {
		log.Error("Failed to send subscription: ", err)
		return err
	}

	return nil
}

func validateZonalPresenceNotification(zonalPresenceNotification *locServClient.ZonalPresenceNotification, expectedAddress string, expectedZoneId string, expectedCurrentAccessPointId string, expectedPreviousAccessPointId string, expectedUserEventType locServClient.UserEventType) string {

	if zonalPresenceNotification.Address != expectedAddress {
		return ("Address of notification not as expected: " + zonalPresenceNotification.Address + " instead of " + expectedAddress)
	}
	if zonalPresenceNotification.ZoneId != expectedZoneId {
		return ("ZoneId of notification not as expected: " + zonalPresenceNotification.ZoneId + " instead of " + expectedZoneId)
	}
	if zonalPresenceNotification.CurrentAccessPointId != expectedCurrentAccessPointId {
		return ("CurrentAccessPointId of notification not as expected: " + zonalPresenceNotification.CurrentAccessPointId + " instead of " + expectedCurrentAccessPointId)
	}
	if zonalPresenceNotification.PreviousAccessPointId != expectedPreviousAccessPointId {
		return ("PreviousAccessPointId of notification not as expected: " + zonalPresenceNotification.PreviousAccessPointId + " instead of " + expectedPreviousAccessPointId)
	}
	if *zonalPresenceNotification.UserEventType != expectedUserEventType {
		return ("UserEventType of notification not as expected: " + string(*zonalPresenceNotification.UserEventType) + " instead of " + string(expectedUserEventType))
	}
	return ""
}

func validateZoneStatusNotification(zoneStatusNotification *locServClient.ZoneStatusNotification, expectedZoneId string, expectedApId string, expectedNbUsersInAP int32, expectedNbUsersInZone int32) string {

	if zoneStatusNotification.ZoneId != expectedZoneId {
		return ("ZoneId of notification not as expected: " + zoneStatusNotification.ZoneId + " instead of " + expectedZoneId)
	}

	if expectedNbUsersInZone != -1 {
		if zoneStatusNotification.NumberOfUsersInZone != expectedNbUsersInZone {
			return ("NumberOfUsersInZone of notification not as expected: " + strconv.Itoa(int(zoneStatusNotification.NumberOfUsersInZone)) + " instead of " + strconv.Itoa(int(expectedNbUsersInZone)))
		}
	}
	if expectedNbUsersInAP != -1 {
		if zoneStatusNotification.NumberOfUsersInAP != expectedNbUsersInAP {
			return ("NumberOfUsersInAP of notification not as expected: " + strconv.Itoa(int(zoneStatusNotification.NumberOfUsersInAP)) + " instead of " + strconv.Itoa(int(expectedNbUsersInAP)))
		}
		if zoneStatusNotification.AccessPointId != expectedApId {
			return ("AccessPointId of notification not as expected: " + zoneStatusNotification.AccessPointId + " instead of " + expectedApId)
		}
	}
	return ""
}

func validateDistanceSubscriptionNotification(subscriptionNotification *locServClient.SubscriptionNotification, expectedTerminalAddress string) string {

	if subscriptionNotification.TerminalLocation[0].Address != expectedTerminalAddress {
		return ("Terminal location address of notification not as expected: " + subscriptionNotification.TerminalLocation[0].Address + " instead of " + expectedTerminalAddress)
	}

	return ""
}

func validateCircleSubscriptionNotification(subscriptionNotification *locServClient.SubscriptionNotification, expectedTerminalAddress string) string {

	if subscriptionNotification.TerminalLocation[0].Address != expectedTerminalAddress {
		return ("Terminal location address of notification not as expected: " + subscriptionNotification.TerminalLocation[0].Address + " instead of " + expectedTerminalAddress)
	}

	return ""
}

func validatePeriodicSubscriptionNotification(subscriptionNotification *locServClient.SubscriptionNotification, expectedTerminalAddress string) string {

	if subscriptionNotification.TerminalLocation[0].Address != expectedTerminalAddress {
		return ("Terminal location address of notification not as expected: " + subscriptionNotification.TerminalLocation[0].Address + " instead of " + expectedTerminalAddress)
	}

	return ""
}
