From 3fa1224920264c0f1e39a1d1b5150fb1ea3daacb Mon Sep 17 00:00:00 2001 From: reinaortega <miguelangel.reinaortega@etsi.org> Date: Fri, 18 Jan 2019 16:05:11 +0100 Subject: [PATCH] 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> --- LibOneM2M/OneM2M_Functions.ttcn | 59 +++++++++++++++++++++++------ OneM2M_PermutationFunctions.ttcn | 4 +- OneM2M_Testcases_AE_Release_1.ttcn | 10 ++--- OneM2M_Testcases_CSE_Release_1.ttcn | 6 +-- 4 files changed, 58 insertions(+), 21 deletions(-) diff --git a/LibOneM2M/OneM2M_Functions.ttcn b/LibOneM2M/OneM2M_Functions.ttcn index 7331db2..3bdac11 100644 --- a/LibOneM2M/OneM2M_Functions.ttcn +++ b/LibOneM2M/OneM2M_Functions.ttcn @@ -1897,7 +1897,7 @@ module OneM2M_Functions { [] mccPortIn.receive(mw_request(p_requestprimitive)) -> value v_request { tc_ac.stop; setverdict(pass, __SCOPE__ & ":INFO: Expected Announcement received"); - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_); if(v_parentIndex == -1) { log(__SCOPE__&": ERROR: Target resource not found"); v_responsePrimitive := valueof(m_responsePrimitive(int4004,v_request.primitive.requestPrimitive.requestIdentifier)); @@ -2137,7 +2137,7 @@ module OneM2M_Functions { [] mccPortIn.receive(mw_request(mw_create(?,?))) -> value vc_request { tc_ac.stop; - v_parentResourceIndex := f_getResourceIndex(vc_request.primitive.requestPrimitive.to_); + v_parentResourceIndex := f_getLocalResourceIndex(vc_request.primitive.requestPrimitive.to_); if(v_parentResourceIndex == -1) { log(__SCOPE__&": ERROR: Target resource not found"); v_response := valueof(m_responsePrimitive(int4004,vc_request.primitive.requestPrimitive.requestIdentifier)); @@ -3303,7 +3303,7 @@ module OneM2M_Functions { tc_ac.stop; v_rp := v_request.primitive.requestPrimitive; - v_parentIndex := f_getResourceIndex(v_rp.to_); + v_parentIndex := f_getLocalResourceIndex(v_rp.to_); v_modifiedResource := f_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType); v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex); if(v_resourceIndex != -1) { @@ -3350,7 +3350,7 @@ module OneM2M_Functions { tc_ac.stop; v_rp := v_request.primitive.requestPrimitive; - v_parentIndex := f_getResourceIndex(v_rp.to_); + v_parentIndex := f_getLocalResourceIndex(v_rp.to_); v_modifiedResource := f_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType); v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex); if(v_resourceIndex != -1) { @@ -3774,7 +3774,7 @@ module OneM2M_Functions { } else if (p_resourceType == int23) {//subscription //notificationURI if(match(valueof(p_request.primitiveContent.subscription.notificationURI), v_defaultListOfURIs )){ - p_request.primitiveContent.subscription.notificationURI := {f_getResourceAddress(p_parentIndex)}; + p_request.primitiveContent.subscription.notificationURI := {f_getResourceAddress(f_getResourceIndex(f_getOriginator(p_parentIndex)))}; } //subscriberURI if(ispresent(p_request.primitiveContent.subscription.subscriberURI)) { @@ -4118,11 +4118,11 @@ module OneM2M_Functions { /** - * @desc Resolution of the resource index for a given resource address (URI) + * @desc Resolution of the local resource index for a given resource address (URI) * @param p_address Resource URI (can be structured/unstructured cseRelative/spRelative/absolute) * @return Internal resource index of the given resource or -1 in case of error */ - function f_getResourceIndex(in XSD.ID p_receivedURI) runs on CseSimu return integer { + function f_getLocalResourceIndex(in XSD.ID p_receivedURI) runs on CseSimu return integer { var integer v_resourceIndex := -1; var integer i; var XSD.ID v_cleanedURI; @@ -4165,6 +4165,43 @@ module OneM2M_Functions { return v_resourceIndex; } + /** + * @desc Resolution of the resource index for a given resource address (URI) + * @param p_address Resource URI (can be structured/unstructured cseRelative/spRelative/absolute) + * @return Internal resource index of the given resource or -1 in case of error + */ + function f_getResourceIndex(in XSD.ID p_receivedURI) runs on Tester return integer { + var integer v_resourceIndex := -1; + var integer i; + var XSD.ID v_cleanedURI; + + v_cleanedURI := f_resourceIdCleaner(p_receivedURI); + + if (f_isHierarchical(p_receivedURI)) { + + log("Hierarchical method: " & v_cleanedURI); + for(i:=0; i < lengthof(vc_resourcesList); i := i+1){ + + if(v_cleanedURI == f_getResourceName(vc_resourcesList[i].resource)){ + v_resourceIndex := i; + break; + } + } + + } else { + + for(i:=0; i < lengthof(vc_resourcesList); i := i+1){ + if(v_cleanedURI == f_getResourceId(vc_resourcesList[i].resource)){ + v_resourceIndex := i; + log("Non Hierarchical method: " & v_cleanedURI); + break; + } + } + } + log("Resource index found: " & int2str(v_resourceIndex)); + return v_resourceIndex; + } + /** * @desc Resolution of the resource address field (to) for a given resource depending on addressing and hierarchical format * @param p_targetResourceIndex Internal resource index of the given resource @@ -5075,7 +5112,7 @@ module OneM2M_Functions { var integer v_localResourceIndex := -1; var PrimitiveContent v_localResource; - v_parentIndex := f_getResourceIndex(p_request.to_); + v_parentIndex := f_getLocalResourceIndex(p_request.to_); if(v_parentIndex == -1) { setverdict(inconc,__SCOPE__&": ERROR: Target resource not found"); vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier)); @@ -5101,7 +5138,7 @@ module OneM2M_Functions { function f_processUpdateRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer { var integer v_targetLocalResourceIndex := -1; - v_targetLocalResourceIndex := f_getResourceIndex(p_request.to_); + v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_); if(v_targetLocalResourceIndex == -1) { setverdict(inconc,__SCOPE__&": ERROR: Target resource not found"); vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier)); @@ -5125,7 +5162,7 @@ module OneM2M_Functions { function f_processRetrieveRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer { var integer v_targetLocalResourceIndex := -1; - v_targetLocalResourceIndex := f_getResourceIndex(p_request.to_); + v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_); if(v_targetLocalResourceIndex == -1) { setverdict(inconc,__SCOPE__&": ERROR: Target resource not found"); vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier)); @@ -5148,7 +5185,7 @@ module OneM2M_Functions { function f_processDeleteRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer { var integer v_targetLocalResourceIndex := -1; - v_targetLocalResourceIndex := f_getResourceIndex(p_request.to_); + v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_); if(v_targetLocalResourceIndex == -1) { setverdict(inconc,__SCOPE__&": ERROR: Target resource not found"); vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier)); diff --git a/OneM2M_PermutationFunctions.ttcn b/OneM2M_PermutationFunctions.ttcn index 6881aa0..fb12fa0 100644 --- a/OneM2M_PermutationFunctions.ttcn +++ b/OneM2M_PermutationFunctions.ttcn @@ -698,7 +698,7 @@ module OneM2M_PermutationFunctions { [] mcaPortIn.receive(mw_request(p_request)) -> value v_request { tc_ac.stop; setverdict(pass, __SCOPE__ & " : Subscription creation request is accepted!"); - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_); v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType); v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex); v_responsePrimitive := valueof(m_responsePrimitive(int2001, v_request.primitive.requestPrimitive.requestIdentifier, vc_localResourcesList[v_resourceIndex].resource)); @@ -7323,7 +7323,7 @@ module OneM2M_PermutationFunctions { tc_ac.stop; setverdict(pass, __SCOPE__ & ":INFO: RemoteCSE UPDATE received"); - v_localResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + v_localResourceIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_); if(v_localResourceIndex == -1) { log(__SCOPE__&": ERROR: Resource Index not valid, target not found"); diff --git a/OneM2M_Testcases_AE_Release_1.ttcn b/OneM2M_Testcases_AE_Release_1.ttcn index e63ec36..c8db4c9 100644 --- a/OneM2M_Testcases_AE_Release_1.ttcn +++ b/OneM2M_Testcases_AE_Release_1.ttcn @@ -1952,7 +1952,7 @@ module OneM2M_Testcases_AE_Release_1 { [] mcaPortIn.receive(mw_request(mw_createSubscription)) -> value v_request { tc_ac.stop; setverdict(pass, __SCOPE__ & " : Subscription creation request is accepted!"); - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_); v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType); v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex); 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 { [] mcaPortIn.receive(mw_request(mw_createAe)) -> value v_request { tc_ac.stop; setverdict(pass, __SCOPE__ & " : AE registration request is accepted!!"); - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_); v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType); v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex); 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 { [] mcaPortIn.receive(mw_request(mw_createSubscription)) -> value v_request { tc_ac.stop; setverdict(pass, __SCOPE__ & " : Subscription creation request is accepted!"); - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_); v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType); v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex); 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 { [] mcaPortIn.receive(mw_request(mw_createAe)) -> value v_request { tc_ac.stop; setverdict(pass, __SCOPE__ & " : AE registration request is accepted!!"); - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_); v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType); v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex); 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 { [] mcaPortIn.receive(mw_request(mw_createSubscription)) -> value v_request { tc_ac.stop; setverdict(pass, __SCOPE__ & " : Subscription creation request is accepted!"); - v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_); v_resource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType); v_resourceIndex := f_setLocalResource(v_resource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex); v_responsePrimitive := valueof(m_responsePrimitive(int2001, v_request.primitive.requestPrimitive.requestIdentifier, vc_localResourcesList[v_resourceIndex].resource)); diff --git a/OneM2M_Testcases_CSE_Release_1.ttcn b/OneM2M_Testcases_CSE_Release_1.ttcn index 947235a..f755996 100644 --- a/OneM2M_Testcases_CSE_Release_1.ttcn +++ b/OneM2M_Testcases_CSE_Release_1.ttcn @@ -1847,7 +1847,7 @@ module OneM2M_Testcases_CSE_Release_1 { [not(v_cseRegistered)] mccPortIn.receive(mw_request(mw_createRemoteCSE)) -> value v_request { tc_ac.stop; setverdict(pass, __SCOPE__&":INFO: CREATE remoteCSE request received"); - v_parentResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + v_parentResourceIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_); if(v_parentResourceIndex == -1) { log(__SCOPE__&": ERROR: Target resource not found"); v_response := valueof(m_responsePrimitive(int4004,v_request.primitive.requestPrimitive.requestIdentifier)); @@ -2752,7 +2752,7 @@ module OneM2M_Testcases_CSE_Release_1 { alt { [] mccPortIn.receive(mw_request(mw_retrieve(?))) -> value v_request { tc_ac.stop; - v_localResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + v_localResourceIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_); if(v_localResourceIndex == -1) { setverdict(fail, __SCOPE__ & ": ERROR: Retrieve request target not found"); @@ -3298,7 +3298,7 @@ module OneM2M_Testcases_CSE_Release_1 { alt { [] mccPortIn.receive(mw_request(mw_delete(?, PX_CSE_ID))) -> value v_request { tc_ac.stop; - v_localResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + v_localResourceIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_); if(v_localResourceIndex == -1) { setverdict(fail, __SCOPE__&": ERROR: Delete request target not found"); -- GitLab