UEAppInterfaceAPI_Functions.ttcn 5.2 KB
Newer Older
YannGarcia's avatar
YannGarcia committed
module UEAppInterfaceAPI_Functions {
  
  // 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/UEAppInterfaceAPI
  import from UEAppInterfaceAPI_Templates all;
  import from UEAppInterfaceAPI_Pixits all;
  
  // LibMec
  import from LibMec_Pics all;
  import from LibMec_Pixits all;
  
  group create_ue {
  
    function f_create_ue_app_ctx() runs on HttpComponent system HttpTestAdapter return integer {
      // Local variables
      var HeaderLines v_headers;
      var HttpMessage v_response;
      var integer v_result := -1;

      // Send createion request
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_post(
                                                       "/" & PICS_ROOT_API & PX_UE_APP_CTX_URI,
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_app_context(
                                                                                                        m_app_context(
                                                                                                                      PX_CONTEXT_ID,
                                                                                                                      PX_ASSOCIATE_UE_APP_ID,
                                                                                                                      m_required_app_info(
                                                                                                                                          PX_APP_NAME,
                                                                                                                                          PX_APP_PROVIDER,
                                                                                                                                          PX_REFERENCE_URL
                    )))))));
      // Wait for the response
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_201_created(
                                                                          mw_http_message_body_json(
                                                                                                    mw_body_json_app_context(
                                                                                                                             mw_app_context(
                                                                                                                                            -, 
                                                                                                                                            -, 
                                                                                                                                            mw_required_app_info(
                                                                                                                                                                 PX_APP_NAME
                            ))))))) -> value v_response {
          tc_ac.stop;
          
          v_result := 0;
          log("*** " & testcasename() & ": INFO: IUT successfully responds with a AppContext ***");
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
        }
      } // End of 'alt' statement
      
      return v_result;
    } // End of function f_create_ue_app_ctx
    
  } // End of group create_ue
  
  group delete_ue {
  
    function f_delete_ue_app_ctx() runs on HttpComponent system HttpTestAdapter return integer {
      // Local variables
      var HeaderLines v_headers;
      var integer v_result := -1;

      // Send createion request
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_delete(
                                                         "/" & PICS_ROOT_API & PX_UE_APP_CTX_URI,
                                                         v_headers
                    )));
      // Wait for the response
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_204_no_content
                            )) {
          tc_ac.stop;
          
          v_result := 0;
          log("*** " & testcasename() & ": INFO: IUT successfully responds with a AppContext ***");
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
        }
      } // End of 'alt' statement
      
      return v_result;
    } // End of function f_delete_ue_app_ctx
    
  } // End of group delete_ue
  
} // End of module UEAppInterfaceAPI_Functions