V2XInformationServiceAPI_Functions.ttcn 26.5 KB
Newer Older
YannGarcia's avatar
YannGarcia committed
/**
 *    @author   ETSI / TTF T012
YannGarcia's avatar
YannGarcia committed
 *    @version  $URL$
 *              $ID:$
 *    @desc     This module provides the custom templates for ITS HTTP based protocols.
 *    @copyright   ETSI Copyright Notification
 *                 No part may be reproduced except as authorized by written permission.
 *                 The copyright and the foregoing restriction extend to reproduction in all media.
 *                 All rights reserved.
 */
module V2XInformationServiceAPI_Functions {
  
  // JSON
  import from JSON all;
  
  // LibCommon
  import from LibCommon_BasicTypesAndValues all;
  import from LibCommon_Time all;
  import from LibCommon_VerdictControl all;
  import from LibCommon_Sync all;

  // LibHttp
  import from LibItsHttp_TypesAndValues all;
  import from LibItsHttp_Functions all;
  import from LibItsHttp_Templates all;
  import from LibItsHttp_JsonTemplates all;
  import from LibItsHttp_TestSystem all;

  // LibMec/V2XInformationServiceAPI
  import from V2XInformationServiceAPI_TypesAndValues all;
  import from V2XInformationServiceAPI_Templates all;
  import from V2XInformationServiceAPI_Pixits all;

  // LibMec
  import from LibMec_Templates all;
  import from LibMec_Functions all;
  import from LibMec_Pics all;
  import from LibMec_Pixits all;

  function f_create_prov_uu_uni_subscription(
                                             out ProvChgUuUniSubscription p_prov_chg_uu_uni_subscription
                                             ) runs on HttpComponent {
YannGarcia's avatar
YannGarcia committed
    var Headers v_headers;
    var HttpMessage v_response;

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_post(
                                                     PICS_ROOT_API & PX_ME_V2X_URI & "/subscriptions/prov_chg_uu_uni",
YannGarcia's avatar
YannGarcia committed
                                                     v_headers,
                                                     m_http_message_body_json(
                                                                              m_body_json_prov_chg_uu_uni_subscription(
                                                                                                                       m_prov_chg_uu_uni_subscription(
                                                                                                                                                      PX_PROV_UU_UNI_SUB_CALLBACK,
                                                                                                                                                      m_prov_chg_uu_uni_filter_criteria(
                                                                                                                                                                                        m_location_info(
                                                                                                                                                                                                        m_ecgi(
                                                                                                                                                                                                               PX_CELL_ID,m_plmn(PX_MCC, PX_MNC)
                                                                                                                                                                                                               ),
                                                                                                                                                                                                        m_location_info_geo_area(
                                                                                                                                                                                                                                 43.72,
                                                                                                                                                                                                                                 10.41
                                                                                                                                                                                                                                 )),
                                                                                                                                                                                        m_v2x_application_server(
                                                                                                                                                                                                                 oct2char(unichar2oct(PX_V2X_SERVER_IP_ADDRESS, "UTF-8")),
                                                                                                                                                                                                                 oct2char(unichar2oct(PX_V2X_SERVER_UDP_PORT, "UTF-8"))
                                                                                                                                                                                                                 ))))))));

    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_201_created(
                                                                        mw_http_message_body_json(
                                                                                                  mw_body_json_prov_chg_uu_uni_subscription(
                                                                                                                                            mw_prov_chg_uu_uni_subscription(
                                                                                                                                                                            PX_PROV_UU_UNI_SUB_CALLBACK,
                                                                                                                                                                            -,
                                                                                                                                                                            ?
                                                                                                                                                                            )))))) -> value v_response {
        tc_ac.stop;

        p_prov_chg_uu_uni_subscription := v_response.response.body.json_body.provChgUuUniSubscription;
        log("f_create_prov_uu_uni_subscription: IUT successfully registers subscription: ", p_prov_chg_uu_uni_subscription);
      }
      [] tc_ac.timeout {
        log("f_create_prov_uu_uni_subscription: Expected message not received");
      }
    } // End of 'alt' statement

  } // End of function f_create_prov_uu_uni_subscription

  function f_delete_prov_uu_uni_subscription(
                                             in ProvChgUuUniSubscription p_prov_chg_uu_uni_subscription
                                             ) runs on HttpComponent {
YannGarcia's avatar
YannGarcia committed
    var Headers v_headers;

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_delete(
                                                       PICS_ROOT_API & p_prov_chg_uu_uni_subscription.links.self_,
YannGarcia's avatar
YannGarcia committed
                                                       v_headers
                                                       )));

    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_204_no_content
                                           )) {
        tc_ac.stop;
      }
      [] tc_ac.timeout {
        log("f_delete_prov_uu_uni_subscription: Expected message not received");
      }
    } // End of 'alt' statement

  } // End of function f_delete_prov_uu_uni_subscription

  function f_create_prov_uu_mbms_subscription(
                                              out ProvChgUuMbmsSubscription p_prov_chg_uu_mbms_subscription
                                              ) runs on HttpComponent {
YannGarcia's avatar
YannGarcia committed
    var Headers v_headers;
    var HttpMessage v_response;

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_post(
                                                     PICS_ROOT_API & PX_ME_V2X_URI & "/subscriptions/prov_chg_uu_mbms",
YannGarcia's avatar
YannGarcia committed
                                                     v_headers,
                                                     m_http_message_body_json(
                                                                              m_body_json_prov_chg_uu_mbms_subscription(
                                                                                                                        m_prov_chg_uu_mbms_subscription(
                                                                                                                                                        PX_PROV_UU_MBMS_SUB_CALLBACK,
                                                                                                                                                        m_prov_chg_uu_mbms_filter_criteria(
                                                                                                                                                                                           m_location_info(
                                                                                                                                                                                                           m_ecgi(
                                                                                                                                                                                                                  PX_CELL_ID,m_plmn(PX_MCC, PX_MNC)
                                                                                                                                                                                                                  ),
                                                                                                                                                                                                           m_location_info_geo_area(
                                                                                                                                                                                                                                    43.72,
                                                                                                                                                                                                                                    10.41
                                                                                                                                                                                                                                    )),
                                                                                                                                                                                        m_v2x_server_usd(
                                                                                                                                                                                                         { PX_V2X_MBMS_SERVICE_ID },
                                                                                                                                                                                                         m_sdp_info(
                                                                                                                                                                                                                    PX_V2X_MC_SERVER,
                                                                                                                                                                                                                    PX_V2X_MC_PORT
                                                                                                                                                                                                                    ),
                                                                                                                                                                                                         m_tmgi(
                                                                                                                                                                                                                PX_V2X_SERVICE_AREA_ID,
                                                                                                                                                                                                                PX_MCC,
                                                                                                                                                                                                                PX_MNC
                                                                                                                                                                                                                )
                                                                                                                                                                                                         ))))))));

    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_201_created(
                                                                        mw_http_message_body_json(
                                                                                                  mw_body_json_prov_chg_uu_mbms_subscription(
                                                                                                                                             mw_prov_chg_uu_mbms_subscription(
                                                                                                                                                                              PX_PROV_UU_MBMS_SUB_CALLBACK,
                                                                                                                                                                              -,
                                                                                                                                                                              ?
                                                                                                                                                                              )))))) -> value v_response {
        tc_ac.stop;

        p_prov_chg_uu_mbms_subscription := v_response.response.body.json_body.provChgUuMbmsSubscription;
        log("f_create_prov_uu_mbms_subscription: IUT successfully registers subscription: ", p_prov_chg_uu_mbms_subscription);
      }
      [] tc_ac.timeout {
        log("f_create_prov_uu_mbms_subscription: Expected message not received");
      }
    } // End of 'alt' statement

  } // End of function f_create_prov_uu_mbms_subscription

  function f_delete_prov_uu_mbms_subscription(
                                             in ProvChgUuMbmsSubscription p_prov_chg_uu_mbms_subscription
                                             ) runs on HttpComponent {
YannGarcia's avatar
YannGarcia committed
    var Headers v_headers;

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_delete(
                                                       PICS_ROOT_API & PX_ME_V2X_URI & "/subscriptions/" & p_prov_chg_uu_mbms_subscription.links.self_,
YannGarcia's avatar
YannGarcia committed
                                                       v_headers
                                                       )));

    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_204_no_content
                                           )) {
        tc_ac.stop;
      }
      [] tc_ac.timeout {
        log("f_delete_prov_uu_mbms_subscription: Expected message not received");
      }
    } // End of 'alt' statement

  } // End of function f_delete_prov_uu_mbms_subscription

  function f_create_prov_pc5_subscription(
                                          out ProvChgPc5Subscription p_prov_chg_pc5_subscription
                                          ) runs on HttpComponent {
YannGarcia's avatar
YannGarcia committed
    var Headers v_headers;
    var HttpMessage v_response;

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_post(
                                                     PICS_ROOT_API & PX_ME_V2X_URI & "/subscriptions/prov_chg_pc5",
YannGarcia's avatar
YannGarcia committed
                                                     v_headers,
                                                     m_http_message_body_json(
                                                                              m_body_json_prov_chg_pc5_subscription(
                                                                                                                    m_prov_chg_pc5_subscription(
                                                                                                                                                PX_PROV_PC5_SUB_CALLBACK,
                                                                                                                                                m_filter_criteria(
                                                                                                                                                                  PX_V2X_DST_LAYER_2_ID,
                                                                                                                                                                  m_location_info(
                                                                                                                                                                                  m_ecgi(
                                                                                                                                                                                         PX_CELL_ID,m_plmn(PX_MCC, PX_MNC)
                                                                                                                                                                                         ),
                                                                                                                                                                                  m_location_info_geo_area(
                                                                                                                                                                                                           43.72,
                                                                                                                                                                                                           10.41
                                                                                                                                                                                                           )))))))));

    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_201_created(
                                                                        mw_http_message_body_json(
                                                                                                  mw_body_json_prov_chg_pc5_subscription(
                                                                                                                                             mw_prov_chg_pc5_subscription(
                                                                                                                                                                              PX_PROV_PC5_SUB_CALLBACK,
                                                                                                                                                                              -,
                                                                                                                                                                              ?
                                                                                                                                                                              )))))) -> value v_response {
        tc_ac.stop;

        p_prov_chg_pc5_subscription := v_response.response.body.json_body.provChgPc5Subscription;
        log("f_create_prov_pc5_subscription: IUT successfully registers subscription: ", p_prov_chg_pc5_subscription);
      }
      [] tc_ac.timeout {
        log("f_create_prov_pc5_subscription: Expected message not received");
      }
    } // End of 'alt' statement

  } // End of function f_create_prov_pc5_subscription

  function f_delete_prov_pc5_subscription(
                                          in ProvChgPc5Subscription p_prov_chg_pc5_subscription
                                          ) runs on HttpComponent {
YannGarcia's avatar
YannGarcia committed
    var Headers v_headers;

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_delete(
                                                       PICS_ROOT_API & PX_ME_V2X_URI & "/subscriptions/" & p_prov_chg_pc5_subscription.links.self_,
YannGarcia's avatar
YannGarcia committed
                                                       v_headers
                                                       )));

    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_204_no_content
                                           )) {
        tc_ac.stop;
      }
      [] tc_ac.timeout {
        log("f_delete_prov_pc5_subscription: Expected message not received");
      }
    } // End of 'alt' statement

  } // End of function f_delete_prov_pc5_subscription

  function f_create_v2x_msg_subscription(
                                         out V2xMsgSubscription p_v2x_msg_subscription
                                         ) runs on HttpComponent {
YannGarcia's avatar
YannGarcia committed
    var Headers v_headers;
    var HttpMessage v_response;

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_post(
                                                     PICS_ROOT_API & PX_ME_V2X_URI & "/subscriptions/V2xMsgSubscription",
YannGarcia's avatar
YannGarcia committed
                                                     v_headers,
                                                     m_http_message_body_json(
                                                                              m_body_json_v2x_msg_subscription(
                                                                                                               m_v2x_msg_subscription(
                                                                                                                                      PX_PROV_V2X_SUB_CALLBACK,
                                                                                                                                      m_v2x_msg_subscription_filter_criteria
                                                                                                                                      ))))));
    
    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_201_created(
                                                                        mw_http_message_body_json(
                                                                                                  mw_body_json_v2x_msg_subscription(
                                                                                                                                    mw_v2x_msg_subscription(
                                                                                                                                                            PX_PROV_V2X_SUB_CALLBACK,
                                                                                                                                                            -,
                                                                                                                                                            ?
                                                                                                                                                            )))))) -> value v_response {
        tc_ac.stop;

        p_v2x_msg_subscription := v_response.response.body.json_body.v2xMsgSubscription;
        log("f_create_v2x_msg_subscription: IUT successfully registers subscription: ", p_v2x_msg_subscription);
      }
      [] tc_ac.timeout {
        log("f_create_v2x_msg_subscription: Expected message not received");
      }
    } // End of 'alt' statement

  } // End of function f_create_v2x_msg_subscription

  function f_delete_v2x_msg_subscription(
                                         in V2xMsgSubscription p_v2x_msg_subscription
                                         ) runs on HttpComponent {
YannGarcia's avatar
YannGarcia committed
    var Headers v_headers;

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_delete(
                                                       PICS_ROOT_API & p_v2x_msg_subscription.links.self_,
YannGarcia's avatar
YannGarcia committed
                                                       v_headers
                                                       )));

    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_204_no_content
                                           )) {
        tc_ac.stop;
      }
      [] tc_ac.timeout {
        log("f_delete_v2x_msg_subscription: Expected message not received");
      }
    } // End of 'alt' statement

  } // End of function f_delete_v2x_msg_subscription

} // End of module V2XInformationServiceAPI_Functions