Loading ccsrc/Protocols/Json/json_codec_mec048.cc +56 −25 Viewed Changes for ccsrc/Protocols/Json/json_codec_mec048.cc: 56 added lines, 25 removed lines. Original line number Diff line number Diff line Loading @@ -18,15 +18,19 @@ int json_codec_mec048::encode (const LibHttp__JsonMessageBodyTypes::JsonBody& ms if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_tenantInfo)) { const SelfServiceEnablementAPI__TypesAndValues::TenantInfo& tenant_info = msg.tenantInfo(); tenant_info.encode(SelfServiceEnablementAPI__TypesAndValues::TenantInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"TenantInfo\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; data = char2oct(CHARSTRING("{\"tenantInfo\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}")); } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_resourceUsageSubscription)) { const SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription& resource_usage_subscription = msg.resourceUsageSubscription(); resource_usage_subscription.encode(SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"ResourceUsageSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; data = char2oct(CHARSTRING("{\"resourceUsageSubscription\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}")); } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_siteResourceUsageSubscription)) { const SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription& site_resource_usage_subscription = msg.siteResourceUsageSubscription(); site_resource_usage_subscription.encode(SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"SiteResourceUsageSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; data = char2oct(CHARSTRING("{\"siteResourceUsageSubscription\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}")); } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_resourceQuotaInfo)) { const SelfServiceEnablementAPI__TypesAndValues::ResourceQuotaInfo& resource_quota_info = msg.resourceQuotaInfo(); resource_quota_info.encode(SelfServiceEnablementAPI__TypesAndValues::ResourceQuotaInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = char2oct(CHARSTRING("{\"resourceQuotaInfo\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}")); } else { return json_codec::encode(msg, data); } Loading Loading @@ -62,30 +66,37 @@ int json_codec_mec048::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo } else { str = it->second; } // ..and create the decoding buffer TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_EncDec::clear_error(); loggers::get_instance().log("json_codec_mec048::decode: decoding_buffer='%c' / '%s'", str[0], str.c_str()); TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); if (it->second.find("\"tenantId\"") != std::string::npos) { // Be careful to the order if (it->second[0] == '[') { SelfServiceEnablementAPI__TypesAndValues::TenantInfoList tenant_info_list; tenant_info_list.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfoList() = tenant_info_list; // Handle tenantInfo wrapper std::string decoded_str; if (str.find("\"tenantInfo\"") != std::string::npos) { // Extract the inner JSON object size_t start = str.find_first_of('{', str.find("\"tenantInfo\"") + 11); // Skip past "tenantInfo": size_t end = str.rfind('}'); // Find the last closing brace if (start != std::string::npos && end != std::string::npos && end > start) { decoded_str = str.substr(start, end - start + 1); } else { SelfServiceEnablementAPI__TypesAndValues::TenantInfo tenant_info; tenant_info.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfo() = tenant_info; loggers::get_instance().warning("json_codec_mec048::decode: Invalid tenantInfo JSON structure: %s", str.c_str()); return -1; } } else if ( (it->second.find("\"_links\"") != std::string::npos) && ((it->second.find("\"subscriptions\"") != std::string::npos) || (it->second.find("\"subscriptionType\"") == std::string::npos)) ) { SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList subscription_link_list; subscription_link_list.decode(SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.subscriptionLinkList__cse() = subscription_link_list; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"ResourceUsageSubscription\"") != std::string::npos)) { } else if (str.find("\"resourceUsageSubscription\"") != std::string::npos) { // Extract the inner JSON object for resourceUsageSubscription size_t start = str.find_first_of('{', str.find("\"resourceUsageSubscription\"") + 25); // Skip past "resourceUsageSubscription": size_t end = str.rfind('}'); // Find the last closing brace if (start != std::string::npos && end != std::string::npos && end > start) { decoded_str = str.substr(start, end - start + 1); } else { loggers::get_instance().warning("json_codec_mec048::decode: Invalid resourceUsageSubscription JSON structure: %s", str.c_str()); return -1; } } else { decoded_str = str; // Use original string if no tenantInfo wrapper } // Create decoding buffer with the adjusted JSON TTCN_Buffer decoding_buffer(OCTETSTRING(decoded_str.length(), (const unsigned char*)decoded_str.c_str())); if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"ResourceUsageSubscription\"") != std::string::npos)) { SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription resource_usage_subscription; resource_usage_subscription.decode(SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.resourceUsageSubscription() = resource_usage_subscription; Loading @@ -93,8 +104,28 @@ int json_codec_mec048::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription site_resource_usage_subscription; site_resource_usage_subscription.decode(SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.siteResourceUsageSubscription() = site_resource_usage_subscription; } else if ( (it->second.find("\"_links\"") != std::string::npos) && ((it->second.find("\"subscriptions\"") != std::string::npos) || (it->second.find("\"subscriptionType\"") == std::string::npos)) ) { SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList subscription_link_list; subscription_link_list.decode(SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.subscriptionLinkList__cse() = subscription_link_list; } else if (it->second.find("\"tenantId\"") != std::string::npos) { // Be careful to the order if (it->second[0] == '[') { SelfServiceEnablementAPI__TypesAndValues::TenantInfoList tenant_info_list; tenant_info_list.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfoList() = tenant_info_list; } else{ SelfServiceEnablementAPI__TypesAndValues::TenantInfo tenant_info; tenant_info.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfo() = tenant_info; } } else { return json_codec::decode(p_data, msg, p_params); loggers::get_instance().warning("json_codec_mec048::decode: No matching structure found, assigning raw"); // Assign raw alternative of union with full original string msg.raw() = CHARSTRING(str.c_str()); loggers::get_instance().log("json_codec_mec048::decode: Assigned raw='%s'", str.c_str()); } loggers::get_instance().log_msg("<<< json_codec_mec048::decode: ", (const Base_Type&)msg); Loading ttcn/AtsMec_SelfServiceEnablement/AtsMec_SelfServiceEnablementAPI_TestCases.ttcn +88 −53 Viewed File changed.Preview size limit exceeded, changes collapsed. Show changes ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Functions.ttcn +54 −34 Viewed Changes for ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Functions.ttcn: 54 added lines, 34 removed lines. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ module SelfServiceEnablementAPI_Functions { // LibHttp import from LibHttp_TypesAndValues all; import from LibHttp_JsonMessageBodyTypes all; import from LibHttp_Functions all; import from LibHttp_Templates all; import from LibHttp_JsonTemplates all; Loading @@ -22,6 +23,7 @@ module SelfServiceEnablementAPI_Functions { import from SelfServiceEnablementAPI_Pixits all; // LibMec import from LibMec_TypesAndValues all; import from LibMec_Templates all; import from LibMec_Functions all; import from LibMec_Pics all; Loading @@ -33,10 +35,13 @@ module SelfServiceEnablementAPI_Functions { ) runs on HttpComponent { log(">>> f_create_tenant_info_list: ", p_tenant_info_list); var charstring v_tenant_id; p_tenant_id_list := {}; for (var integer i := 0; i < lengthof(p_tenant_info_list); i := i + 1) { f_create_tenant_info(p_tenant_info_list[i], v_tenant_id); if (lengthof(v_tenant_id) > 0) { p_tenant_id_list := p_tenant_id_list & { v_tenant_id }; } } } // End of function f_create_tenant_info_list function f_create_tenant_info( Loading @@ -55,8 +60,14 @@ module SelfServiceEnablementAPI_Functions { PICS_ROOT_API & PX_CSE_TENANTS_INFO, v_headers, m_http_message_body_json( m_body_json_cse_tenant_info(p_tenant_info) )))); m_body_json_cse_tenant_info( m_tenant_info( p_tenant_info.customerId, p_tenant_info.customerName, p_tenant_info.customerCategory, omit, p_tenant_info.tenantName )))))); tc_ac.start; alt { [] httpPort.receive( Loading @@ -65,11 +76,11 @@ module SelfServiceEnablementAPI_Functions { mw_http_message_body_json( mw_body_json_cse_tenant_info( mw_tenant_info( p_tenant_info.customerId, p_tenant_info.customerName, p_tenant_info.customerCategory, ?, ?, ?, ?, ? p_tenant_info.tenantName ) ))))) -> value v_response { tc_ac.stop; Loading @@ -78,6 +89,7 @@ module SelfServiceEnablementAPI_Functions { var charstring_list v_tenant_id; f_get_header(v_response.response.header, "Location", v_tenant_id); // Extract HTTP tenant id if (ispresent(v_tenant_id) and lengthof(v_tenant_id) > 0) { p_tenant_id := regexp( v_tenant_id[0], "?+" & PX_CSE_TENANTS_INFO & "/(?*)", Loading @@ -87,6 +99,7 @@ module SelfServiceEnablementAPI_Functions { p_tenant_info := v_response.response.body.json_body.tenantInfo; log("f_create_tenant_info: INFO: IUT successfully creates the Tenants: ", p_tenant_info); } } [] tc_ac.timeout { log("f_create_tenant_info: INCONC: Expected message not received"); } Loading Loading @@ -194,11 +207,12 @@ module SelfServiceEnablementAPI_Functions { ) runs on HttpComponent { log(">>> f_create_site_resource_quota_info_list: ", p_site_resource_quota_info); var charstring v_site_resource_quota_info_id; p_site_resource_quota_info_id_list := {}; for (var integer i := 0; i < lengthof(p_site_resource_quota_info); i := i + 1) { f_create_site_resource_quota_info(p_site_resource_quota_info[i], -, p_tenant_id); p_site_resource_quota_info_id_list := p_site_resource_quota_info_id_list & { v_site_resource_quota_info_id }; } } // End of function f_create_tenant_info_list } // End of function f_create_site_resource_quota_info_list function f_create_site_resource_quota_info( inout SiteResourceQuotaInfo p_site_resource_quota_info, Loading @@ -214,7 +228,7 @@ module SelfServiceEnablementAPI_Functions { httpPort.send( m_http_request( m_http_request_post( PICS_ROOT_API & PX_CSE_TENANTS_INFO & "/" & p_tenant_id & "/resources/quota_in_sites", PICS_ROOT_API & PX_CSE_TENANTS_INFO & "/" & p_tenant_id & "/resources/quota_in_system", v_headers, m_http_message_body_json( m_body_json_cse_site_resource_quota_info( Loading Loading @@ -278,7 +292,9 @@ module SelfServiceEnablementAPI_Functions { m_body_json_resource_usage_subscription( m_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, omit, omit, omit, true, omit, omit, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID, m_notification_trigger( Loading @@ -298,9 +314,11 @@ module SelfServiceEnablementAPI_Functions { mw_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, true, *, *, ?,?,? omit, -, PX_CSE_CUSTOMER_ID_1, ?, ? ) ))))) -> value v_response { tc_ac.stop; Loading Loading @@ -342,18 +360,19 @@ module SelfServiceEnablementAPI_Functions { m_body_json_site_resource_usage_subscription( m_site_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, omit, omit, omit, true, omit, omit, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID, { m_site_id("site-001"), m_site_id("site-002") }, { m_site_id(PX_CSE_SITE_ID_1), m_site_id(PX_CSE_SITE_ID_2) }, m_notification_trigger( e_tt_ten, 5, true ) ) ))))); )))))); tc_ac.start; alt { [] httpPort.receive( Loading @@ -364,10 +383,10 @@ module SelfServiceEnablementAPI_Functions { mw_site_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, true, *, *, omit, -, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID ? ) ))))) -> value v_response { tc_ac.stop; Loading Loading @@ -410,7 +429,9 @@ module SelfServiceEnablementAPI_Functions { m_body_json_resource_usage_subscription( m_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, omit, omit, omit, true, omit, omit, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID, m_notification_trigger ( Loading @@ -418,8 +439,7 @@ module SelfServiceEnablementAPI_Functions { 4, false ) ) ))))); )))))); tc_ac.start; alt { [] httpPort.receive( Loading @@ -430,10 +450,10 @@ module SelfServiceEnablementAPI_Functions { mw_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, true, *, omit, -, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID ? ) ))))) -> value v_response { tc_ac.stop; Loading Loading @@ -479,8 +499,8 @@ module SelfServiceEnablementAPI_Functions { omit, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID, { m_site_id("site-001"), m_site_id("site-002") }, { m_site_id(PX_CSE_SITE_ID_1), m_site_id(PX_CSE_SITE_ID_2) }, m_notification_trigger ( e_tt_ten, 4, Loading @@ -500,10 +520,10 @@ module SelfServiceEnablementAPI_Functions { omit, -, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID, { m_site_id("site-001"), m_site_id("site-002") }, m_notification_trigger ( ?, { mw_site_id(PX_CSE_SITE_ID_1), mw_site_id(PX_CSE_SITE_ID_2) }, mw_notification_trigger ( e_tt_ten, 4, false Loading @@ -522,11 +542,11 @@ module SelfServiceEnablementAPI_Functions { 0 ); p_site_resource_usage_subscription := v_response.response.body.json_body.siteResourceUsageSubscription; log("f_create_site_resource_usage_subscription: INFO: IUT successfully responds to the subscription: ", p_site_resource_usage_subscription); log("f_create_site_resource_usage_subscription: INFO: p_subscription_id: ", p_subscription_id); log("f_create_site_resource_usage_subscription_2: INFO: IUT successfully responds to the subscription: ", p_site_resource_usage_subscription); log("f_create_site_resource_usage_subscription_2: INFO: p_subscription_id: ", p_subscription_id); } [] tc_ac.timeout { log("f_create_resource_usage_subscription: Expected message not received"); log("f_create_site_resource_usage_subscription_2: Expected message not received"); } } // End of 'alt' statement } // End of function f_create_site_resource_usage_subscription Loading ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Pixits.ttcn +7 −3 Viewed Changes for ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Pixits.ttcn: 7 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ module SelfServiceEnablementAPI_Pixits { // LibMec/SelfServiceEnablementAPI import from SelfServiceEnablementAPI_TypesAndValues all; modulepar Json.String PX_CSE_CUSTOMER_ID_1 := "" modulepar Json.String PX_CSE_CUSTOMER_ID_1 := "customer01" modulepar Json.String PX_CSE_CUSTOMER_NAME_1 := "customerName"; Loading @@ -17,18 +17,22 @@ module SelfServiceEnablementAPI_Pixits { modulepar Json.String PX_CSE_TENANT_NAME_1 := "tenantX"; modulepar Json.String PX_CSE_CUSTOMER_ID_2 := "" modulepar Json.String PX_CSE_CUSTOMER_ID_2 := "customer02" modulepar Json.String PX_CSE_CUSTOMER_NAME_2 := "customerName02"; modulepar Json.String PX_CSE_TENANT_NAME_2 := "tenantY"; modulepar Json.String PX_CSE_CUSTOMER_ID_3 := "" modulepar Json.String PX_CSE_CUSTOMER_ID_3 := "customer03" modulepar Json.String PX_CSE_CUSTOMER_NAME_3 := "customerName03"; modulepar Json.String PX_CSE_TENANT_NAME_3 := "tenantName03"; modulepar Json.String PX_CSE_SITE_ID_1 := "site-001"; modulepar Json.String PX_CSE_SITE_ID_2 := "site-002"; modulepar Json.String PX_NON_EXISTENT_TENANT_ID := "9344"; modulepar Json.String PX_NEW_CUSTOMER_ID := ""; Loading ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Templates.ttcn +6 −6 Viewed Changes for ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Templates.ttcn: 6 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ module SelfServiceEnablementAPI_Templates { in template (omit) Json.String p_tenantId, in Json.String p_tenantName, in template (omit) ResourceInfo p_resourceUseInfo := omit, in template (omit) SiteInfo p_siteList := omit in template (omit) SiteInfoList p_siteList := omit ) := { customerId := p_customerId, customerName := p_customerName, Loading @@ -37,7 +37,7 @@ module SelfServiceEnablementAPI_Templates { template Json.String p_tenantId := *, template (present) Json.String p_tenantName := ?, template ResourceInfo p_resourceUseInfo := *, template SiteInfo p_siteList := * template SiteInfoList p_siteList := * ) := { customerId := p_customerId, customerName := p_customerName, Loading Loading @@ -333,7 +333,7 @@ module SelfServiceEnablementAPI_Templates { } // End of template mw_site_resource_use_info template (value) ExpiryNotification m_cse_expiry_notification( in template (value) LinkExpiry p_links, in template (value) LinksExpiry p_links, in template (value) TimeStamp p_expiryDeadline ) := { notificationType := "ExpiryNotification", Loading @@ -342,7 +342,7 @@ module SelfServiceEnablementAPI_Templates { } // End of template m_expiry_notification template (present) ExpiryNotification mw_cse_expiry_notification( template (present) LinkExpiry p_links := ?, template (present) LinksExpiry p_links := ?, template (present) TimeStamp p_expiryDeadline := ? ) := { notificationType := "ExpiryNotification", Loading Loading @@ -467,13 +467,13 @@ module SelfServiceEnablementAPI_Templates { diskRemain := p_diskRemain } // End of template mw_resource_info template (value) LinkExpiry m_link_expiry( template (value) LinksExpiry m_link_expiry( in template (value) LinkType p_subscription ) := { subscription := p_subscription } //End of temaplate m_link_expiry template (present) LinkExpiry mw_link_expiry( template (present) LinksExpiry mw_link_expiry( template (present) LinkType p_subscription := ? ) := { subscription := p_subscription Loading Loading
ccsrc/Protocols/Json/json_codec_mec048.cc +56 −25 Viewed Changes for ccsrc/Protocols/Json/json_codec_mec048.cc: 56 added lines, 25 removed lines. Original line number Diff line number Diff line Loading @@ -18,15 +18,19 @@ int json_codec_mec048::encode (const LibHttp__JsonMessageBodyTypes::JsonBody& ms if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_tenantInfo)) { const SelfServiceEnablementAPI__TypesAndValues::TenantInfo& tenant_info = msg.tenantInfo(); tenant_info.encode(SelfServiceEnablementAPI__TypesAndValues::TenantInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"TenantInfo\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; data = char2oct(CHARSTRING("{\"tenantInfo\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}")); } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_resourceUsageSubscription)) { const SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription& resource_usage_subscription = msg.resourceUsageSubscription(); resource_usage_subscription.encode(SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"ResourceUsageSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; data = char2oct(CHARSTRING("{\"resourceUsageSubscription\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}")); } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_siteResourceUsageSubscription)) { const SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription& site_resource_usage_subscription = msg.siteResourceUsageSubscription(); site_resource_usage_subscription.encode(SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"SiteResourceUsageSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; data = char2oct(CHARSTRING("{\"siteResourceUsageSubscription\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}")); } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_resourceQuotaInfo)) { const SelfServiceEnablementAPI__TypesAndValues::ResourceQuotaInfo& resource_quota_info = msg.resourceQuotaInfo(); resource_quota_info.encode(SelfServiceEnablementAPI__TypesAndValues::ResourceQuotaInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = char2oct(CHARSTRING("{\"resourceQuotaInfo\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}")); } else { return json_codec::encode(msg, data); } Loading Loading @@ -62,30 +66,37 @@ int json_codec_mec048::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo } else { str = it->second; } // ..and create the decoding buffer TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_EncDec::clear_error(); loggers::get_instance().log("json_codec_mec048::decode: decoding_buffer='%c' / '%s'", str[0], str.c_str()); TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); if (it->second.find("\"tenantId\"") != std::string::npos) { // Be careful to the order if (it->second[0] == '[') { SelfServiceEnablementAPI__TypesAndValues::TenantInfoList tenant_info_list; tenant_info_list.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfoList() = tenant_info_list; // Handle tenantInfo wrapper std::string decoded_str; if (str.find("\"tenantInfo\"") != std::string::npos) { // Extract the inner JSON object size_t start = str.find_first_of('{', str.find("\"tenantInfo\"") + 11); // Skip past "tenantInfo": size_t end = str.rfind('}'); // Find the last closing brace if (start != std::string::npos && end != std::string::npos && end > start) { decoded_str = str.substr(start, end - start + 1); } else { SelfServiceEnablementAPI__TypesAndValues::TenantInfo tenant_info; tenant_info.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfo() = tenant_info; loggers::get_instance().warning("json_codec_mec048::decode: Invalid tenantInfo JSON structure: %s", str.c_str()); return -1; } } else if ( (it->second.find("\"_links\"") != std::string::npos) && ((it->second.find("\"subscriptions\"") != std::string::npos) || (it->second.find("\"subscriptionType\"") == std::string::npos)) ) { SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList subscription_link_list; subscription_link_list.decode(SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.subscriptionLinkList__cse() = subscription_link_list; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"ResourceUsageSubscription\"") != std::string::npos)) { } else if (str.find("\"resourceUsageSubscription\"") != std::string::npos) { // Extract the inner JSON object for resourceUsageSubscription size_t start = str.find_first_of('{', str.find("\"resourceUsageSubscription\"") + 25); // Skip past "resourceUsageSubscription": size_t end = str.rfind('}'); // Find the last closing brace if (start != std::string::npos && end != std::string::npos && end > start) { decoded_str = str.substr(start, end - start + 1); } else { loggers::get_instance().warning("json_codec_mec048::decode: Invalid resourceUsageSubscription JSON structure: %s", str.c_str()); return -1; } } else { decoded_str = str; // Use original string if no tenantInfo wrapper } // Create decoding buffer with the adjusted JSON TTCN_Buffer decoding_buffer(OCTETSTRING(decoded_str.length(), (const unsigned char*)decoded_str.c_str())); if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"ResourceUsageSubscription\"") != std::string::npos)) { SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription resource_usage_subscription; resource_usage_subscription.decode(SelfServiceEnablementAPI__TypesAndValues::ResourceUsageSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.resourceUsageSubscription() = resource_usage_subscription; Loading @@ -93,8 +104,28 @@ int json_codec_mec048::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription site_resource_usage_subscription; site_resource_usage_subscription.decode(SelfServiceEnablementAPI__TypesAndValues::SiteResourceUsageSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.siteResourceUsageSubscription() = site_resource_usage_subscription; } else if ( (it->second.find("\"_links\"") != std::string::npos) && ((it->second.find("\"subscriptions\"") != std::string::npos) || (it->second.find("\"subscriptionType\"") == std::string::npos)) ) { SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList subscription_link_list; subscription_link_list.decode(SelfServiceEnablementAPI__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.subscriptionLinkList__cse() = subscription_link_list; } else if (it->second.find("\"tenantId\"") != std::string::npos) { // Be careful to the order if (it->second[0] == '[') { SelfServiceEnablementAPI__TypesAndValues::TenantInfoList tenant_info_list; tenant_info_list.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfoList() = tenant_info_list; } else{ SelfServiceEnablementAPI__TypesAndValues::TenantInfo tenant_info; tenant_info.decode(SelfServiceEnablementAPI__TypesAndValues::TenantInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.tenantInfo() = tenant_info; } } else { return json_codec::decode(p_data, msg, p_params); loggers::get_instance().warning("json_codec_mec048::decode: No matching structure found, assigning raw"); // Assign raw alternative of union with full original string msg.raw() = CHARSTRING(str.c_str()); loggers::get_instance().log("json_codec_mec048::decode: Assigned raw='%s'", str.c_str()); } loggers::get_instance().log_msg("<<< json_codec_mec048::decode: ", (const Base_Type&)msg); Loading
ttcn/AtsMec_SelfServiceEnablement/AtsMec_SelfServiceEnablementAPI_TestCases.ttcn +88 −53 Viewed File changed.Preview size limit exceeded, changes collapsed. Show changes
ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Functions.ttcn +54 −34 Viewed Changes for ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Functions.ttcn: 54 added lines, 34 removed lines. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ module SelfServiceEnablementAPI_Functions { // LibHttp import from LibHttp_TypesAndValues all; import from LibHttp_JsonMessageBodyTypes all; import from LibHttp_Functions all; import from LibHttp_Templates all; import from LibHttp_JsonTemplates all; Loading @@ -22,6 +23,7 @@ module SelfServiceEnablementAPI_Functions { import from SelfServiceEnablementAPI_Pixits all; // LibMec import from LibMec_TypesAndValues all; import from LibMec_Templates all; import from LibMec_Functions all; import from LibMec_Pics all; Loading @@ -33,10 +35,13 @@ module SelfServiceEnablementAPI_Functions { ) runs on HttpComponent { log(">>> f_create_tenant_info_list: ", p_tenant_info_list); var charstring v_tenant_id; p_tenant_id_list := {}; for (var integer i := 0; i < lengthof(p_tenant_info_list); i := i + 1) { f_create_tenant_info(p_tenant_info_list[i], v_tenant_id); if (lengthof(v_tenant_id) > 0) { p_tenant_id_list := p_tenant_id_list & { v_tenant_id }; } } } // End of function f_create_tenant_info_list function f_create_tenant_info( Loading @@ -55,8 +60,14 @@ module SelfServiceEnablementAPI_Functions { PICS_ROOT_API & PX_CSE_TENANTS_INFO, v_headers, m_http_message_body_json( m_body_json_cse_tenant_info(p_tenant_info) )))); m_body_json_cse_tenant_info( m_tenant_info( p_tenant_info.customerId, p_tenant_info.customerName, p_tenant_info.customerCategory, omit, p_tenant_info.tenantName )))))); tc_ac.start; alt { [] httpPort.receive( Loading @@ -65,11 +76,11 @@ module SelfServiceEnablementAPI_Functions { mw_http_message_body_json( mw_body_json_cse_tenant_info( mw_tenant_info( p_tenant_info.customerId, p_tenant_info.customerName, p_tenant_info.customerCategory, ?, ?, ?, ?, ? p_tenant_info.tenantName ) ))))) -> value v_response { tc_ac.stop; Loading @@ -78,6 +89,7 @@ module SelfServiceEnablementAPI_Functions { var charstring_list v_tenant_id; f_get_header(v_response.response.header, "Location", v_tenant_id); // Extract HTTP tenant id if (ispresent(v_tenant_id) and lengthof(v_tenant_id) > 0) { p_tenant_id := regexp( v_tenant_id[0], "?+" & PX_CSE_TENANTS_INFO & "/(?*)", Loading @@ -87,6 +99,7 @@ module SelfServiceEnablementAPI_Functions { p_tenant_info := v_response.response.body.json_body.tenantInfo; log("f_create_tenant_info: INFO: IUT successfully creates the Tenants: ", p_tenant_info); } } [] tc_ac.timeout { log("f_create_tenant_info: INCONC: Expected message not received"); } Loading Loading @@ -194,11 +207,12 @@ module SelfServiceEnablementAPI_Functions { ) runs on HttpComponent { log(">>> f_create_site_resource_quota_info_list: ", p_site_resource_quota_info); var charstring v_site_resource_quota_info_id; p_site_resource_quota_info_id_list := {}; for (var integer i := 0; i < lengthof(p_site_resource_quota_info); i := i + 1) { f_create_site_resource_quota_info(p_site_resource_quota_info[i], -, p_tenant_id); p_site_resource_quota_info_id_list := p_site_resource_quota_info_id_list & { v_site_resource_quota_info_id }; } } // End of function f_create_tenant_info_list } // End of function f_create_site_resource_quota_info_list function f_create_site_resource_quota_info( inout SiteResourceQuotaInfo p_site_resource_quota_info, Loading @@ -214,7 +228,7 @@ module SelfServiceEnablementAPI_Functions { httpPort.send( m_http_request( m_http_request_post( PICS_ROOT_API & PX_CSE_TENANTS_INFO & "/" & p_tenant_id & "/resources/quota_in_sites", PICS_ROOT_API & PX_CSE_TENANTS_INFO & "/" & p_tenant_id & "/resources/quota_in_system", v_headers, m_http_message_body_json( m_body_json_cse_site_resource_quota_info( Loading Loading @@ -278,7 +292,9 @@ module SelfServiceEnablementAPI_Functions { m_body_json_resource_usage_subscription( m_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, omit, omit, omit, true, omit, omit, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID, m_notification_trigger( Loading @@ -298,9 +314,11 @@ module SelfServiceEnablementAPI_Functions { mw_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, true, *, *, ?,?,? omit, -, PX_CSE_CUSTOMER_ID_1, ?, ? ) ))))) -> value v_response { tc_ac.stop; Loading Loading @@ -342,18 +360,19 @@ module SelfServiceEnablementAPI_Functions { m_body_json_site_resource_usage_subscription( m_site_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, omit, omit, omit, true, omit, omit, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID, { m_site_id("site-001"), m_site_id("site-002") }, { m_site_id(PX_CSE_SITE_ID_1), m_site_id(PX_CSE_SITE_ID_2) }, m_notification_trigger( e_tt_ten, 5, true ) ) ))))); )))))); tc_ac.start; alt { [] httpPort.receive( Loading @@ -364,10 +383,10 @@ module SelfServiceEnablementAPI_Functions { mw_site_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, true, *, *, omit, -, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID ? ) ))))) -> value v_response { tc_ac.stop; Loading Loading @@ -410,7 +429,9 @@ module SelfServiceEnablementAPI_Functions { m_body_json_resource_usage_subscription( m_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, omit, omit, omit, true, omit, omit, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID, m_notification_trigger ( Loading @@ -418,8 +439,7 @@ module SelfServiceEnablementAPI_Functions { 4, false ) ) ))))); )))))); tc_ac.start; alt { [] httpPort.receive( Loading @@ -430,10 +450,10 @@ module SelfServiceEnablementAPI_Functions { mw_resource_usage_subscription( PX_CSE_SUB_CALLBACK_URI, true, *, omit, -, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID ? ) ))))) -> value v_response { tc_ac.stop; Loading Loading @@ -479,8 +499,8 @@ module SelfServiceEnablementAPI_Functions { omit, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID, { m_site_id("site-001"), m_site_id("site-002") }, { m_site_id(PX_CSE_SITE_ID_1), m_site_id(PX_CSE_SITE_ID_2) }, m_notification_trigger ( e_tt_ten, 4, Loading @@ -500,10 +520,10 @@ module SelfServiceEnablementAPI_Functions { omit, -, PX_CSE_CUSTOMER_ID_1, PX_CSE_TENANT_ID, { m_site_id("site-001"), m_site_id("site-002") }, m_notification_trigger ( ?, { mw_site_id(PX_CSE_SITE_ID_1), mw_site_id(PX_CSE_SITE_ID_2) }, mw_notification_trigger ( e_tt_ten, 4, false Loading @@ -522,11 +542,11 @@ module SelfServiceEnablementAPI_Functions { 0 ); p_site_resource_usage_subscription := v_response.response.body.json_body.siteResourceUsageSubscription; log("f_create_site_resource_usage_subscription: INFO: IUT successfully responds to the subscription: ", p_site_resource_usage_subscription); log("f_create_site_resource_usage_subscription: INFO: p_subscription_id: ", p_subscription_id); log("f_create_site_resource_usage_subscription_2: INFO: IUT successfully responds to the subscription: ", p_site_resource_usage_subscription); log("f_create_site_resource_usage_subscription_2: INFO: p_subscription_id: ", p_subscription_id); } [] tc_ac.timeout { log("f_create_resource_usage_subscription: Expected message not received"); log("f_create_site_resource_usage_subscription_2: Expected message not received"); } } // End of 'alt' statement } // End of function f_create_site_resource_usage_subscription Loading
ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Pixits.ttcn +7 −3 Viewed Changes for ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Pixits.ttcn: 7 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ module SelfServiceEnablementAPI_Pixits { // LibMec/SelfServiceEnablementAPI import from SelfServiceEnablementAPI_TypesAndValues all; modulepar Json.String PX_CSE_CUSTOMER_ID_1 := "" modulepar Json.String PX_CSE_CUSTOMER_ID_1 := "customer01" modulepar Json.String PX_CSE_CUSTOMER_NAME_1 := "customerName"; Loading @@ -17,18 +17,22 @@ module SelfServiceEnablementAPI_Pixits { modulepar Json.String PX_CSE_TENANT_NAME_1 := "tenantX"; modulepar Json.String PX_CSE_CUSTOMER_ID_2 := "" modulepar Json.String PX_CSE_CUSTOMER_ID_2 := "customer02" modulepar Json.String PX_CSE_CUSTOMER_NAME_2 := "customerName02"; modulepar Json.String PX_CSE_TENANT_NAME_2 := "tenantY"; modulepar Json.String PX_CSE_CUSTOMER_ID_3 := "" modulepar Json.String PX_CSE_CUSTOMER_ID_3 := "customer03" modulepar Json.String PX_CSE_CUSTOMER_NAME_3 := "customerName03"; modulepar Json.String PX_CSE_TENANT_NAME_3 := "tenantName03"; modulepar Json.String PX_CSE_SITE_ID_1 := "site-001"; modulepar Json.String PX_CSE_SITE_ID_2 := "site-002"; modulepar Json.String PX_NON_EXISTENT_TENANT_ID := "9344"; modulepar Json.String PX_NEW_CUSTOMER_ID := ""; Loading
ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Templates.ttcn +6 −6 Viewed Changes for ttcn/LibMec/SelfServiceEnablementAPI/ttcn/SelfServiceEnablementAPI_Templates.ttcn: 6 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ module SelfServiceEnablementAPI_Templates { in template (omit) Json.String p_tenantId, in Json.String p_tenantName, in template (omit) ResourceInfo p_resourceUseInfo := omit, in template (omit) SiteInfo p_siteList := omit in template (omit) SiteInfoList p_siteList := omit ) := { customerId := p_customerId, customerName := p_customerName, Loading @@ -37,7 +37,7 @@ module SelfServiceEnablementAPI_Templates { template Json.String p_tenantId := *, template (present) Json.String p_tenantName := ?, template ResourceInfo p_resourceUseInfo := *, template SiteInfo p_siteList := * template SiteInfoList p_siteList := * ) := { customerId := p_customerId, customerName := p_customerName, Loading Loading @@ -333,7 +333,7 @@ module SelfServiceEnablementAPI_Templates { } // End of template mw_site_resource_use_info template (value) ExpiryNotification m_cse_expiry_notification( in template (value) LinkExpiry p_links, in template (value) LinksExpiry p_links, in template (value) TimeStamp p_expiryDeadline ) := { notificationType := "ExpiryNotification", Loading @@ -342,7 +342,7 @@ module SelfServiceEnablementAPI_Templates { } // End of template m_expiry_notification template (present) ExpiryNotification mw_cse_expiry_notification( template (present) LinkExpiry p_links := ?, template (present) LinksExpiry p_links := ?, template (present) TimeStamp p_expiryDeadline := ? ) := { notificationType := "ExpiryNotification", Loading Loading @@ -467,13 +467,13 @@ module SelfServiceEnablementAPI_Templates { diskRemain := p_diskRemain } // End of template mw_resource_info template (value) LinkExpiry m_link_expiry( template (value) LinksExpiry m_link_expiry( in template (value) LinkType p_subscription ) := { subscription := p_subscription } //End of temaplate m_link_expiry template (present) LinkExpiry mw_link_expiry( template (present) LinksExpiry mw_link_expiry( template (present) LinkType p_subscription := ? ) := { subscription := p_subscription Loading