From 3cc4cc2ff1efa6d0691a12ae7a1e9148fa5e0f57 Mon Sep 17 00:00:00 2001
From: reinaortega <miguelangel.reinaortega@etsi.org>
Date: Fri, 18 May 2018 15:28:00 +0200
Subject: [PATCH] TC draft TC_CSE_PCH_001

Signed-off-by: reinaortega <miguelangel.reinaortega@etsi.org>
---
 LibOneM2M/OneM2M_Functions.ttcn     | 36 +++++++++++++
 LibOneM2M/OneM2M_Templates.ttcn     | 62 ++++++++++++++---------
 OneM2M_Testcases_CSE_Release_2.ttcn | 78 +++++++++++++++++++++++++++++
 3 files changed, 152 insertions(+), 24 deletions(-)

diff --git a/LibOneM2M/OneM2M_Functions.ttcn b/LibOneM2M/OneM2M_Functions.ttcn
index e4c593a..900f98c 100644
--- a/LibOneM2M/OneM2M_Functions.ttcn
+++ b/LibOneM2M/OneM2M_Functions.ttcn
@@ -1586,6 +1586,42 @@ module OneM2M_Functions {
 		
 				} //end f_cse_notifyProcedure_noNotification Handler
 				
+				/**
+				 * @desc Message exchange for notification
+				 * @param p_requestPrimitive Notify request to be used for the notification
+				 * @verdict 
+				 */
+				 function f_cse_notifyProcedure_notify(template RequestPrimitive p_requestPrimitive) runs on CseSimu {
+					// Local variables
+					var RequestPrimitive v_request;
+					var ResponsePrimitive v_responsePrimitive;
+					var integer v_resourceIndex := -1;
+				
+					v_request.from_ := PX_CSE1_ID;
+					
+					mccPort.send(m_request(v_request));
+					tc_ac.start;
+					alt {
+						[] mccPort.receive(mw_response(mw_responsePrimitive(int2000, mw_primitiveContentNotification(mw_contentNotification_any)))) -> value vc_response {
+							tc_ac.stop;
+						}
+						[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
+							tc_ac.stop;
+							setverdict(inconc, __SCOPE__&":INFO: Error while performing notification");
+						}
+						[] mccPort.receive {
+							tc_ac.stop;
+							setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
+						}
+						[] tc_ac.timeout {
+							setverdict(inconc, __SCOPE__&":INFO: No answer while performing notification");
+						}
+					}	
+				
+					f_checkCseSimuStatus();
+				
+				} //end f_cse_notifyProcedure_notify	
+				
 				/**
 				 * @desc Checking of notification primitiveContent
 				 * @param p_requestPrimitive Received Notification request
diff --git a/LibOneM2M/OneM2M_Templates.ttcn b/LibOneM2M/OneM2M_Templates.ttcn
index 02ff8ea..59019ba 100644
--- a/LibOneM2M/OneM2M_Templates.ttcn
+++ b/LibOneM2M/OneM2M_Templates.ttcn
@@ -376,6 +376,16 @@ module OneM2M_Templates {
 				}
 			};
 			
+			/**
+			  * @desc RETRIEVE request primtive for polling request
+			  * @param p_targetResourceAddress Target resource address 
+			  * @param p_filterCriteria FilterCriteria
+			  * @param p_originator Originator (from)
+			 */
+			template (value) RequestPrimitive m_retrievePollingRequest(XSD.ID p_targetResourceAddress, in XSD.ID p_originator) modifies m_retrieve := {
+				to_ := p_targetResourceAddress & "/pcu"
+			};
+			
 			/**
 			  * @desc FilterCriteria empty template
 			 */
@@ -1240,13 +1250,13 @@ module OneM2M_Templates {
 			/**
 			 * @desc Base NOTIFY request primitive
 			 */
-			template RequestPrimitive m_notify := {
+			template RequestPrimitive m_notify(XSD.ID p_resourceAddress) := {
 				operation := int5,
-				to_ := "NotInitialized",
-				from_ := omit,
+				to_ := p_resourceAddress,
+				from_ := "NotInitialized",
 				requestIdentifier := testcasename() & "-m_notify" & f_rnd(1, 1000000),
 				resourceType := omit,
-				primitiveContent := {notification := m_contentCreateNotification_allOmit},
+				primitiveContent := {notification := m_contentNotification_allOmit},
 				roleIDs := omit,
 				originatingTimestamp := omit,
 				requestExpirationTimestamp := omit,
@@ -1277,7 +1287,7 @@ module OneM2M_Templates {
 				from_ := omit,
 				requestIdentifier := testcasename() & "-m_notifyAggregatedNotification" & f_rnd(1, 1000000),
 				resourceType := omit,
-				primitiveContent := {aggregatedNotification := {notification_list := {m_contentCreateNotification_allOmit,m_contentCreateNotification_allOmit}}},
+				primitiveContent := {aggregatedNotification := {notification_list := {m_contentNotification_allOmit,m_contentNotification_allOmit}}},
 				roleIDs := omit,
 				originatingTimestamp := omit,
 				requestExpirationTimestamp := omit,
@@ -1374,6 +1384,10 @@ module OneM2M_Templates {
 		}
 				
 		template PrimitiveContent mw_primitiveContent := ?;
+		
+		template PrimitiveContent mw_primitiveContentNotification (template Notification p_notification) := {
+			notification := p_notification
+		};
 		 
 		/**
 		 * @desc Base primitiveContent for CREATE operation for AEAnnc resource
@@ -2197,25 +2211,6 @@ module OneM2M_Templates {
     	  iPEDiscoveryRequest := omit
     	};
     			
-		template (value) Notification m_contentCreateNotification_allOmit := {
-		  notificationEvent := {
-		  	representation := omit,
-			operationMonitor := {
-				operation := omit,
-				originator := omit
-			},
-			notificationEventType := omit    	    
-		  },
-		  verificationRequest := omit,
-		  subscriptionDeletion := omit,
-		  subscriptionReference := omit,
-		  creator := omit,
-		  notificationForwardingURI := omit, 
-		  notificationTarget := omit,
-		  targetRemovalRequest := omit,
-		  targetRemovalAllowance := omit,
-		  iPEDiscoveryRequest := omit
-		};
 		/**
 		 * @desc 	Base primitiveContent for CREATE operation for SemanticDescriptor resource
 		 */
@@ -4072,6 +4067,23 @@ module OneM2M_Templates {
 			vendorInformation := *
     	};
     	
+    	template ResponsePrimitive mw_responsePollingResponse (template RequestPrimitive p_requestPrimitive := ?) := {
+			responseStatusCode := int2000,
+			requestIdentifier := ?,
+			primitiveContent := {requestPrimitive := p_requestPrimitive},
+			to_ := *,
+			from_ := *,
+			originatingTimestamp := *,
+			resultExpirationTimestamp := *,
+			eventCategory := *,
+			contentStatus := *,
+			contentOffset := *,
+			assignedTokenIdentifiers := *,
+			tokenRequestInformation := *,
+			releaseVersionIndicator := ?,
+			vendorInformation := *
+		};
+    	
 		template ResponsePrimitive mw_responseDiscovery (template URIList p_uriList := ?) := {
 			responseStatusCode := int2000,
 			requestIdentifier := ?,
@@ -4105,6 +4117,8 @@ module OneM2M_Templates {
 			releaseVersionIndicator := "2a",
 			vendorInformation := omit
 		};
+		
+		
     	
 		group InfoPortTemplates {
 		
diff --git a/OneM2M_Testcases_CSE_Release_2.ttcn b/OneM2M_Testcases_CSE_Release_2.ttcn
index b0d8d2e..24370a1 100644
--- a/OneM2M_Testcases_CSE_Release_2.ttcn
+++ b/OneM2M_Testcases_CSE_Release_2.ttcn
@@ -7196,6 +7196,84 @@ module OneM2M_Testcases_CSE_Release_2 {
 		
 			}//end group Basic
 		}//end group Announcement
+		
+		group PollingChannel {
+					
+			/**
+			 * @desc Check that the IUT which hosts <pollingChannel> resource forwards a Notify request successfully to a target AE, once the IUT receives a polling request from AE (retrieve request to <pollingChannelURI> resource)
+			 * 
+			 */
+			testcase TC_CSE_PCH_001() runs on Tester system CseSystem {
+					
+				var AeSimu v_ae1 := AeSimu.create("AE1") alive;
+										
+				v_ae1.start(f_CSE_PCH_001());
+							  	  	
+				v_ae1.done;
+							  	  		
+			}
+									
+			function f_CSE_PCH_001() runs on AeSimu {
+				// Local variables
+				var integer v_aeIndex := -1;
+				var integer v_resourceIndex := -1;
+				var RequestPrimitive v_request;
+				var MsgIn v_response;
+				var RequestPrimitive v_requestNotify;
+				
+				// Test control
+	
+				// Test component configuration
+				f_cf02Up();
+	
+				// Test adapter configuration
+	
+				// Preamble
+				vc_cse1.start(f_cse_registerRemoteCse(m_createRemoteCSEBase));
+				vc_cse1.done;
+				
+				v_aeIndex := f_cse_preamble_registerAe();//AE1 is registred;
+				
+				v_resourceIndex := f_cse_createResource(int15, m_createPollingChannelBase, v_aeIndex);
+				
+				v_request := valueof(m_retrievePollingRequest(f_getResourceAddress(v_resourceIndex), f_getOriginator(v_resourceIndex)));
+				mcaPort.send(m_request(v_request));
+				
+				v_requestNotify := valueof(m_notify(f_getResourceAddress(v_aeIndex)));
+				
+				vc_cse1.start(f_cse_notifyProcedure_notify(v_requestNotify));
+				
+				tc_ac.start;
+				alt {
+					[] mcaPort.receive(mw_response(mw_responsePollingResponse(v_requestNotify))) -> value v_response {
+						tc_ac.stop;
+						setverdict(pass, __SCOPE__ & ": Polling response received");
+					}
+					[] mcaPort.receive(mw_response(mw_responsePollingResponse)) { 
+						tc_ac.stop;
+						setverdict(fail, __SCOPE__ & ": Content not carrying request targeting AE1");
+					}
+					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) { 
+						tc_ac.stop;
+						setverdict(fail, __SCOPE__ & ": Wrong status code");
+					}
+					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) { 
+						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_deleteResources();
+				
+				// Tear down
+				f_cf01Down();
+			} // end TC_CSE_PCH_001
+			
+		}//end group PollingChannel
 	
 	}//end group CSE
 
-- 
GitLab