Commit 3fa1224920264c0f1e39a1d1b5150fb1ea3daacb

Authored by Miguel Angel Reina Ortega
1 parent 413b9ad6

Implementation of function f_getLocalResourceIndex

Functions f_getLocalResourceIndex and f_getResourceIndex look for the
index of a given resource in vc_localResourcesList or vc_resourcesList,
respectively

Signed-off-by: reinaortega <miguelangel.reinaortega@etsi.org>
... ... @@ -1897,7 +1897,7 @@ module OneM2M_Functions {
1897 1897 [] mccPortIn.receive(mw_request(p_requestprimitive)) -> value v_request {
1898 1898 tc_ac.stop;
1899 1899 setverdict(pass, __SCOPE__ & ":INFO: Expected Announcement received");
1900   - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
  1900 + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
1901 1901 if(v_parentIndex == -1) {
1902 1902 log(__SCOPE__&": ERROR: Target resource not found");
1903 1903 v_responsePrimitive := valueof(m_responsePrimitive(int4004,v_request.primitive.requestPrimitive.requestIdentifier));
... ... @@ -2137,7 +2137,7 @@ module OneM2M_Functions {
2137 2137 [] mccPortIn.receive(mw_request(mw_create(?,?))) -> value vc_request {
2138 2138 tc_ac.stop;
2139 2139  
2140   - v_parentResourceIndex := f_getResourceIndex(vc_request.primitive.requestPrimitive.to_);
  2140 + v_parentResourceIndex := f_getLocalResourceIndex(vc_request.primitive.requestPrimitive.to_);
2141 2141 if(v_parentResourceIndex == -1) {
2142 2142 log(__SCOPE__&": ERROR: Target resource not found");
2143 2143 v_response := valueof(m_responsePrimitive(int4004,vc_request.primitive.requestPrimitive.requestIdentifier));
... ... @@ -3303,7 +3303,7 @@ module OneM2M_Functions {
3303 3303 tc_ac.stop;
3304 3304  
3305 3305 v_rp := v_request.primitive.requestPrimitive;
3306   - v_parentIndex := f_getResourceIndex(v_rp.to_);
  3306 + v_parentIndex := f_getLocalResourceIndex(v_rp.to_);
3307 3307 v_modifiedResource := f_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
3308 3308 v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex);
3309 3309 if(v_resourceIndex != -1) {
... ... @@ -3350,7 +3350,7 @@ module OneM2M_Functions {
3350 3350 tc_ac.stop;
3351 3351  
3352 3352 v_rp := v_request.primitive.requestPrimitive;
3353   - v_parentIndex := f_getResourceIndex(v_rp.to_);
  3353 + v_parentIndex := f_getLocalResourceIndex(v_rp.to_);
3354 3354 v_modifiedResource := f_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
3355 3355 v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex);
3356 3356 if(v_resourceIndex != -1) {
... ... @@ -3774,7 +3774,7 @@ module OneM2M_Functions {
3774 3774 } else if (p_resourceType == int23) {//subscription
3775 3775 //notificationURI
3776 3776 if(match(valueof(p_request.primitiveContent.subscription.notificationURI), v_defaultListOfURIs )){
3777   - p_request.primitiveContent.subscription.notificationURI := {f_getResourceAddress(p_parentIndex)};
  3777 + p_request.primitiveContent.subscription.notificationURI := {f_getResourceAddress(f_getResourceIndex(f_getOriginator(p_parentIndex)))};
3778 3778 }
3779 3779 //subscriberURI
3780 3780 if(ispresent(p_request.primitiveContent.subscription.subscriberURI)) {
... ... @@ -4118,11 +4118,11 @@ module OneM2M_Functions {
4118 4118  
4119 4119  
4120 4120 /**
4121   - * @desc Resolution of the resource index for a given resource address (URI)
  4121 + * @desc Resolution of the local resource index for a given resource address (URI)
4122 4122 * @param p_address Resource URI (can be structured/unstructured cseRelative/spRelative/absolute)
4123 4123 * @return Internal resource index of the given resource or -1 in case of error
4124 4124 */
4125   - function f_getResourceIndex(in XSD.ID p_receivedURI) runs on CseSimu return integer {
  4125 + function f_getLocalResourceIndex(in XSD.ID p_receivedURI) runs on CseSimu return integer {
4126 4126 var integer v_resourceIndex := -1;
4127 4127 var integer i;
4128 4128 var XSD.ID v_cleanedURI;
... ... @@ -4166,6 +4166,43 @@ module OneM2M_Functions {
4166 4166 }
4167 4167  
4168 4168 /**
  4169 + * @desc Resolution of the resource index for a given resource address (URI)
  4170 + * @param p_address Resource URI (can be structured/unstructured cseRelative/spRelative/absolute)
  4171 + * @return Internal resource index of the given resource or -1 in case of error
  4172 + */
  4173 + function f_getResourceIndex(in XSD.ID p_receivedURI) runs on Tester return integer {
  4174 + var integer v_resourceIndex := -1;
  4175 + var integer i;
  4176 + var XSD.ID v_cleanedURI;
  4177 +
  4178 + v_cleanedURI := f_resourceIdCleaner(p_receivedURI);
  4179 +
  4180 + if (f_isHierarchical(p_receivedURI)) {
  4181 +
  4182 + log("Hierarchical method: " & v_cleanedURI);
  4183 + for(i:=0; i < lengthof(vc_resourcesList); i := i+1){
  4184 +
  4185 + if(v_cleanedURI == f_getResourceName(vc_resourcesList[i].resource)){
  4186 + v_resourceIndex := i;
  4187 + break;
  4188 + }
  4189 + }
  4190 +
  4191 + } else {
  4192 +
  4193 + for(i:=0; i < lengthof(vc_resourcesList); i := i+1){
  4194 + if(v_cleanedURI == f_getResourceId(vc_resourcesList[i].resource)){
  4195 + v_resourceIndex := i;
  4196 + log("Non Hierarchical method: " & v_cleanedURI);
  4197 + break;
  4198 + }
  4199 + }
  4200 + }
  4201 + log("Resource index found: " & int2str(v_resourceIndex));
  4202 + return v_resourceIndex;
  4203 + }
  4204 +
  4205 + /**
4169 4206 * @desc Resolution of the resource address field (to) for a given resource depending on addressing and hierarchical format
4170 4207 * @param p_targetResourceIndex Internal resource index of the given resource
4171 4208 * @return Resource address for the given resource
... ... @@ -5075,7 +5112,7 @@ module OneM2M_Functions {
5075 5112 var integer v_localResourceIndex := -1;
5076 5113 var PrimitiveContent v_localResource;
5077 5114  
5078   - v_parentIndex := f_getResourceIndex(p_request.to_);
  5115 + v_parentIndex := f_getLocalResourceIndex(p_request.to_);
5079 5116 if(v_parentIndex == -1) {
5080 5117 setverdict(inconc,__SCOPE__&": ERROR: Target resource not found");
5081 5118 vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
... ... @@ -5101,7 +5138,7 @@ module OneM2M_Functions {
5101 5138 function f_processUpdateRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
5102 5139 var integer v_targetLocalResourceIndex := -1;
5103 5140  
5104   - v_targetLocalResourceIndex := f_getResourceIndex(p_request.to_);
  5141 + v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_);
5105 5142 if(v_targetLocalResourceIndex == -1) {
5106 5143 setverdict(inconc,__SCOPE__&": ERROR: Target resource not found");
5107 5144 vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
... ... @@ -5125,7 +5162,7 @@ module OneM2M_Functions {
5125 5162 function f_processRetrieveRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
5126 5163 var integer v_targetLocalResourceIndex := -1;
5127 5164  
5128   - v_targetLocalResourceIndex := f_getResourceIndex(p_request.to_);
  5165 + v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_);
5129 5166 if(v_targetLocalResourceIndex == -1) {
5130 5167 setverdict(inconc,__SCOPE__&": ERROR: Target resource not found");
5131 5168 vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
... ... @@ -5148,7 +5185,7 @@ module OneM2M_Functions {
5148 5185 function f_processDeleteRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
5149 5186 var integer v_targetLocalResourceIndex := -1;
5150 5187  
5151   - v_targetLocalResourceIndex := f_getResourceIndex(p_request.to_);
  5188 + v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_);
5152 5189 if(v_targetLocalResourceIndex == -1) {
5153 5190 setverdict(inconc,__SCOPE__&": ERROR: Target resource not found");
5154 5191 vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
... ...
... ... @@ -698,7 +698,7 @@ module OneM2M_PermutationFunctions {
698 698 [] mcaPortIn.receive(mw_request(p_request)) -> value v_request {
699 699 tc_ac.stop;
700 700 setverdict(pass, __SCOPE__ & " : Subscription creation request is accepted!");
701   - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
  701 + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
702 702 v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType);
703 703 v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex);
704 704 v_responsePrimitive := valueof(m_responsePrimitive(int2001, v_request.primitive.requestPrimitive.requestIdentifier, vc_localResourcesList[v_resourceIndex].resource));
... ... @@ -7323,7 +7323,7 @@ module OneM2M_PermutationFunctions {
7323 7323 tc_ac.stop;
7324 7324 setverdict(pass, __SCOPE__ & ":INFO: RemoteCSE UPDATE received");
7325 7325  
7326   - v_localResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
  7326 + v_localResourceIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
7327 7327 if(v_localResourceIndex == -1)
7328 7328 {
7329 7329 log(__SCOPE__&": ERROR: Resource Index not valid, target not found");
... ...
... ... @@ -1952,7 +1952,7 @@ module OneM2M_Testcases_AE_Release_1 {
1952 1952 [] mcaPortIn.receive(mw_request(mw_createSubscription)) -> value v_request {
1953 1953 tc_ac.stop;
1954 1954 setverdict(pass, __SCOPE__ & " : Subscription creation request is accepted!");
1955   - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
  1955 + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
1956 1956 v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType);
1957 1957 v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex);
1958 1958 v_responsePrimitive := valueof(m_responsePrimitive(int2001, v_request.primitive.requestPrimitive.requestIdentifier, vc_localResourcesList[v_resourceIndex].resource));
... ... @@ -2154,7 +2154,7 @@ module OneM2M_Testcases_AE_Release_1 {
2154 2154 [] mcaPortIn.receive(mw_request(mw_createAe)) -> value v_request {
2155 2155 tc_ac.stop;
2156 2156 setverdict(pass, __SCOPE__ & " : AE registration request is accepted!!");
2157   - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
  2157 + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
2158 2158 v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType);
2159 2159 v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex);
2160 2160 v_responsePrimitive := valueof(m_responsePrimitive(int2001, v_request.primitive.requestPrimitive.requestIdentifier, vc_localResourcesList[v_resourceIndex].resource));
... ... @@ -2186,7 +2186,7 @@ module OneM2M_Testcases_AE_Release_1 {
2186 2186 [] mcaPortIn.receive(mw_request(mw_createSubscription)) -> value v_request {
2187 2187 tc_ac.stop;
2188 2188 setverdict(pass, __SCOPE__ & " : Subscription creation request is accepted!");
2189   - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
  2189 + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
2190 2190 v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType);
2191 2191 v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex);
2192 2192 v_responsePrimitive := valueof(m_responsePrimitive(int2001, v_request.primitive.requestPrimitive.requestIdentifier, vc_localResourcesList[v_resourceIndex].resource));
... ... @@ -2265,7 +2265,7 @@ module OneM2M_Testcases_AE_Release_1 {
2265 2265 [] mcaPortIn.receive(mw_request(mw_createAe)) -> value v_request {
2266 2266 tc_ac.stop;
2267 2267 setverdict(pass, __SCOPE__ & " : AE registration request is accepted!!");
2268   - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
  2268 + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
2269 2269 v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType);
2270 2270 v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex);
2271 2271 v_responsePrimitive := valueof(m_responsePrimitive(int2001, v_request.primitive.requestPrimitive.requestIdentifier, vc_localResourcesList[v_resourceIndex].resource));
... ... @@ -2297,7 +2297,7 @@ module OneM2M_Testcases_AE_Release_1 {
2297 2297 [] mcaPortIn.receive(mw_request(mw_createSubscription)) -> value v_request {
2298 2298 tc_ac.stop;
2299 2299 setverdict(pass, __SCOPE__ & " : Subscription creation request is accepted!");
2300   - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
  2300 + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
2301 2301 v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType);
2302 2302 v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex);
2303 2303 v_responsePrimitive := valueof(m_responsePrimitive(int2001, v_request.primitive.requestPrimitive.requestIdentifier, vc_localResourcesList[v_resourceIndex].resource));
... ...
... ... @@ -1847,7 +1847,7 @@ module OneM2M_Testcases_CSE_Release_1 {
1847 1847 [not(v_cseRegistered)] mccPortIn.receive(mw_request(mw_createRemoteCSE)) -> value v_request {
1848 1848 tc_ac.stop;
1849 1849 setverdict(pass, __SCOPE__&":INFO: CREATE remoteCSE request received");
1850   - v_parentResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
  1850 + v_parentResourceIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
1851 1851 if(v_parentResourceIndex == -1) {
1852 1852 log(__SCOPE__&": ERROR: Target resource not found");
1853 1853 v_response := valueof(m_responsePrimitive(int4004,v_request.primitive.requestPrimitive.requestIdentifier));
... ... @@ -2752,7 +2752,7 @@ module OneM2M_Testcases_CSE_Release_1 {
2752 2752 alt {
2753 2753 [] mccPortIn.receive(mw_request(mw_retrieve(?))) -> value v_request {
2754 2754 tc_ac.stop;
2755   - v_localResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
  2755 + v_localResourceIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
2756 2756 if(v_localResourceIndex == -1)
2757 2757 {
2758 2758 setverdict(fail, __SCOPE__ & ": ERROR: Retrieve request target not found");
... ... @@ -3298,7 +3298,7 @@ module OneM2M_Testcases_CSE_Release_1 {
3298 3298 alt {
3299 3299 [] mccPortIn.receive(mw_request(mw_delete(?, PX_CSE_ID))) -> value v_request {
3300 3300 tc_ac.stop;
3301   - v_localResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
  3301 + v_localResourceIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
3302 3302 if(v_localResourceIndex == -1)
3303 3303 {
3304 3304 setverdict(fail, __SCOPE__&": ERROR: Delete request target not found");
... ...