From 535e16b5a667a6092dd84a611d746ccb1df6b3f8 Mon Sep 17 00:00:00 2001
From: reinaortega <miguelangel.reinaortega@etsi.org>
Date: Thu, 20 Feb 2020 23:45:02 +0100
Subject: [PATCH] Fix #84

Signed-off-by: reinaortega <miguelangel.reinaortega@etsi.org>
---
 OneM2M_PermutationFunctions.ttcn | 312 +++++++++++++++++++++++--------
 1 file changed, 237 insertions(+), 75 deletions(-)

diff --git a/OneM2M_PermutationFunctions.ttcn b/OneM2M_PermutationFunctions.ttcn
index 81fe3ed..74db44c 100644
--- a/OneM2M_PermutationFunctions.ttcn
+++ b/OneM2M_PermutationFunctions.ttcn
@@ -2957,6 +2957,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
+						var integer v_parentIndex := -1;
 										   
 						// Test control
 				
@@ -2971,7 +2972,10 @@ module OneM2M_PermutationFunctions {
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 									
 						// Test Body
-						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_parentIndex);
 						
 						f_send(e_mcaPort, m_request(v_request));
 						tc_ac.start;
@@ -2980,7 +2984,7 @@ module OneM2M_PermutationFunctions {
 								tc_ac.stop;
 								setverdict(pass, __SCOPE__ & ": Resource type " & int2str(enum2int(p_resourceType)) & " created successfully");
 								f_checkAttributesToBeSaved(p_resourceType, v_request, vc_response.primitive.responsePrimitive);
-								v_resourceIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, p_resourceType, v_aeIndex);
+								v_resourceIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, p_resourceType, v_parentIndex);
 							}
 							[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
 								tc_ac.stop;
@@ -3019,8 +3023,9 @@ module OneM2M_PermutationFunctions {
 						var MsgIn v_response;
 						var RequestPrimitive v_request;
 						var integer v_aeIndex := -1;
-						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_resourceIndex := -1;
+						var integer v_parentIndex := -1;
     										   
 						// Test control
     				
@@ -3034,13 +3039,16 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 	
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 	
 						
 						if(p_resourceType == int15) {
 							v_request := f_getCreateRequestPrimitive(int3, m_createContainerBase, v_aeIndex);
 							v_request.primitiveContent.container.resourceName := vc_resourcesList[v_resourceIndex].resource.pollingChannel.resourceName;
 						} else {
-							v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
+							v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_parentIndex);
 						}
 												    									
 						// Test Body
@@ -3085,6 +3093,7 @@ module OneM2M_PermutationFunctions {
 						var RequestPrimitive v_request;
 						var integer v_acpAuxIndex := -1;
 						var integer v_aeIndex := -1;
+						var integer v_parentIndex := -1;
 											   
 						// Test control
 						if(not(PICS_ACP_SUPPORT)) {
@@ -3107,7 +3116,10 @@ module OneM2M_PermutationFunctions {
 						v_aeIndex := f_cse_preamble_registerAe({f_getResourceId(vc_resourcesList[v_acpAuxIndex].resource)}, -);
 						
 						// Test Body
-						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_parentIndex);
 						
 						f_send(e_mcaPort, m_request(v_request));
 						tc_ac.start;
@@ -3615,6 +3627,7 @@ module OneM2M_PermutationFunctions {
 						var RequestPrimitive v_request;
 						var integer v_aeIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
 											   
 						// Test control
     				
@@ -3629,7 +3642,10 @@ module OneM2M_PermutationFunctions {
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 					
 						// Test Body
-						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_parentIndex);
 						v_request.resultContent := int0;//Attributes
 						
 						f_send(e_mcaPort, m_request(v_request));
@@ -3671,6 +3687,7 @@ module OneM2M_PermutationFunctions {
 						var RequestPrimitive v_request;
 						var integer v_aeIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
 											   
 						// Test control
     				
@@ -3685,7 +3702,10 @@ module OneM2M_PermutationFunctions {
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 					
 						// Test Body
-						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_parentIndex);
 						v_request.resultContent := int2;//Attributes
 						
 						f_send(e_mcaPort, m_request(v_request));
@@ -3732,6 +3752,7 @@ module OneM2M_PermutationFunctions {
 						var RequestPrimitive v_request;
 						var integer v_aeIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
 											   
 						// Test control
     				
@@ -3746,7 +3767,10 @@ module OneM2M_PermutationFunctions {
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 											
 						// Test Body
-						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_parentIndex);
 						v_request.resultContent := int3;//Attributes + Hierarchichal Address
 						
 						f_send(e_mcaPort, m_request(v_request));
@@ -3841,6 +3865,7 @@ module OneM2M_PermutationFunctions {
 						var RequestPrimitive v_request;
 						var integer v_aeIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
 											   
 						// Test control
     				
@@ -3855,7 +3880,10 @@ module OneM2M_PermutationFunctions {
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 											
 						// Test Body
-						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_parentIndex);
 						v_request.resultContent := int1;//Attributes
 						
 						f_send(e_mcaPort, m_request(v_request));
@@ -3898,6 +3926,7 @@ module OneM2M_PermutationFunctions {
 						var RequestPrimitive v_request;
 						var integer v_aeIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
 											   
 						// Test control
     				
@@ -3912,7 +3941,10 @@ module OneM2M_PermutationFunctions {
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 											
 						// Test Body
-						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_parentIndex);
 						v_request.resultContent := int9;//Modified Attributes
 						
 						f_send(e_mcaPort, m_request(v_request));
@@ -4041,7 +4073,7 @@ module OneM2M_PermutationFunctions {
 							vc_cse1.start(f_cse_announcementProcedure_createHandler());
 							v_parentIndex := f_cse_createResource(int3, v_create, v_aeIndex);
 							f_aeSimu_checkComponentDoneAndGetVerdict(vc_cse1);
-					  } else {
+					  } else if (p_resourceType != int18) {
 							v_parentIndex := v_aeIndex;
 						}
 					
@@ -4088,7 +4120,7 @@ module OneM2M_PermutationFunctions {
 							vc_cse1.start(f_cse_announcementProcedure_createHandler());
 							v_parentIndex := f_cse_createResource(int3, v_create, v_aeIndex);
 							f_aeSimu_checkComponentDoneAndGetVerdict(vc_cse1);
-					  } else {
+					  } else if (p_resourceType != int18) {
 							v_parentIndex := v_aeIndex;
 						}
 	
@@ -4136,7 +4168,7 @@ module OneM2M_PermutationFunctions {
 						if(p_resourceType == int4) {	//ContentInstance
 							v_containerIndex := f_cse_createResource(int3, m_createContainerBase, v_aeIndex);
 							v_parentIndex := v_containerIndex;
-						}else{
+						} else if (p_resourceType != int18) {
 							v_parentIndex := v_aeIndex;
 						}
     									
@@ -4177,6 +4209,7 @@ module OneM2M_PermutationFunctions {
 						return v_response.primitive.responsePrimitive;
     				
 					}//end f_CSE_DMR_RET_001
+					
 					function f_CSE_DMR_RET_003(ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive) runs on AeSimu system CseSystem {
     				
 						// Local variables
@@ -4185,6 +4218,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_acpAuxIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
     										   
 						// Test control
 						if(not(PICS_ACP_SUPPORT)) {
@@ -4207,7 +4241,10 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 										
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 	
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 	
 
 						// Test Body
 						f_send(e_mcaPort, m_request(m_retrieve(f_getResourceAddress(v_resourceIndex), f_getOriginator(v_resourceIndex))));
@@ -4247,6 +4284,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
     										   
 						// Test control
     				
@@ -4260,7 +4298,11 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 				
     									
 						// Test Body
 						f_send(e_mcaPort, m_request(m_retrieveAttributeToOption(f_getResourceAddress(v_resourceIndex) & v_attribute, f_getOriginator(v_resourceIndex))));
@@ -4303,6 +4345,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
     										   
 						// Test control
     				
@@ -4316,7 +4359,10 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 				
     									
 						// Test Body
 						f_send(e_mcaPort, m_request(m_retrieveAttributeContentOption(f_getResourceAddress(v_resourceIndex) ,	{"pi"}, f_getOriginator(v_resourceIndex))));
@@ -4359,6 +4405,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
     										   
 						// Test control
     				
@@ -4372,7 +4419,11 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 				
     									
 						// Test Body
 						f_send(e_mcaPort, m_request(m_retrieveAttributeContentOption(f_getResourceAddress(v_resourceIndex) ,
@@ -4416,6 +4467,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
 											   
 						// Test control
     				
@@ -4429,7 +4481,10 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 				
     									
 						// Test Body
 						f_send(e_mcaPort, m_request(m_retrieveAttributeContentOption(f_getResourceAddress(v_resourceIndex),
@@ -4469,6 +4524,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
 											   
 						// Test control
     				
@@ -4482,7 +4538,11 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 				
     									
 						// Test Body
 						f_send(e_mcaPort, m_request(m_retrieveAttributeContentOption(f_getResourceAddress(v_resourceIndex),
@@ -4731,7 +4791,11 @@ module OneM2M_PermutationFunctions {
 							f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 						
 							v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive);//under the CSEBase resource
-    									
+
+							if (p_resourceType==int2){
+								v_aeIndex := v_resourceIndex;
+							}
+										
 						} else {
 							vc_cse1.start(f_cse_registerRemoteCse(p_requestPrimitive));
 							vc_cse1.done;
@@ -4813,7 +4877,11 @@ module OneM2M_PermutationFunctions {
 							f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 							
 							v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive);//under the CSEBase resource
-    									
+
+							if (p_resourceType==int2){
+								v_aeIndex := v_resourceIndex;
+							}
+							    									
 						}else{
 							vc_cse1.start(f_cse_registerRemoteCse(p_requestPrimitive));
 							vc_cse1.done;
@@ -4894,7 +4962,11 @@ module OneM2M_PermutationFunctions {
 							f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, p_resourceType);
 							
 							v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive);//under the CSEBase resource
-    									
+							
+							if (p_resourceType==int2){
+								v_aeIndex := v_resourceIndex;
+							}
+										
 						}else{
 							vc_cse1.start(f_cse_registerRemoteCse(p_requestPrimitive));
 							vc_cse1.done;
@@ -4977,6 +5049,10 @@ module OneM2M_PermutationFunctions {
 							
 							v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive);//under the CSEBase resource
     									
+							if (p_resourceType==int2){
+								v_aeIndex := v_resourceIndex;
+							}
+							
 						}else{
 							vc_cse1.start(f_cse_registerRemoteCse(p_requestPrimitive));
 							vc_cse1.done;
@@ -5055,6 +5131,10 @@ module OneM2M_PermutationFunctions {
 							
 							v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive);//under the CSEBase resource
     									
+							if (p_resourceType==int2){
+								v_aeIndex := v_resourceIndex;
+							}
+							
 						}else{
 							vc_cse1.start(f_cse_registerRemoteCse(p_requestPrimitive));
 							vc_cse1.done;
@@ -5156,7 +5236,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_childResourceIndex := -1;
-								   
+						var integer v_parentIndex := -1;		   
 						// Test control
 		
 						// Test component configuration
@@ -5175,7 +5255,10 @@ module OneM2M_PermutationFunctions {
 							}
 						} 
 	
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 
 		
 						if(p_resourceType != int15) {
 							v_childResourceIndex := f_cse_createResource(valueof(p_childResourceType), p_childRequestPrimitive, v_resourceIndex);				
@@ -5225,6 +5308,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_childResourceIndex := -1;
+						var integer v_parentIndex := -1;
 								   
 						// Test control
 		
@@ -5244,7 +5328,10 @@ module OneM2M_PermutationFunctions {
 							}
 						} 
 							
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex);
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex);
 	
 						if(p_resourceType != int15) {
 							v_childResourceIndex := f_cse_createResource(valueof(p_childResourceType), p_childRequestPrimitive, v_resourceIndex);					
@@ -5294,6 +5381,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_childResourceIndex := -1;
+						var integer v_parentIndex := -1;
 								   
 						// Test control
 		
@@ -5313,8 +5401,10 @@ module OneM2M_PermutationFunctions {
 							}
 						} 
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 
-					
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 
 		
 						if(p_resourceType != int15) {
 							v_childResourceIndex := f_cse_createResource(valueof(p_childResourceType), p_childRequestPrimitive, v_resourceIndex);					
@@ -5364,6 +5454,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_childResourceIndex := -1;
+						var integer v_parentIndex := -1;
 								   
 						// Test control
 		
@@ -5383,7 +5474,10 @@ module OneM2M_PermutationFunctions {
 							}
 						} 
 							
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 				
 		
 						if(p_resourceType != int15) {
 							v_childResourceIndex := f_cse_createResource(valueof(p_childResourceType), p_childRequestPrimitive, v_resourceIndex);				
@@ -5433,6 +5527,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_childResourceIndex := -1;
+						var integer v_parentIndex := -1;
 								   
 						// Test control
 		
@@ -5452,7 +5547,10 @@ module OneM2M_PermutationFunctions {
 							}
 						}
 							
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 				
 		
 						if(p_resourceType != int15) {
 							v_childResourceIndex := f_cse_createResource(valueof(p_childResourceType), p_childRequestPrimitive, v_resourceIndex);				
@@ -5504,6 +5602,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
     										   
 						// Test control
     				
@@ -5517,7 +5616,10 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_createRequestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_parentIndex); 				
     									
 						// Test Body
 						v_request := f_getUpdateRequestPrimitive(p_resourceType, v_resourceIndex, p_updateRequestPrimitive);
@@ -5565,7 +5667,8 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
-    										   
+    					var integer v_parentIndex := -1;
+    					
 						// Test control
     				
 						// Test component configuration
@@ -5578,7 +5681,10 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_createRequestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_parentIndex); 				
     									
 						// Test Body
 						v_request := f_getUpdateRequestPrimitive(p_resourceType, v_resourceIndex, p_updateRequestPrimitive);
@@ -5623,6 +5729,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
     										   
 						// Test control
     				
@@ -5636,7 +5743,10 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_createRequestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_parentIndex); 				
 						
 						//f_match2PrimitiveContent(vc_resourcesList[v_resourceIndex].resource, p_createRequestPrimitive.primitiveContent); TODO fix the match problem
     						
@@ -5683,6 +5793,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
     										   
 						// Test control
     				
@@ -5696,7 +5807,10 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_createRequestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_parentIndex); 				
     					
 						// Test Body
 						v_request := f_getUpdateRequestPrimitive(p_resourceType, v_resourceIndex, p_updateRequestPrimitive);
@@ -5742,6 +5856,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_acpAuxIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
     										   
 						// Test control
 						if(not(PICS_ACP_SUPPORT)) {
@@ -5761,7 +5876,10 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_createRequestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_parentIndex); 				
 																
 						// Test Body
 						v_request := f_getUpdateRequestPrimitive(p_resourceType, v_resourceIndex, p_updateRequestPrimitive);
@@ -5804,6 +5922,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
     										   
 						// Test control
     				
@@ -5817,7 +5936,10 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_createRequestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_parentIndex); 				
 																
 						// Test Body
 						v_request := f_getUpdateRequestPrimitive(p_resourceType, v_resourceIndex, p_updateRequestPrimitive);
@@ -5860,6 +5982,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
     										   
 						// Test control
     				
@@ -5873,7 +5996,10 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_createRequestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_parentIndex); 				
 																
 						// Test Body
 						v_request := f_getUpdateRequestPrimitive(p_resourceType, v_resourceIndex, p_updateRequestPrimitive);
@@ -5916,6 +6042,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
+						var integer v_parentIndex := -1;
 												   
 						// Test control
 	    				
@@ -5929,7 +6056,10 @@ module OneM2M_PermutationFunctions {
 							
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_createRequestPrimitive, p_resourceType);
 							
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive , v_aeIndex);
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive , v_parentIndex);
 	
 						// Test Body
 						v_request := f_getUpdateRequestPrimitive(p_resourceType, v_resourceIndex, p_updateRequestPrimitive);
@@ -6309,7 +6439,6 @@ module OneM2M_PermutationFunctions {
 					
 				function f_CSE_DMR_UPD_017(ResourceType p_resourceType, template RequestPrimitive p_requestCreatePrimitive, template RequestPrimitive p_createRequestAnnc, template RequestPrimitive p_requestUpdatePrimitive) runs on CseSimu system CseSystem {
 					// Local variables
-					var AeSimu v_ae1 := AeSimu.create("AE1") alive;
 					var MsgIn v_request;
 					var RequestPrimitive v_requestUpdatePrimitive;
 					var integer v_parentIndex := -1;
@@ -6330,19 +6459,23 @@ module OneM2M_PermutationFunctions {
 		
 					//Preamble
 		
-					v_ae1.start(f_cse_createResource(int2,v_create));					
+					vc_ae1.start(f_cse_createResource(int2,v_create));					
 					f_cse_announcementProcedure_createHandler(mw_createAEAnnc(-, -, -));		
-					v_ae1.done;
-		
-					v_aeIndex:= f_getLatestResourceIndex(v_ae1);
+					f_cseSimu_checkComponentDoneAndGetVerdict(vc_ae1);
 					
-					v_ae1.start(f_cse_createResource(p_resourceType, p_requestCreatePrimitive, v_aeIndex));
-					v_ae1.done;					
-			
-					v_latestResourceIndex := f_getLatestResourceIndex(v_ae1);
+					v_aeIndex:= f_getLatestResourceIndex(vc_ae1);
+					
+					if(p_resourceType != int18) {
+						v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+					}
+					
+					vc_ae1.start(f_cse_createResource(p_resourceType, p_requestCreatePrimitive, v_parentIndex));
+					f_cseSimu_checkComponentDoneAndGetVerdict(vc_ae1);
+					
+					v_latestResourceIndex := f_getLatestResourceIndex(vc_ae1);
 		
 					// Test Body
-					v_ae1.start(f_cse_updateResource(p_resourceType, v_latestResourceIndex, p_requestUpdatePrimitive));
+					vc_ae1.start(f_cse_updateResource(p_resourceType, v_latestResourceIndex, p_requestUpdatePrimitive));
 		
 					tc_ac.start;
 					alt {
@@ -6362,8 +6495,8 @@ module OneM2M_PermutationFunctions {
 							setverdict(fail, __SCOPE__ & ":ERROR:  No CREATE REQUEST received");
 						}
 					}
-					v_ae1.done;
-		
+					f_cseSimu_checkComponentDoneAndGetVerdict(vc_ae1);
+					
 					// Postamble
 					f_cse_postamble_deleteResourcesCSE();
 		
@@ -6374,7 +6507,6 @@ module OneM2M_PermutationFunctions {
 					
 				function f_CSE_DMR_UPD_018(ResourceType p_resourceType, template RequestPrimitive p_requestCreatePrimitive, template RequestPrimitive p_createRequestAnnc, template RequestPrimitive p_requestUpdatePrimitive, template RequestPrimitive p_updateRequestAnnc) runs on CseSimu system CseSystem {
 					// Local variables
-					var AeSimu v_ae1 := AeSimu.create("AE1") alive;
 					var MsgIn v_request;
 					var RequestPrimitive v_requestUpdatePrimitive;
 					var integer v_parentIndex := -1;
@@ -6396,21 +6528,25 @@ module OneM2M_PermutationFunctions {
 
 					//Preamble
 
-					v_ae1.start(f_cse_createResource(int2,v_create));					
+					vc_ae1.start(f_cse_createResource(int2,v_create));					
 					f_cse_announcementProcedure_createHandler(mw_createAEAnnc(-, -, -));		
-					v_ae1.done;
+					f_cseSimu_checkComponentDoneAndGetVerdict(vc_ae1);
 					
-					v_aeIndex := f_getLatestResourceIndex(v_ae1);
+					v_aeIndex := f_getLatestResourceIndex(vc_ae1);
 
-					v_ae1.start(f_cse_createResource(p_resourceType, p_requestCreatePrimitive, v_aeIndex));
-					f_cse_announcementProcedure_createHandler(p_createRequestAnnc);	
-					v_ae1.done;					
+					if(p_resourceType != int18) {
+						v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+					}
 
-					v_latestResourceIndex := f_getLatestResourceIndex(v_ae1);
+					vc_ae1.start(f_cse_createResource(p_resourceType, p_requestCreatePrimitive, v_parentIndex));
+					f_cse_announcementProcedure_createHandler(p_createRequestAnnc);	
+					f_cseSimu_checkComponentDoneAndGetVerdict(vc_ae1);
+					
+					v_latestResourceIndex := f_getLatestResourceIndex(vc_ae1);
 					p_updateRequestAnnc.to_ := f_getLocalResourceAddress(lengthof(vc_localResourcesList)-1);
 
 					// Test Body
-					v_ae1.start(f_cse_updateResource(p_resourceType, v_latestResourceIndex, p_requestUpdatePrimitive));
+					vc_ae1.start(f_cse_updateResource(p_resourceType, v_latestResourceIndex, p_requestUpdatePrimitive));
 
 					tc_ac.start;
 					alt {
@@ -6427,8 +6563,8 @@ module OneM2M_PermutationFunctions {
 							setverdict(fail, __SCOPE__ & ":ERROR:  No announcement received");
 						}
 					}
-					v_ae1.done;
-
+					f_cseSimu_checkComponentDoneAndGetVerdict(vc_ae1);
+					
 					// Postamble
 					f_cse_postamble_deleteResourcesCSE();
 
@@ -6498,6 +6634,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_childResourceIndex := -1;
+						var integer v_parentIndex := -1;
 								   
 						// Test control
 		
@@ -6517,7 +6654,10 @@ module OneM2M_PermutationFunctions {
 							}
 						} 
 	
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 
 		
 						if(p_resourceType != int15) {
 							v_childResourceIndex := f_cse_createResource(valueof(p_childResourceType), p_childRequestPrimitive, v_resourceIndex);				
@@ -6567,6 +6707,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_childResourceIndex := -1;
+						var integer v_parentIndex := -1;
 								   
 						// Test control
 		
@@ -6585,8 +6726,11 @@ module OneM2M_PermutationFunctions {
 								f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, valueof(p_resourceType));
 							}
 						} 
-	
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 
+
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 
 		
 						if(p_resourceType != int15) {
 							v_childResourceIndex := f_cse_createResource(valueof(p_childResourceType), p_childRequestPrimitive, v_resourceIndex);				
@@ -6636,6 +6780,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_childResourceIndex := -1;
+						var integer v_parentIndex := -1;
 								   
 						// Test control
 		
@@ -6655,7 +6800,10 @@ module OneM2M_PermutationFunctions {
 							}
 						} 
 	
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 
 		
 						if(p_resourceType != int15) {
 							v_childResourceIndex := f_cse_createResource(valueof(p_childResourceType), p_childRequestPrimitive, v_resourceIndex);				
@@ -6725,8 +6873,8 @@ module OneM2M_PermutationFunctions {
 						if(p_resourceType == int4) {
 							v_containerIndex := f_cse_createResource(int3, m_createContainerBase, v_aeIndex);
 							v_parentIndex := v_containerIndex;
-						}else{
-							v_parentIndex := v_aeIndex;
+						} else if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
 						}
                 												
 						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_parentIndex); 				
@@ -6780,6 +6928,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_aeIndex := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
                 							   
 						// Test control
 						if(not(PICS_ACP_SUPPORT)) {
@@ -6806,7 +6955,10 @@ module OneM2M_PermutationFunctions {
 						}
                 		
 						//Creation of resource
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex); 				
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_parentIndex); 				
                 												
 						// Test Body
 						v_request := valueof(m_delete(f_getResourceAddress(v_resourceIndex), f_getOriginator(v_resourceIndex)));
@@ -6856,6 +7008,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_resourceIndex := -1;
 						var integer v_childResourceIndex := -1;
 						var integer v_ae2Index := -1;
+						var integer v_parentIndex := -1;
                 							   
 						// Test control
                 
@@ -6869,7 +7022,10 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_createRequestPrimitive, p_resourceType);
 						
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex); 
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_parentIndex); 
                 
 						f_cse_preamble_subscriptionVerification(v_ae2Index, p_createRequestPrimitiveChildResource, p_childResourceType);
 						
@@ -6881,8 +7037,6 @@ module OneM2M_PermutationFunctions {
 						
 						f_cse_deleteResource(v_resourceIndex);
 						
-						f_checkAeSimuStatus();
-                		
 						// Test Body
 						f_send(e_mcaPort, m_request(m_delete(f_getResourceAddress(v_childResourceIndex), f_getOriginator(v_childResourceIndex))));
                 
@@ -7103,6 +7257,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_childResourceIndex := -1;
+						var integer v_parentIndex := -1;
 								   
 						// Test control
 		
@@ -7121,8 +7276,11 @@ module OneM2M_PermutationFunctions {
 								f_cse_preamble_subscriptionVerification(v_ae2Index, p_requestPrimitive, valueof(p_resourceType));
 							}
 						} 
-	
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 
+
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}	
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 
 		
 						if(p_resourceType != int15) {
 							v_childResourceIndex := f_cse_createResource(valueof(p_childResourceType), p_childRequestPrimitive, v_resourceIndex);				
@@ -7173,6 +7331,7 @@ module OneM2M_PermutationFunctions {
 						var integer v_ae2Index := -1;
 						var integer v_resourceIndex := -1;
 						var integer v_childResourceIndex := -1;
+						var integer v_parentIndex := -1;
 								   
 						// Test control
 		
@@ -7192,7 +7351,10 @@ module OneM2M_PermutationFunctions {
 							}
 						} 
 	
-						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_aeIndex); 
+						if(p_resourceType != int18) {
+							v_parentIndex := v_aeIndex;//For resources that can have AE resource as parent
+						}
+						v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, v_parentIndex); 
 		
 						if(p_resourceType != int15) {
 							v_childResourceIndex := f_cse_createResource(valueof(p_childResourceType), p_childRequestPrimitive, v_resourceIndex);				
-- 
GitLab