+ __log_test_start $@
+
+ if [ "$PMS_VERSION" == "V2" ]; then
+ if [ $# -lt 8 ] || [ $# -gt 9 ]; then
+ __print_err "<response-code> <service-name> <ric-id> <policytype-id>|NOTYPE <policy-id> <transient>|NOTRANSIENT <notification-url>|NOURL <template-file> [<count>]" $@
+ return 1
+ fi
+ else
+ if [ $# -lt 7 ] || [ $# -gt 8 ]; then
+ __print_err "<response-code> <service-name> <ric-id> <policytype-id>|NOTYPE <policy-id> <transient>|NOTRANSIENT <template-file> [<count>]" $@
+ return 1
+ fi
+ fi
+
+ count=0
+ max=1
+ serv=$2
+ ric=$3
+ pt=$4
+ pid=$5
+ trans=$6
+
+ if [ "$PMS_VERSION" == "V2" ]; then
+ noti=$7
+ temp=$8
+ if [ $# -eq 9 ]; then
+ max=$9
+ fi
+ else
+ temp=$7
+ if [ $# -eq 8 ]; then
+ max=$8
+ fi
+ fi
+
+ while [ $count -lt $max ]; do
+ if [ "$PMS_VERSION" == "V2" ]; then
+
+ query="/v2/policies"
+
+ inputJson="\"ric_id\":\"$ric\",\"policy_id\":\"$UUID$pid\",\"service_id\":\"$serv\""
+ if [ $trans != "NOTRANSIENT" ]; then
+ inputJson=$inputJson", \"transient\":$trans"
+ fi
+ if [ $pt != "NOTYPE" ]; then
+ inputJson=$inputJson", \"policytype_id\":\"$pt\""
+ else
+ inputJson=$inputJson", \"policytype_id\":\"\""
+ fi
+ if [ $noti != "NOURL" ]; then
+ inputJson=$inputJson", \"status_notification_uri\":\"$noti\""
+ fi
+ file="./tmp/.p.json"
+ data=$(sed 's/XXX/'${pid}'/g' $temp)
+ inputJson=$inputJson", \"policy_data\":$data"
+ inputJson="{$inputJson}"
+ echo $inputJson > $file
+ else
+ query="/policy?id=$UUID$pid&ric=$ric&service=$serv"
+
+ if [ $pt != "NOTYPE" ]; then
+ query=$query"&type=$pt"
+ fi
+
+ if [ $trans != NOTRANSIENT ]; then
+ query=$query"&transient=$trans"
+ fi
+
+ file="./tmp/.p.json"
+ sed 's/XXX/'${pid}'/g' $temp > $file
+ fi
+ res="$(__do_curl_to_api PA PUT $query $file)"
+ status=${res:${#res}-3}
+ echo -ne " Executing "$count"("$max")${SAMELINE}"
+ if [ $status -ne $1 ]; then
+ echo " Executed "$count"?("$max")"
+ __log_test_fail_status_code $1 $status
+ return 1
+ fi
+
+ let pid=$pid+1
+ let count=$count+1
+ echo -ne " Executed "$count"("$max")${SAMELINE}"
+ done
+ echo ""
+
+ __log_test_pass
+ return 0
+}
+
+# API Test function: PUT /policy and V2 PUT /policies, to run in batch
+# args: <response-code> <service-name> <ric-id> <policytype-id>|NOTYPE <policy-id> <transient> <template-file> [<count>]
+# args(V2): <response-code> <service-name> <ric-id> <policytype-id>|NOTYPE <policy-id> <transient> <notification-url>|NOURL <template-file> [<count>]
+# (Function for test scripts)
+
+api_put_policy_batch() {
+ __log_test_start $@
+
+ if [ "$PMS_VERSION" == "V2" ]; then
+ if [ $# -lt 8 ] || [ $# -gt 9 ]; then
+ __print_err "<response-code> <service-name> <ric-id> <policytype-id>|NOTYPE <policy-id> <transient> <notification-url>|NOURL <template-file> [<count>]" $@
+ return 1
+ fi
+ else
+ if [ $# -lt 7 ] || [ $# -gt 8 ]; then
+ __print_err "<response-code> <service-name> <ric-id> <policytype-id>|NOTYPE <policy-id> <transient> <template-file> [<count>]" $@
+ return 1
+ fi
+ fi
+
+ count=0
+ max=1
+ serv=$2
+ ric=$3
+ pt=$4
+ pid=$5
+ trans=$6
+ if [ "$PMS_VERSION" == "V2" ]; then
+ noti=$7
+ temp=$8
+ if [ $# -eq 9 ]; then
+ max=$9
+ fi
+ else
+ temp=$7
+ if [ $# -eq 8 ]; then
+ max=$8
+ fi
+ fi
+
+ ARR=""
+ while [ $count -lt $max ]; do
+ if [ "$PMS_VERSION" == "V2" ]; then
+ query="/v2/policies"
+
+ inputJson="\"ric_id\":\"$ric\",\"policy_id\":\"$UUID$pid\",\"service_id\":\"$serv\""
+ if [ $trans != "NOTRANSIENT" ]; then
+ inputJson=$inputJson", \"transient\":$trans"
+ fi
+ if [ $pt != "NOTYPE" ]; then
+ inputJson=$inputJson", \"policytype_id\":\"$pt\""
+ else
+ inputJson=$inputJson", \"policytype_id\":\"\""
+ fi
+ if [ $noti != "NOURL" ]; then
+ inputJson=$inputJson", \"status_notification_uri\":\"$noti\""
+ fi
+ file="./tmp/.p.json"
+ data=$(sed 's/XXX/'${pid}'/g' $temp)
+ inputJson=$inputJson", \"policy_data\":$data"
+ inputJson="{$inputJson}"
+ echo $inputJson > $file
+ else
+ query="/policy?id=$UUID$pid&ric=$ric&service=$serv"
+
+ if [ $pt != "NOTYPE" ]; then
+ query=$query"&type=$pt"
+ fi
+
+ if [ $trans != NOTRANSIENT ]; then
+ query=$query"&transient=$trans"
+ fi
+ file="./tmp/.p.json"
+ sed 's/XXX/'${pid}'/g' $temp > $file
+ fi
+ res="$(__do_curl_to_api PA PUT_BATCH $query $file)"
+ status=${res:${#res}-3}
+ echo -ne " Requesting(batch) "$count"("$max")${SAMELINE}"
+
+ if [ $status -ne 200 ]; then
+ echo " Requested(batch) "$count"?("$max")"
+ __log_test_fail_status_code 200 $status
+ return 1
+ fi
+ cid=${res:0:${#res}-3}
+ ARR=$ARR" "$cid
+ let pid=$pid+1
+ let count=$count+1
+ echo -ne " Requested(batch) "$count"("$max")${SAMELINE}"
+ done
+
+ echo ""
+ count=0
+ for cid in $ARR; do
+
+ res="$(__do_curl_to_api PA RESPONSE $cid)"
+ status=${res:${#res}-3}
+ echo -ne " Accepting(batch) "$count"("$max")${SAMELINE}"
+
+ if [ $status -ne $1 ]; then
+ echo " Accepted(batch) "$count"?("$max")"
+ __log_test_fail_status_code $1 $status
+ return 1
+ fi
+
+ let count=$count+1
+ echo -ne " Accepted(batch) "$count"("$max")${SAMELINE}"
+ done
+
+ echo ""
+
+ __log_test_pass
+ return 0
+}