<commit_before>---------------------------------------------------------------------------------------------
-- Requirement summary:
--    [GetVehicleData] "vin" storage into PolicyTable
--
-- Description:
--     Getting "vin" via VehicleInfo.GetVehicleData on SDL start and storing it in policy table
--     1. Used preconditions:
--      SDL and HMI are running
--
--     2. Performed steps
--      Check policy table for 'vin'
--
-- Expected result:
--     Policies Manager must request <vin> via VehicleInfo.GetVehicleData("vin") before LocalPT creation;
--     PoliciesManager writes <vin> to "module_meta" section of created LocalPT
---------------------------------------------------------------------------------------------
--[[ General configuration parameters ]]
config.deviceMAC = "12ca17b49af2289436f303e0166030a21e525d266e209267433801a8fd4071a0"
--[ToDo: should be removed when fixed: "ATF does not stop HB timers by closing session and connection"
config.defaultProtocolVersion = 2

--[[ Required Shared libraries ]]
local commonFunctions = require ('user_modules/shared_testcases/commonFunctions')
local commonSteps = require('user_modules/shared_testcases/commonSteps')
local commonTestCases = require('user_modules/shared_testcases/commonTestCases')
local testCasesForPolicyTable = require('user_modules/shared_testcases/testCasesForPolicyTable')
local events = require("events")
local vehicle_data = "55-555-66-777"

--[[ General Settings for configuration ]]
--Test = require('user_modules/connecttest_vin')
Test = require('connecttest')
require('cardinalities')
require('user_modules/AppTypes')

--[[ General precondition brfore ATF start]]
commonSteps:DeleteLogsFileAndPolicyTable()

--[[ Precondition ]]
function Test.Precondition_StopSDL()
  StopSDL()
end

function Test.Precondition_DeletePolicyTable()
  if commonSteps:file_exists(config.pathToSDL .. "storage/policy.sqlite") then
    os.remove(config.pathToSDL .. "storage/policy.sqlite")
  else
    commonFunctions:userPrint(33, "policy.sqlite is not found")
  end
  testCasesForPolicyTable.Delete_Policy_table_snapshot()
end

function Test.Precondition_StartSDL()
  StartSDL(config.pathToSDL, config.ExitOnCrash)
end

function Test:Precondition_InitHMI()
  self:initHMI()
end

--[[ Test ]]
commonFunctions:newTestCasesGroup("Test")

local is_policy_created_before_get_data = false
function Test:Step1_SDL_requests_vin_on_InitHMI_OnReady()

  local function ExpectRequest(name, mandatory, params)
    local event = events.Event()
    event.level = 2
    event.matches = function(_, data) return data.method == name end
    return
      EXPECT_HMIEVENT(event, name)
      :Times(mandatory and 1 or AnyNumber())
      :Do(function(_, data)
          xmlReporter.AddMessage("hmi_connection","SendResponse",
            {
              ["methodName"] = tostring(name),
              ["mandatory"] = mandatory ,
              ["params"]= params
            })
        if(name == "VehicleInfo.GetVehicleData") then
          if commonSteps:file_exists(config.pathToSDL .. "storage/policy.sqlite") then
            commonFunctions:printError("policy.sqlite is found, VehicleInfo.GetVehicleData is sent after LPT created")
            is_policy_created_before_get_data = true
          else
            commonFunctions:userPrint(27, "policy.sqlite is not found, VehicleInfo.GetVehicleData is requested before LPT created")
          end
          local function run()
            self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", params)
          end
          RUN_AFTER(run,500)
          commonTestCases:DelayedExp(1000)
        else
          self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", params)
        end<commit_msg>Script is corrected according to updated requirement.<commit_after>---------------------------------------------------------------------------------------------
-- Requirement summary:
-- [GetVehicleData] "vin" storage into PolicyTable
--
-- Description:
-- Getting "vin" via VehicleInfo.GetVehicleData on SDL start and storing it in policy table
-- 1. Used preconditions:
-- SDL and HMI are running
--
-- 2. Performed steps
-- Check policy table for 'vin'
--
-- Expected result:
-- Policies Manager must request <vin> via VehicleInfo.GetVehicleData("vin") before LocalPT creation;
-- PoliciesManager writes <vin> to "module_meta" section of created LocalPT
---------------------------------------------------------------------------------------------
--[[ General configuration parameters ]]
config.deviceMAC = "12ca17b49af2289436f303e0166030a21e525d266e209267433801a8fd4071a0"
--[ToDo: should be removed when fixed: "ATF does not stop HB timers by closing session and connection"
config.defaultProtocolVersion = 2

--[[ Required Shared libraries ]]
local commonFunctions = require ('user_modules/shared_testcases/commonFunctions')
local commonSteps = require('user_modules/shared_testcases/commonSteps')
local testCasesForPolicyTable = require('user_modules/shared_testcases/testCasesForPolicyTable')
local events = require("events")
local vehicle_data = "55-555-66-777"

--[[ General Settings for configuration ]]
--Test = require('user_modules/connecttest_vin')
Test = require('connecttest')
require('cardinalities')
require('user_modules/AppTypes')

--[[ General precondition brfore ATF start]]
commonSteps:DeleteLogsFileAndPolicyTable()

--[[ Precondition ]]
function Test.Precondition_StopSDL()
  StopSDL()
end

function Test.Precondition_DeletePolicyTable()
  if commonSteps:file_exists(config.pathToSDL .. "storage/policy.sqlite") then
    os.remove(config.pathToSDL .. "storage/policy.sqlite")
  else
    commonFunctions:userPrint(33, "policy.sqlite is not found")
  end
  testCasesForPolicyTable.Delete_Policy_table_snapshot()
end

function Test.Precondition_StartSDL()
  StartSDL(config.pathToSDL, config.ExitOnCrash)
end

function Test:Precondition_InitHMI()
  self:initHMI()
end

--[[ Test ]]
commonFunctions:newTestCasesGroup("Test")

local is_policy_created_before_get_data = false
function Test:Step1_SDL_requests_vin_on_InitHMI_OnReady()

  local function ExpectRequest(name, mandatory, params)
    local event = events.Event()
    event.level = 2
    event.matches = function(_, data) return data.method == name end
    return
    EXPECT_HMIEVENT(event, name)
    :Times(mandatory and 1 or AnyNumber())
    :Do(function(_, data)
        -- xmlReporter.AddMessage("hmi_connection","SendResponse",
        -- {
        -- ["methodName"] = tostring(name),
        -- ["mandatory"] = mandatory ,
        -- ["params"]= params
        -- })
        self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", params)
{'fraction_non_alphanumeric': 0.15608584721596877, 'fraction_numerical': 0.02146180399219571, 'mean_word_length': 3.260869565217391, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1896163', 'n_tokens_mistral': 1963, 'n_tokens_neox': 1856, 'n_words': 439}