From e77b140e3cca56d03fdfe2f89f2c17ddd3d967e4 Mon Sep 17 00:00:00 2001
From: pkulkarni <pkulkarni75@gmail.com>
Date: Thu, 19 Oct 2017 18:01:48 +0200
Subject: [PATCH] Code review comments incorporated and REG/RET/009 TC written.

Signed-off-by: pkulkarni <pkulkarni75@gmail.com>
---
 LibOneM2M/OneM2M_Pics.ttcn      |   3 +-
 LibOneM2M/OneM2M_Templates.ttcn |   5 +
 OneM2M_Testcases_CSE.ttcn       | 449 ++++++++++++++++----------------
 3 files changed, 226 insertions(+), 231 deletions(-)

diff --git a/LibOneM2M/OneM2M_Pics.ttcn b/LibOneM2M/OneM2M_Pics.ttcn
index 3755ac9..8061df0 100644
--- a/LibOneM2M/OneM2M_Pics.ttcn
+++ b/LibOneM2M/OneM2M_Pics.ttcn
@@ -18,7 +18,8 @@ module OneM2M_Pics {
 	 * @see  oneM2M TS-0017 A.5.5.1/1
 	 */
 	modulepar boolean PICS_ACP_SUPPORT := true;
-	modulepar boolean PICS_IN_CSE := true;	
+	modulepar boolean PICS_IN_CSE := true;
+	modulepar boolean PICS_MN_CSE := true;	
 	modulepar boolean PICS_UNSTRUCTURED_CSE_RELATIVE_RESOURCE_ID_FORMAT := true;
 	modulepar boolean PICS_STRUCTURED_CSE_RELATIVE_RESOURCE_ID_FORMAT := true;
 	
diff --git a/LibOneM2M/OneM2M_Templates.ttcn b/LibOneM2M/OneM2M_Templates.ttcn
index c2bc68a..259e06e 100644
--- a/LibOneM2M/OneM2M_Templates.ttcn
+++ b/LibOneM2M/OneM2M_Templates.ttcn
@@ -3715,6 +3715,11 @@ module OneM2M_Templates {
 			primitiveContent := {subscription := m_contentSubscription}
 		}
 		
+		template (value) UtTriggerPrimitive m_utCreateRemoteCSE modifies m_utCreate := {
+			requestIdentifier := testcasename() & "-m_utCreateRemoteCSE" & f_rnd(1, 1000000),
+			resourceType := int16
+		}
+ 		
 		template (value) UtTriggerPrimitive m_utRetrieveResource(XSD.ID p_targetResourceAddress, in XSD.ID p_originator) := {
 			operation := int2,
 			to_ := p_targetResourceAddress,
diff --git a/OneM2M_Testcases_CSE.ttcn b/OneM2M_Testcases_CSE.ttcn
index 5f1591d..e2b80c5 100644
--- a/OneM2M_Testcases_CSE.ttcn
+++ b/OneM2M_Testcases_CSE.ttcn
@@ -1827,6 +1827,10 @@ module OneM2M_Testcases_CSE {
 	
 				}//end TC_CSE_REG_RET_001
 				
+				/**
+				 * @desc Check that the IUT accepts a retrieval request of <CSEBase> resource with the optional ATTRIBUTE
+				 * 
+				 */
 				group g_CSE_REG_RET_002 {
 					
 					testcase TC_CSE_REG_RET_002_CST() runs on Tester system CseSystem {
@@ -1835,6 +1839,7 @@ module OneM2M_Testcases_CSE {
 						var template PrimitiveContent v_contentResponse;
 					
 						v_contentResponse.cSEBase := mw_contentCSEBase_rc1;
+						v_contentResponse.cSEBase.cseType := ?;
 						    
 						v_ae1.start(f_CSE_REG_RET_002(v_contentResponse));
 						v_ae1.done;
@@ -1846,6 +1851,7 @@ module OneM2M_Testcases_CSE {
 						 var template PrimitiveContent v_contentResponse;
 	
 						 v_contentResponse.cSEBase := mw_contentCSEBase_rc1;
+						 v_contentResponse.cSEBase.nodeLink := ?;
 	    
 						 v_ae1.start(f_CSE_REG_RET_002(v_contentResponse));
 						 v_ae1.done;
@@ -1866,17 +1872,12 @@ module OneM2M_Testcases_CSE {
 						 // Preamble
 						 v_aeIndex := f_cse_preamble_registerAe();//c_CRUDNDi);
 						 
-						 mcaPort.send(m_request(m_retrieveResource(f_getResourceAddress(), f_getOriginator(v_aeIndex))));//TODO Maybe PX_SUPER_AE_ID
+						 mcaPort.send(m_request(m_retrieveResource(f_getResourceAddress(), f_getOriginator(v_aeIndex))));
 						 tc_ac.start;
 						 alt {
 							[] mcaPort.receive(mw_response(mw_responsePrimitive(int2000, p_contentResponse))) -> value v_response {
 								tc_ac.stop;
-								if ((ispresent(v_response.primitive.responsePrimitive.primitiveContent.cSEBase.cseType)) or 
-								     (ispresent(v_response.primitive.responsePrimitive.primitiveContent.cSEBase.nodeLink))){
-								  setverdict(pass, __SCOPE__ & ": Response OK for retrieving for attribute");
-								} else {
-								  setverdict(fail, __SCOPE__ & ": Error: Unable to retrieve attribute"); 	
-								}
+								setverdict(pass, __SCOPE__ & ": Response OK for retrieving for attribute");
 							}
 							[] mcaPort.receive(mw_response(mw_responsePrimitiveOK(p_contentResponse))) -> value v_response {
 								tc_ac.stop;
@@ -1904,6 +1905,11 @@ module OneM2M_Testcases_CSE {
 					
 				} //end g_CSE_REG_RET_002
 				
+				/**
+				 * @desc Check that the IUT accepts a retrieval request of <AE> resource with attributes multiplicity equals to 1
+				 * 
+				 */
+				 
 				testcase TC_CSE_REG_RET_003() runs on AeSimu system CseSystem {
 					// Local variables
 					var MsgIn v_response;
@@ -1956,6 +1962,11 @@ module OneM2M_Testcases_CSE {
 	
 				}//end TC_CSE_REG_RET_003
 				
+				/**
+				 * @desc Check that the IUT accepts a retrieval request of <AE> resource with optional ATTRIBUTE
+				 * 
+				 */
+				 
 				group g_CSE_REG_RET_004 {
 					
 					testcase TC_CSE_REG_RET_004_LBL() runs on Tester system CseSystem {
@@ -1964,6 +1975,7 @@ module OneM2M_Testcases_CSE {
 						var template PrimitiveContent v_contentResponse;
 	
 						v_contentResponse.aE := mw_contentAeBase;
+						v_contentResponse.aE.labels := ?;
 		    
 						v_ae1.start(f_CSE_REG_RET_004(v_contentResponse));
 						v_ae1.done;
@@ -1975,6 +1987,7 @@ module OneM2M_Testcases_CSE {
 						 var template PrimitiveContent v_contentResponse;
 
 						 v_contentResponse.aE := mw_contentAeBase;
+						 v_contentResponse.aE.appName := ?;
 
 						 v_ae1.start(f_CSE_REG_RET_004(v_contentResponse));
 						 v_ae1.done;
@@ -1986,6 +1999,7 @@ module OneM2M_Testcases_CSE {
 						 var template PrimitiveContent v_contentResponse;
 
 						 v_contentResponse.aE := mw_contentAeBase;
+						 v_contentResponse.aE.pointOfAccess := ?;
 
 						 v_ae1.start(f_CSE_REG_RET_004(v_contentResponse));
 						 v_ae1.done;
@@ -1997,6 +2011,7 @@ module OneM2M_Testcases_CSE {
 						 var template PrimitiveContent v_contentResponse;
 
 						 v_contentResponse.aE := mw_contentAeBase;
+						 v_contentResponse.aE.nodeLink := ?;
 
 						 v_ae1.start(f_CSE_REG_RET_004(v_contentResponse));
 						 v_ae1.done;
@@ -2008,6 +2023,7 @@ module OneM2M_Testcases_CSE {
 						 var template PrimitiveContent v_contentResponse;
 
 						 v_contentResponse.aE := mw_contentAeBase;
+						 v_contentResponse.aE.contentSerialization := ?; 
 
 						 v_ae1.start(f_CSE_REG_RET_004(v_contentResponse));
 						 v_ae1.done;
@@ -2033,19 +2049,7 @@ module OneM2M_Testcases_CSE {
 						 alt {
 							[] mcaPort.receive(mw_response(mw_responsePrimitive(int2000, p_contentResponse))) -> value v_response {
 								tc_ac.stop;
-								if (ispresent(v_response.primitive.responsePrimitive.primitiveContent)){
-									if ((ispresent(v_response.primitive.responsePrimitive.primitiveContent.aE.appName)) or 
-										 (ispresent(v_response.primitive.responsePrimitive.primitiveContent.aE.nodeLink)) or
-									     (ispresent(v_response.primitive.responsePrimitive.primitiveContent.aE.labels)) or 
-									     (ispresent(v_response.primitive.responsePrimitive.primitiveContent.aE.pointOfAccess)) or
-									     (ispresent(v_response.primitive.responsePrimitive.primitiveContent.aE.contentSerialization)) ){
-									  setverdict(pass, __SCOPE__ & ": Response OK for retrieving for attribute");
-									} else {
-									  setverdict(fail, __SCOPE__ & ": Error: Unable to retrieve attribute"); 	
-									}
-							  } else {
-								setverdict(fail, __SCOPE__ & ": Error: Primitive content not available");
-							  }
+							    setverdict(pass, __SCOPE__ & ": Response OK for retrieving for attribute");
 							}
 							[] mcaPort.receive(mw_response(mw_responsePrimitiveOK(p_contentResponse))) -> value v_response {
 								tc_ac.stop;
@@ -2074,7 +2078,7 @@ module OneM2M_Testcases_CSE {
 				} //end g_CSE_REG_RET_004
 				
 				/**
-				 * @desc Check that if the IUT is IN-CSE, it accepts an retrieval request of <CSEBase> resource and returns the cseType attribute. cseType Attribute is mandatory for IN-CSE
+				 * @desc Check that the IUT accepts a retrieval request of <CSEBase> resource including the cseType attribute
 				 * 
 				 */
 				testcase TC_CSE_REG_RET_005() runs on AeSimu system CseSystem {
@@ -2100,6 +2104,7 @@ module OneM2M_Testcases_CSE {
 	
 					// Test Body
 					v_contentResponse.cSEBase := mw_contentCSEBase_rc1;
+					v_contentResponse.cSEBase.cseType := int1;
 	
 					mcaPort.send(m_request(m_retrieveResource(f_getResourceAddress(), f_getOriginator(v_aeIndex))));//TODO Maybe PX_SUPER_AE_ID 
 					
@@ -2107,19 +2112,7 @@ module OneM2M_Testcases_CSE {
 					alt {
 						[] mcaPort.receive(mw_response(mw_responsePrimitive(int2000, v_contentResponse))) -> value v_response {
 							tc_ac.stop;
-							if (ispresent(v_response.primitive.responsePrimitive.primitiveContent)) {
-								if (ispresent(v_response.primitive.responsePrimitive.primitiveContent.cSEBase.cseType)){
-									if (v_response.primitive.responsePrimitive.primitiveContent.cSEBase.cseType==int1){
-										setverdict(pass, __SCOPE__ & ": cseType attribute is set to 1 (IN_CSE)");
-									}else{
-										setverdict(fail, __SCOPE__ & ": Error, cseType attribute is set to " & int2str(enum2int(v_response.primitive.responsePrimitive.primitiveContent.cSEBase.cseType)));
-									}
-								}else{
-									setverdict(fail, __SCOPE__ & ": Error, cseType attribute is not present");
-								}
-						  } else {
-							setverdict(fail, __SCOPE__ & ": Error, Primitive content not available");  
-						  }
+							setverdict(pass, __SCOPE__ & ": cseType attribute is set to 1 (IN_CSE)");
 						}
 						[] mcaPort.receive(mw_response(mw_responsePrimitiveOK(v_contentResponse))) -> value v_response {
 							tc_ac.stop;
@@ -2146,6 +2139,10 @@ module OneM2M_Testcases_CSE {
 
 				}//end TC_CSE_REG_RET_BV_005
 				
+				/**
+				 * @desc Check that the IUT accepts a retrieval request of <remoteCSE> resource
+				 * 
+				 */
 				testcase TC_CSE_REG_RET_006() runs on CseSimu system CseSystem {
 				//Local variables
 				 //Local variables
@@ -2162,33 +2159,64 @@ module OneM2M_Testcases_CSE {
 				 // Test adapter configuration
 
 				 // Preamble
-				 vc_remoteCseIndex := f_cse_registerRemoteCse(m_createRemoteCSEBase);
-				 
-				 v_contentResponse.remoteCSE := mw_contentRemoteCSEBase;
-				 
-				 mccPort.send(m_request(m_retrieveResource(f_getResourceAddress(), f_getOriginator(vc_remoteCseIndex))));
-				 tc_ac.start;
-				 alt {
-					 [] mccPort.receive(mw_response(mw_responsePrimitive(int2000, v_contentResponse))) -> value v_response {
-						 tc_ac.stop;
-						 setverdict(pass, __SCOPE__ & ": Response OK for retrieving");
-					 }
-					 [] mccPort.receive(mw_response(mw_responsePrimitiveOK(v_contentResponse))) -> value v_response {
-						 tc_ac.stop;
-						 setverdict(fail, __SCOPE__ & ": Wrong response status code");
-					 }
-					 [] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
-						 tc_ac.stop;
-						 setverdict(fail, __SCOPE__ & ": Error, resource elements provided not matching expected resource elements");
-					 }
-					 [] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
-						 tc_ac.stop;
-						 setverdict(fail, __SCOPE__ & ": Error while retrieving resource");
+				 if(PICS_IN_CSE){
+				     vc_remoteCseIndex := f_cse_registerRemoteCse(m_createRemoteCSEBase);
+				    
+					 v_contentResponse.remoteCSE := mw_contentRemoteCSEBase;
+ 
+					 mccPort.send(m_request(m_retrieveResource(f_getResourceAddress(), f_getOriginator(vc_remoteCseIndex))));
+					 tc_ac.start;
+					 alt {
+						 [] mccPort.receive(mw_response(mw_responsePrimitive(int2000, v_contentResponse))) -> value v_response {
+							 tc_ac.stop;
+							 setverdict(pass, __SCOPE__ & ": Response OK for retrieving");
+						 }
+						 [] mccPort.receive(mw_response(mw_responsePrimitiveOK(v_contentResponse))) -> value v_response {
+							 tc_ac.stop;
+							 setverdict(fail, __SCOPE__ & ": Wrong response status code");
+						 }
+						 [] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
+							 tc_ac.stop;
+							 setverdict(fail, __SCOPE__ & ": Error, resource elements provided not matching expected resource elements");
+						 }
+						 [] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
+							 tc_ac.stop;
+							 setverdict(fail, __SCOPE__ & ": Error while retrieving resource");
+						 }
+						 [] tc_ac.timeout {
+							 setverdict(fail, __SCOPE__ & ": No answer while retrieving resource");
+						 }
 					 }
-					 [] tc_ac.timeout {
-						 setverdict(fail, __SCOPE__ & ": No answer while retrieving resource");
+				    
+				 } else if (PICS_MN_CSE) {
+					vc_remoteCseIndex := f_cse_registrationRemoteCse(m_createRemoteCSEBase);
+					
+					v_contentResponse.remoteCSE := mw_contentRemoteCSEBase;
+					
+					mccPort.send(m_request(m_retrieveResource(f_getResourceAddress(), f_getOriginator(vc_remoteCseIndex))));
+					tc_ac.start;
+					alt {
+						 [] mccPort.receive(mw_response(mw_responsePrimitive(int2000, v_contentResponse))) -> value v_response {
+							 tc_ac.stop;
+							 setverdict(pass, __SCOPE__ & ": Response OK for retrieving");
+						 }
+						 [] mccPort.receive(mw_response(mw_responsePrimitiveOK(v_contentResponse))) -> value v_response {
+							 tc_ac.stop;
+							 setverdict(fail, __SCOPE__ & ": Wrong response status code");
+						 }
+						 [] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
+							 tc_ac.stop;
+							 setverdict(fail, __SCOPE__ & ": Error, resource elements provided not matching expected resource elements");
+						 }
+						 [] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
+							 tc_ac.stop;
+							 setverdict(fail, __SCOPE__ & ": Error while retrieving resource");
+						 }
+						 [] tc_ac.timeout {
+							 setverdict(fail, __SCOPE__ & ": No answer while retrieving resource");
+						 }
 					 }
-				 }	
+				 }
 
 				 // Postamble
 				 f_cse_postamble_deleteResourcesCSE();
@@ -2198,6 +2226,10 @@ module OneM2M_Testcases_CSE {
 				 
 				}//end TC_CSE_REG_RET_006
 				
+				/**
+				 * @desc Check that the IUT accepts an retrieval request of <remoteCSE> resource with optional ATTRIBUTE
+				 * 
+				 */
 				group g_CSE_REG_RET_007 {
 					
 					testcase TC_CSE_REG_RET_007_LBL() runs on Tester system CseSystem {
@@ -2206,6 +2238,7 @@ module OneM2M_Testcases_CSE {
 						var template PrimitiveContent v_contentResponse;
 
 						v_contentResponse.remoteCSE := mw_contentRemoteCSEBase;
+						v_contentResponse.remoteCSE.labels := ?;
 
 						v_cse1.start(f_CSE_REG_RET_007(v_contentResponse));
 						v_cse1.done;
@@ -2217,6 +2250,7 @@ module OneM2M_Testcases_CSE {
 						var template PrimitiveContent v_contentResponse;
 
 						v_contentResponse.remoteCSE := mw_contentRemoteCSEBase;
+						v_contentResponse.remoteCSE.cseType := ?;
 
 						v_cse1.start(f_CSE_REG_RET_007(v_contentResponse));
 						v_cse1.done;
@@ -2228,6 +2262,7 @@ module OneM2M_Testcases_CSE {
 						var template PrimitiveContent v_contentResponse;
 
 						v_contentResponse.remoteCSE := mw_contentRemoteCSEBase;
+						v_contentResponse.remoteCSE.pointOfAccess := ?;
 
 						v_cse1.start(f_CSE_REG_RET_007(v_contentResponse));
 						v_cse1.done;
@@ -2239,6 +2274,7 @@ module OneM2M_Testcases_CSE {
 						var template PrimitiveContent v_contentResponse;
 
 						v_contentResponse.remoteCSE := mw_contentRemoteCSEBase;
+						v_contentResponse.remoteCSE.nodeLink := ?;
 
 						v_cse1.start(f_CSE_REG_RET_007(v_contentResponse));
 						v_cse1.done;
@@ -2258,39 +2294,55 @@ module OneM2M_Testcases_CSE {
 						// Test adapter configuration
 
 						// Preamble
-						vc_remoteCseIndex := f_cse_registerRemoteCse(m_createRemoteCSEBase);
-						mccPort.send(m_request(m_retrieveResource(f_getResourceAddress(), f_getOriginator(vc_remoteCseIndex))));
-					    tc_ac.start;
-						alt {
-							[] mccPort.receive(mw_response(mw_responsePrimitive(int2000, p_contentResponse))) -> value v_response {
-								tc_ac.stop;
-								if (ispresent(v_response.primitive.responsePrimitive.primitiveContent)){
-									if ((ispresent(v_response.primitive.responsePrimitive.primitiveContent.remoteCSE.labels)) or 
-										 (ispresent(v_response.primitive.responsePrimitive.primitiveContent.remoteCSE.nodeLink)) or
-										 (ispresent(v_response.primitive.responsePrimitive.primitiveContent.remoteCSE.cseType)) or 
-										 (ispresent(v_response.primitive.responsePrimitive.primitiveContent.remoteCSE.pointOfAccess))){
-									  setverdict(pass, __SCOPE__ & ": Response OK for retrieving for attribute");
-									} else {
-									  setverdict(fail, __SCOPE__ & ": Error: Unable to retrieve attribute"); 	
-									}
-							  } else {
-								setverdict(fail, __SCOPE__ & ": Error: Primitive content not available");
-							  }
-							}
-							[] mccPort.receive(mw_response(mw_responsePrimitiveOK(p_contentResponse))) -> value v_response {
-								tc_ac.stop;
-								setverdict(fail, __SCOPE__ & ": Wrong response status code");
-							}
-							[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
-								tc_ac.stop;
-								setverdict(fail, __SCOPE__ & ": Error, resource elements provided not matching expected resource elements");
-							}
-							[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
-								tc_ac.stop;
-								setverdict(fail, __SCOPE__ & ": Error while retrieving resource");
+						if(PICS_IN_CSE){
+							vc_remoteCseIndex := f_cse_registerRemoteCse(m_createRemoteCSEBase);
+							mccPort.send(m_request(m_retrieveResource(f_getResourceAddress(), f_getOriginator(vc_remoteCseIndex))));
+						    tc_ac.start;
+							alt {
+								[] mccPort.receive(mw_response(mw_responsePrimitive(int2000, p_contentResponse))) -> value v_response {
+									tc_ac.stop;
+									setverdict(pass, __SCOPE__ & ": Response OK for retrieving for attribute");
+								}
+								[] mccPort.receive(mw_response(mw_responsePrimitiveOK(p_contentResponse))) -> value v_response {
+									tc_ac.stop;
+									setverdict(fail, __SCOPE__ & ": Wrong response status code");
+								}
+								[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
+									tc_ac.stop;
+									setverdict(fail, __SCOPE__ & ": Error, resource elements provided not matching expected resource elements");
+								}
+								[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
+									tc_ac.stop;
+									setverdict(fail, __SCOPE__ & ": Error while retrieving resource");
+								}
+								[] tc_ac.timeout {
+									setverdict(fail, __SCOPE__ & ": No answer while retrieving resource");
+								}
 							}
-							[] tc_ac.timeout {
-								setverdict(fail, __SCOPE__ & ": No answer while retrieving resource");
+						} else if (PICS_MN_CSE){
+							vc_remoteCseIndex := f_cse_registrationRemoteCse(m_createRemoteCSEBase);
+							mccPort.send(m_request(m_retrieveResource(f_getResourceAddress(), f_getOriginator(vc_remoteCseIndex))));
+							tc_ac.start;
+							alt {
+								[] mccPort.receive(mw_response(mw_responsePrimitive(int2000, p_contentResponse))) -> value v_response {
+									tc_ac.stop;
+									setverdict(pass, __SCOPE__ & ": Response OK for retrieving for attribute");
+								}
+								[] mccPort.receive(mw_response(mw_responsePrimitiveOK(p_contentResponse))) -> value v_response {
+									tc_ac.stop;
+									setverdict(fail, __SCOPE__ & ": Wrong response status code");
+								}
+								[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
+									tc_ac.stop;
+									setverdict(fail, __SCOPE__ & ": Error, resource elements provided not matching expected resource elements");
+								}
+								[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
+									tc_ac.stop;
+									setverdict(fail, __SCOPE__ & ": Error while retrieving resource");
+								}
+								[] tc_ac.timeout {
+									setverdict(fail, __SCOPE__ & ": No answer while retrieving resource");
+								}
 							}
 						}
 						
@@ -2371,6 +2423,44 @@ module OneM2M_Testcases_CSE {
 					f_cf01Down();
 
 				}//end TC_CSE_REG_RET_008
+				
+				testcase TC_CSE_REG_RET_009() runs on CseSimu system CseSystem {
+					//Local variables
+					 //Local variables
+					 var MsgIn v_response;
+					 var RequestPrimitive v_request;
+					 var ResourceType v_resourceType := int16;	//remoteCSE
+					 var template PrimitiveContent v_contentResponse;
+					 var template UtTriggerPrimitive v_utRequest := m_utCreateRemoteCSE;
+	 		
+					 // Test control
+					if(not(PICS_MN_CSE)) {
+						setverdict(inconc, __SCOPE__ & ": IUT shall be MN-CSE to run this test case");
+						stop;
+					 }
+	
+					 // Test component configuration
+					 f_cf04Up();
+	
+					 // Test adapter configuration
+	
+					 // Preamble
+					 vc_remoteCseIndex := f_cse_registrationRemoteCse(m_createRemoteCSEBase);
+					 
+					 //Send Trigger Message
+ 				     v_utRequest.to_ := f_getResourceAddress();
+					 v_utRequest.from_ := "UNINITIALIZED";
+					 f_sendUtPrimitive(v_utRequest);
+					 
+					 tc_ac.start;
+					 mccPort.send(m_request(m_retrieveResource(f_getResourceAddress(), f_getOriginator(vc_remoteCseIndex))));
+					 // Postamble
+					 f_cse_postamble_deleteResourcesCSE();
+	
+					 // Tear down
+					 f_cf04Down();
+ 
+				}//end TC_CSE_REG_RET_009
 			
 			}	//end group Retrieve
 			
@@ -2426,17 +2516,21 @@ module OneM2M_Testcases_CSE {
 
 				}; //end TC_CSE_REG_UPD_BI_001
 				
+				/**
+				 * @desc Check that the IUT accepts an update request of <remoteCSE> resource with OPTIONAL_ATTRIBUTE.
+				 * 
+				 */
+				 
 				group g_CSE_REG_UPD_002 {
 					
 					testcase TC_CSE_REG_UPD_002_ET() runs on Tester system CseSystem {
 						// Local variables
 						var template RequestPrimitive v_updateRequest := m_updateRemoteCSEBase;	
-						const AttributeAux c_Attribute := {"expirationTime", omit};
 						var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
     						
 						v_updateRequest.primitiveContent.remoteCSE.expirationTime := "20301231T012345";
 	
-						v_cse1.start(f_CSE_REG_UPD_002(v_updateRequest, c_Attribute));
+						v_cse1.start(f_CSE_REG_UPD_002(v_updateRequest));
 						v_cse1.done;
 						
 					}
@@ -2444,12 +2538,11 @@ module OneM2M_Testcases_CSE {
 					testcase TC_CSE_REG_UPD_002_LBL() runs on Tester system CseSystem {
 						// Local variables
 						var template RequestPrimitive v_updateRequest := m_updateRemoteCSEBase;	
-						const AttributeAux c_Attribute := {"labels", omit};
 						var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
     						
 						v_updateRequest.primitiveContent.remoteCSE.labels := {"MyLabel"};
 	
-						v_cse1.start(f_CSE_REG_UPD_002(v_updateRequest, c_Attribute));
+						v_cse1.start(f_CSE_REG_UPD_002(v_updateRequest));
 						v_cse1.done;
 	
 					}
@@ -2457,12 +2550,11 @@ module OneM2M_Testcases_CSE {
 					testcase TC_CSE_REG_UPD_002_POA() runs on Tester system CseSystem {
 						// Local variables
 						var template RequestPrimitive v_updateRequest := m_updateRemoteCSEBase;	
-						const AttributeAux c_Attribute := {"pointofAccess", omit};
 						var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
     					
 						v_updateRequest.primitiveContent.remoteCSE.pointOfAccess := {"http://" & PX_CSE1_ADDRESS & "/"};
 	
-						v_cse1.start(f_CSE_REG_UPD_002(v_updateRequest, c_Attribute));
+						v_cse1.start(f_CSE_REG_UPD_002(v_updateRequest));
 						v_cse1.done;
 	
 					}
@@ -2470,17 +2562,28 @@ module OneM2M_Testcases_CSE {
 					testcase TC_CSE_REG_UPD_002_NL() runs on Tester system CseSystem {
 						// Local variables
 						var template RequestPrimitive v_updateRequest := m_updateRemoteCSEBase;	
-						const AttributeAux c_Attribute := {"nodeLink", omit};
 						var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
     						
 						v_updateRequest.primitiveContent.remoteCSE.nodeLink := c_defaultNodeID;
 	
-						v_cse1.start(f_CSE_REG_UPD_002(v_updateRequest, c_Attribute));
+						v_cse1.start(f_CSE_REG_UPD_002(v_updateRequest));
 						v_cse1.done;
 
 					}
 					
-					function f_CSE_REG_UPD_002(template RequestPrimitive p_requestPrimitive, in AttributeAux p_Attribute) runs on CseSimu {
+					testcase TC_CSE_REG_UPD_004_RR() runs on Tester system CseSystem {
+						// Local variables
+						var template RequestPrimitive v_updateRequest := m_updateRemoteCSEBase;	
+						var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
+
+						v_updateRequest.primitiveContent.remoteCSE.requestReachability := true;
+
+						v_cse1.start(f_CSE_REG_UPD_002(v_updateRequest));
+						v_cse1.done;
+
+					}
+					
+					function f_CSE_REG_UPD_002(template RequestPrimitive p_requestPrimitive) runs on CseSimu {
 						// Local variables
 						//Local variables
 					    var MsgIn v_response;
@@ -2504,22 +2607,19 @@ module OneM2M_Testcases_CSE {
 						alt {
 							[] mccPort.receive(mw_response(mw_responsePrimitive(int2004, f_getTemplateFromPrimitiveContent(v_request.primitiveContent)))) -> value v_response {
 								tc_ac.stop;
-								setverdict(pass, __SCOPE__ & ": Accepted updation for resource type remoteCSE containing attribute " & p_Attribute.name);
-								f_setResource(v_request.primitiveContent,int16);
+								setverdict(pass, __SCOPE__ & ": Accepted updation for resource type remoteCSE containing attribute ");
 							}
 							[] mccPort.receive(mw_response(mw_responsePrimitiveOK(f_getTemplateFromPrimitiveContent(v_request.primitiveContent)))) -> value v_response {
 								tc_ac.stop;
 								setverdict(fail, __SCOPE__ & ": Wrong response status code in the response");
-								f_setResource(v_request.primitiveContent,int16);
 							}
 							[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
 								tc_ac.stop;
-								setverdict(fail, __SCOPE__ & ": Accepted updation for resource type remoteCSE without containing attribute " & p_Attribute.name);
-								f_setResource(v_request.primitiveContent,int16);
+								setverdict(fail, __SCOPE__ & ": Accepted updation for resource type remoteCSE without containing attribute ");
 							}
 							[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
 								tc_ac.stop;
-								setverdict(fail, __SCOPE__ & ": Rejected updation of resource type remoteCSE containing attribute" & p_Attribute.name);
+								setverdict(fail, __SCOPE__ & ": Rejected updation of resource type remoteCSE containing attribute");
 							}
 							[] tc_ac.timeout {
 								setverdict(fail, __SCOPE__ & ": No answer while updating resource type remoteCSE");
@@ -2607,8 +2707,14 @@ module OneM2M_Testcases_CSE {
 						//Local variables
 						var MsgIn v_response;
 						var RequestPrimitive v_request;
-						var ResourceType v_resourceType := int16;	//remoteCSE		
+						var ResourceType v_resourceType := int16;	//remoteCSE
+						var template UtTriggerPrimitive v_utRequest := m_utCreateRemoteCSE;
+								
 						// Test control
+						if(not(PICS_MN_CSE)) {
+							setverdict(inconc, __SCOPE__ & ": IUT shall be MN-CSE to run this test case");
+							stop;
+						}
 
 						// Test component configuration
 						f_cf04Up();
@@ -2616,7 +2722,12 @@ module OneM2M_Testcases_CSE {
 						// Test adapter configuration
 
 						// Preamble
-						vc_remoteCseIndex := f_cse_registerRemoteCse(m_createRemoteCSEBase);
+						vc_remoteCseIndex := f_cse_registrationRemoteCse(m_createRemoteCSEBase);
+						
+						//Send Trigger Message
+					    v_utRequest.to_ := f_getResourceAddress();
+					    v_utRequest.from_ := "UNINITIALIZED";
+					    f_sendUtPrimitive(v_utRequest);
 
 						// Test Body
 						v_request := f_getUpdateRequestPrimitive(int16, vc_remoteCseIndex, p_requestPrimitive);
@@ -2657,128 +2768,6 @@ module OneM2M_Testcases_CSE {
 					}//end f_CSE_REG_UPD_003
 				} //end g_CSE_REG_UPD_003
 			    
-				group g_CSE_REG_UPD_004 {
-	
-					testcase TC_CSE_REG_UPD_004_ET() runs on Tester system CseSystem {
-						// Local variables
-						var template RequestPrimitive v_updateRequest := m_updateRemoteCSEBase;	
-						const AttributeAux c_optionalAttribute := {"expirationTime", omit};
-						var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
-			
-						v_updateRequest.primitiveContent.remoteCSE.expirationTime := "20301231T012345";
-
-						v_cse1.start(f_CSE_REG_UPD_004(v_updateRequest, c_optionalAttribute));
-						v_cse1.done;
-		
-					}
-	
-					testcase TC_CSE_REG_UPD_004_LBL() runs on Tester system CseSystem {
-						// Local variables
-						var template RequestPrimitive v_updateRequest := m_updateRemoteCSEBase;	
-						const AttributeAux c_optionalAttribute := {"labels", omit};
-						var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
-			
-						v_updateRequest.primitiveContent.remoteCSE.labels := {"MyLabel"};
-
-						v_cse1.start(f_CSE_REG_UPD_004(v_updateRequest, c_optionalAttribute));
-						v_cse1.done;
-
-					}
-	
-					testcase TC_CSE_REG_UPD_004_POA() runs on Tester system CseSystem {
-						// Local variables
-						var template RequestPrimitive v_updateRequest := m_updateRemoteCSEBase;	
-						const AttributeAux c_optionalAttribute := {"pointofAccess", omit};
-						var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
-		
-						v_updateRequest.primitiveContent.remoteCSE.pointOfAccess := {"http://" & PX_CSE1_ADDRESS & "/"};
-
-						v_cse1.start(f_CSE_REG_UPD_004(v_updateRequest, c_optionalAttribute));
-						v_cse1.done;
-
-					}
-	
-					testcase TC_CSE_REG_UPD_004_NL() runs on Tester system CseSystem {
-						// Local variables
-						var template RequestPrimitive v_updateRequest := m_updateRemoteCSEBase;	
-						const AttributeAux c_optionalAttribute := {"nodeLink", omit};
-						var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
-			
-						v_updateRequest.primitiveContent.remoteCSE.nodeLink := c_defaultNodeID;
-
-						v_cse1.start(f_CSE_REG_UPD_004(v_updateRequest, c_optionalAttribute));
-						v_cse1.done;
-
-					}
-					
-					testcase TC_CSE_REG_UPD_004_RR() runs on Tester system CseSystem {
-						// Local variables
-						var template RequestPrimitive v_updateRequest := m_updateRemoteCSEBase;	
-						const AttributeAux c_optionalAttribute := {"requestReachability", omit};
-						var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
-
-						v_updateRequest.primitiveContent.remoteCSE.requestReachability := true;
-
-						v_cse1.start(f_CSE_REG_UPD_004(v_updateRequest, c_optionalAttribute));
-						v_cse1.done;
-
-					}
-	
-					function f_CSE_REG_UPD_004(template RequestPrimitive p_requestPrimitive, in AttributeAux p_Attribute) runs on CseSimu {
-						// Local variables
-						//Local variables
-						var MsgIn v_response;
-						var RequestPrimitive v_request;
-						var ResourceType v_resourceType := int16;	//remoteCSE		
-						// Test control
-
-						// Test component configuration
-						f_cf04Up();
-
-						// Test adapter configuration
-
-						// Preamble
-						vc_remoteCseIndex := f_cse_registerRemoteCse(m_createRemoteCSEBase);
-
-						// Test Body
-						v_request := f_getUpdateRequestPrimitive(int16, vc_remoteCseIndex, p_requestPrimitive);
-
-						mccPort.send(m_request(v_request));
-						tc_ac.start;
-						alt {
-							[] mccPort.receive(mw_response(mw_responsePrimitive(int2004, f_getTemplateFromPrimitiveContent(v_request.primitiveContent)))) -> value v_response {
-								tc_ac.stop;
-								setverdict(pass, __SCOPE__ & ": Accepted updation for resource type remoteCSE containing attribute " & p_Attribute.name);
-								f_setResource(v_request.primitiveContent,int16);
-							}
-							[] mccPort.receive(mw_response(mw_responsePrimitiveOK(f_getTemplateFromPrimitiveContent(v_request.primitiveContent)))) -> value v_response {
-								tc_ac.stop;
-								setverdict(fail, __SCOPE__ & ": Wrong response status code in the response");
-								f_setResource(v_request.primitiveContent,int16);
-							}
-							[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
-								tc_ac.stop;
-								setverdict(fail, __SCOPE__ & ": Accepted updation for resource type remoteCSE without containing attribute " & p_Attribute.name);
-								f_setResource(v_request.primitiveContent,int16);
-							}
-							[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
-								tc_ac.stop;
-								setverdict(fail, __SCOPE__ & ": Rejected updation of resource type remoteCSE containing attribute" & p_Attribute.name);
-							}
-							[] tc_ac.timeout {
-								setverdict(fail, __SCOPE__ & ": No answer while updating resource type remoteCSE");
-							}
-						}					    
-
-						// Postamble
-						f_cse_postamble_deleteResourcesCSE();
-
-						// Tear down
-						f_cf04Down();
-
-					}//end f_CSE_REG_UPD_004
-				} //end g_CSE_REG_UPD_004
-			    
 			}// end group Update
 			
 			group Delete{
-- 
GitLab