+ __log_conf_fail_status_code 200 $status
+ return 1
+ fi
+
+ __log_conf_ok
+ return 0
+}
+
+# Send text to topic in mr-stub.
+# arg: <topic-url> <text-msg>
+# (Function for test scripts)
+mr_api_send_text() {
+ __log_conf_start $@
+ if [ $# -ne 2 ]; then
+ __print_err "<topic-url> <text-msg>" $@
+ return 1
+ fi
+ query=$1
+ fname=$PWD/tmp/text_payload_to_mr.txt
+ echo $2 > $fname
+ res="$(__do_curl_to_api MRSTUB POST $query $fname text/plain)"
+
+ status=${res:${#res}-3}
+ if [ $status -ne 200 ]; then
+ __log_conf_fail_status_code 200 $status
+ return 1
+ fi
+
+ __log_conf_ok
+ return 0
+}
+
+# Send json file to topic in mr-stub.
+# arg: <topic-url> <json-file>
+# (Function for test scripts)
+mr_api_send_json_file() {
+ __log_conf_start $@
+ if [ $# -ne 2 ]; then
+ __print_err "<topic-url> <json-file>" $@
+ return 1
+ fi
+ query=$1
+ if [ ! -f $2 ]; then
+ __log_test_fail_general "File $2 does not exist"
+ return 1
+ fi
+ #Create json array for mr
+ datafile="tmp/mr_api_send_json_file.json"
+ { echo -n "[" ; cat $2 ; echo -n "]" ;} > $datafile
+
+ res="$(__do_curl_to_api MRSTUB POST $query $datafile)"
+
+ status=${res:${#res}-3}
+ if [ $status -ne 200 ]; then
+ __log_conf_fail_status_code 200 $status
+ return 1
+ fi
+
+ __log_conf_ok
+ return 0
+}
+
+# Send text file to topic in mr-stub.
+# arg: <topic-url> <text-file>
+# (Function for test scripts)
+mr_api_send_text_file() {
+ __log_conf_start $@
+ if [ $# -ne 2 ]; then
+ __print_err "<topic-url> <text-file>" $@
+ return 1
+ fi
+ query=$1
+ if [ ! -f $2 ]; then
+ __log_test_fail_general "File $2 does not exist"
+ return 1
+ fi
+
+ res="$(__do_curl_to_api MRSTUB POST $query $2 text/plain)"
+
+ status=${res:${#res}-3}
+ if [ $status -ne 200 ]; then
+ __log_conf_fail_status_code 200 $status