[CR #1696842] CLL: Provide specific error code for dataSource SetDataValue handler when set request is faulty but handled

Change-Id: I61a65a0850268d89daf1200c08b4b93ff9875687
Signed-off-by: József Gyürüsi <jozsef.gyurusi@ericsson.com>
diff --git a/src/DataSource/EPTF_CLL_DataSourceClient_Functions.ttcn b/src/DataSource/EPTF_CLL_DataSourceClient_Functions.ttcn
index 6dddecf..4ee9aa6 100644
--- a/src/DataSource/EPTF_CLL_DataSourceClient_Functions.ttcn
+++ b/src/DataSource/EPTF_CLL_DataSourceClient_Functions.ttcn
@@ -1915,7 +1915,7 @@
     );
   }
 
-  if (vl_dataValueResponse.errorCode != 0) {
+  if (vl_dataValueResponse.errorCode < 0) {
     // try to find getData handler:
     if (f_EPTF_str2int_HashMap_Find(v_EPTF_DataSourceClient_dataHandlerHash,vl_handlerIdStr,vl_handlerId)) {
       // calling handler: v_fcb_EPTF_DataSourceClient_dataHandler_List[vl_handlerId]
diff --git a/src/DataSource/EPTF_CLL_DataSource_Definitions.ttcn b/src/DataSource/EPTF_CLL_DataSource_Definitions.ttcn
index 1b33eca..c06bcc3 100644
--- a/src/DataSource/EPTF_CLL_DataSource_Definitions.ttcn
+++ b/src/DataSource/EPTF_CLL_DataSource_Definitions.ttcn
@@ -1641,9 +1641,13 @@
 //      For elementary type values this argument is not used
 //
 //  Return Value:
-//    integer - error code (0 of OK, non zero if unsuccessful:
+//    integer - error code (0 if OK, non zero if unsuccessful:
 //     e.g. invalid parameters given in pl_params, or data is read-only.
-//     If error code is not zero pl_dataValue can be used to provide textual error message)
+//     For negative error codes the getDataHandlers registered by <f_EPTF_DataSourceClient_registerData>
+//     are also called to get the EPTF Variable name to process the request, since the value of any data source
+//     that have getDataHandler might also be set (if the corresponding variable can be adjusted with the value to be set)
+//     For positive error codes, the getDataHandlers are not called for the same request.
+//     If error code is positive pl_dataValue can be used to provide textual error message)
 //
 //  Detailed Comments:
 //    This function is called when <f_EPTF_DataSource_setDataValue> is requested
diff --git a/src/DsRestAPI/EPTF_CLL_DsRestAPI_Timeline_Functions.ttcn b/src/DsRestAPI/EPTF_CLL_DsRestAPI_Timeline_Functions.ttcn
index 0d7598b..9d5e83f 100644
--- a/src/DsRestAPI/EPTF_CLL_DsRestAPI_Timeline_Functions.ttcn
+++ b/src/DsRestAPI/EPTF_CLL_DsRestAPI_Timeline_Functions.ttcn
@@ -204,7 +204,7 @@
           vl_errorCode := f_EPTF_DsRestAPI_Timeline_AppendFromFile(pl_dataValue.charstringVal, pl_dataValue);
         } else {
           pl_dataValue := {charstringVal := "Charstring value expected"};
-          vl_errorCode := -5;
+          vl_errorCode := 5;
         }
       }
       case (c_DsRestAPI_Timeline_dataElementAppendFromJSON) {
@@ -212,7 +212,7 @@
           vl_errorCode := f_EPTF_DsRestAPI_Timeline_AppendFromJson(char2oct(pl_params[0].paramValue), pl_dataValue);
         } else {
           pl_dataValue := {charstringVal := "Charstring value expected"};
-          vl_errorCode := -5;
+          vl_errorCode := 5;
         }
       }
       case (c_DsRestAPI_Timeline_dataElementClear) {
@@ -235,7 +235,7 @@
           vl_errorCode := 0;
         } else {
           pl_dataValue := {charstringVal := "Boolean value expected"};
-          vl_errorCode := -5;
+          vl_errorCode := 5;
         }
       }
       case else {}
@@ -695,4 +695,4 @@
     
     return true;
   }
-}
\ No newline at end of file
+}
diff --git a/test/DataSource/EPTF_DataSource_Test_Functions.ttcn b/test/DataSource/EPTF_DataSource_Test_Functions.ttcn
index c8e2e18..19270a6 100644
--- a/test/DataSource/EPTF_DataSource_Test_Functions.ttcn
+++ b/test/DataSource/EPTF_DataSource_Test_Functions.ttcn
@@ -369,18 +369,18 @@
             (    pl_dataElement != c_EPTF_CLL_DataSourceClient_Test_DSOwnerElementName_Value 

              and pl_dataElement != c_EPTF_CLL_DataSourceClient_Test_DSOwnerElementName

              and pl_dataElement != c_EPTF_CLL_DataSourceClient_Test_DSOwnerElementName_List)) {

-        return 1; //incorrect param

+        return -1; //incorrect param

       }

       

       if (pl_dataElement == c_EPTF_CLL_DataSourceClient_Test_DSOwnerElementName_Value or pl_dataElement == c_EPTF_CLL_DataSourceClient_Test_DSOwnerElementName) {

         if (not ischosen(pl_dataValue.intVal)) {

-          return 2; //incorrect value        

+          return -2; //incorrect value        

         }

       }

       

       if (pl_dataElement == c_EPTF_CLL_DataSourceClient_Test_DSOwnerElementName_List) {

         if (not ischosen(pl_dataValue.integerlistVal)) {

-          return 2; //incorrect value        

+          return -2; //incorrect value        

         }

       }

         

@@ -392,7 +392,7 @@
       

       if (pl_dataElement == c_EPTF_CLL_DataSourceClient_Test_DSOwnerElementName or pl_dataElement == c_EPTF_CLL_DataSourceClient_Test_DSOwnerElementName_List)  {

         if (pl_result[0] == "") {  

-          return 1; //incorrect param

+          return -1; //incorrect param

         }

       }

       

@@ -1166,15 +1166,19 @@
   ) runs on EPTF_DataSourceClient_CT return integer {

     if (not match(pl_dataElement,pattern "value*")) {

       pl_dataValue := {charstringVal := log2str(%definitionId&": Custom warning: Wrong element name for DataSource "&pl_dataSource&": ",pl_dataElement)};

-      return 2; // invalid element name

+      return -2; // invalid element name

     }

     if (sizeof(pl_params)!=3) {

       pl_dataValue := {charstringVal := log2str(%definitionId&": Custom warning: Wrong number of params for Element "&pl_dataElement)};

-      return 1; // invalid number of params

+      return -1; // invalid number of params

     }

     if (pl_params[0].paramName == "read-only") {

       pl_dataValue := {charstringVal := log2str(%definitionId&": Custom warning: Data is read-only for ",pl_dataElement, " params: ", pl_params)};

-      return 2; // read-only value

+      return -2; // read-only value

+    }

+    if (pl_params[0].paramName == "read-only-2") {

+      pl_dataValue := {charstringVal := log2str(%definitionId&": Custom warning: Data is read-only for ",pl_dataElement, " params: ", pl_params)};

+      return 2; // read-only value, getData handler is not called

     }

     // store value in pl_dataValue:

     //.... do nothing, (it is not stored)

@@ -2895,6 +2899,35 @@
       f_EPTF_Base_stopAll(none);

     }

 

+    // check read-only:

+    vl_dataValue := {charstringlistVal :={"a","b"}};

+    vl_errorCode := f_EPTF_DataSource_setDataValue(

+      pl_dataValue := vl_dataValue,

+      pl_source := "DummySource",

+      pl_ptcName := pl_ptcName,

+      pl_element := "value_element-2",

+      pl_params := {

+        {

+          paramName := "read-only-2",

+          paramValue := "v21"

+        },

+        {

+          paramName := "P21",

+          paramValue := "v22"

+        },

+        {

+          paramName := "P21",

+          paramValue := "v23"

+        }

+      }

+    );

+

+    // data should be read-only

+    if (vl_errorCode!=2) {

+      setverdict(fail,"Wrong error code for DataSource, it should be read-only: 'value_element-2'");

+      f_EPTF_Base_stopAll(none);

+    }

+

     //check nonexistent source:

     vl_dataValue := {charstringlistVal :={"a","b"}};

     vl_errorCode := f_EPTF_DataSource_setDataValue(