f_ae_createLocalResource renamed to f_ae_generateLocalResource and updated for container +

f_AE_DMR_UPD_001 and f_AE_GEN_CRE_001 updated
Signed-off-by: Miguel Angel Reina Ortega's avatarMiguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org>
parent c965a4b8
......@@ -1933,7 +1933,8 @@ module OneM2M_Functions {
v_rp := v_request.primitive.requestPrimitive;
v_parentIndex := f_getResourceIndex(v_rp.to_);
v_resourceIndex := f_ae_createLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType, v_modifiedResource);
v_modifiedResource := f_ae_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex);
if(v_resourceIndex != -1) {
mcaPortIn.send(m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, v_modifiedResource)));
setverdict(pass, __SCOPE__&":INFO: Application registered successfuly");
......@@ -1983,7 +1984,8 @@ module OneM2M_Functions {
v_rp := v_request.primitive.requestPrimitive;
v_parentIndex := f_getResourceIndex(v_rp.to_);
v_resourceIndex := f_ae_createLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType, v_modifiedResource);
v_modifiedResource := f_ae_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex);
if(v_resourceIndex != -1) {
mcaPort.send(m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, v_modifiedResource)));
setverdict(pass, __SCOPE__&":INFO: Container created successfuly");
......@@ -2017,27 +2019,46 @@ module OneM2M_Functions {
* @param p_modifiedResource Assigned and/or modified fields
* @return Internal resource index of the saved resource or -1
*/
function f_ae_createLocalResource(in PrimitiveContent p_resource, in integer p_parentIndex, in ResourceType p_resourceType, out PrimitiveContent p_modifiedResource) runs on CseSimu return integer {
function f_ae_generateLocalResource(in PrimitiveContent p_resource, in integer p_parentIndex, in ResourceType p_resourceType) runs on CseSimu return PrimitiveContent {
var integer v_resourceIndex;
var PrimitiveContent v_primitiveContent;
// AE TODO To review the code (use of indexes, generation of value for certain attributes, etc..)
if(p_resourceType == int2 and ispresent(p_resource)) {
if(ischosen(p_resource.aE)){
var AE_optional v_ae := p_resource.aE;
var AE_optional v_content := p_resource.aE;
v_resourceIndex := lengthof(vc_localResourcesList) - 1;
v_ae.resourceType := p_resourceType;
v_content.resourceType := p_resourceType;
v_ae.parentID := PX_CSE1_ID;
v_ae.creationTime := fx_generateTimestamp();
v_ae.lastModifiedTime := v_ae.creationTime;
v_ae.resourceID := "ae" & int2str(v_resourceIndex);
v_ae.aE_ID := "Cae" & int2str(v_resourceIndex);
v_ae.resourceName := "ae" & int2str(v_resourceIndex);
p_modifiedResource.aE := v_ae;
return f_setLocalResource(p_resource, p_resourceType, p_parentIndex);
v_content.parentID := PX_CSE1_ID;
v_content.creationTime := fx_generateTimestamp();
v_content.lastModifiedTime := v_content.creationTime;
v_content.resourceID := "ae" & int2str(v_resourceIndex);
v_content.aE_ID := "Cae" & int2str(v_resourceIndex);
v_content.resourceName := "ae" & int2str(v_resourceIndex);
v_primitiveContent := {aE := v_content};
return v_primitiveContent;
}
}
if(p_resourceType == int3 and ispresent(p_resource)) {
if(ischosen(p_resource.container)){
var Container_optional v_content := p_resource.container;
v_resourceIndex := lengthof(vc_localResourcesList) - 1;
v_content.resourceType := p_resourceType;
v_content.parentID := PX_CSE1_ID;
v_content.creationTime := fx_generateTimestamp();
v_content.lastModifiedTime := v_content.creationTime;
v_content.resourceID := "cnt" & int2str(v_resourceIndex);
v_content.resourceName := "cnt" & int2str(v_resourceIndex);
v_primitiveContent := {container := v_content};
return v_primitiveContent;
}
......@@ -2046,7 +2067,7 @@ module OneM2M_Functions {
// TODO: implement other resource types
// Error
return -1;
return p_resource;
}
} // end helpingFunctions
......@@ -2087,7 +2108,8 @@ module OneM2M_Functions {
[] mcaPort.receive(mw_request(mw_create)) -> value v_request {
v_rp := v_request.primitive.requestPrimitive;
v_parentIndex := f_getResourceIndex(v_rp.to_);
v_resourceIndex := f_ae_createLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType, v_modifiedResource);
v_modifiedResource := f_ae_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
v_resourceIndex := f_setLocalResource(v_modifiedResource, v_rp.resourceType, v_parentIndex);
if(v_resourceIndex != -1) {
mcaPort.send(m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, v_modifiedResource)));
}
......
......@@ -73,6 +73,10 @@ module OneM2M_Testcases_AE {
var ResponsePrimitive v_responsePrimitive;
var template UtTriggerPrimitive v_utRequest := m_utCreateContainer;
var UtTriggerAckPrimitive v_trigger_response;
var integer v_parentIndex := -1;
var integer v_resourceIndex := -1;
var MsgIn v_request;
var PrimitiveContent v_modifiedResource;
var charstring v_action := __SCOPE__ & ": Please, send a valid CREATE Request for container containing To set to " & f_getResourceAddress(-1, e_nonHierarchical, p_primitiveScope);
if(not(PICS_UNSTRUCTURED_CSE_RELATIVE_RESOURCE_ID_FORMAT)) {
......@@ -89,11 +93,13 @@ module OneM2M_Testcases_AE {
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_createContainer(-,v_utRequest.to_))) {
[] mcaPortIn.receive(mw_request(mw_createContainer(-,v_utRequest.to_))) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__, " : Container creation request received successfuly");
v_responsePrimitive := valueof(m_responsePrimitive(int2001, "To_be_defined", omit));
v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
v_modifiedResource := f_ae_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType);
v_resourceIndex := f_setLocalResource(v_modifiedResource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex);
v_responsePrimitive := valueof(m_responsePrimitive(int2001, v_request.primitive.requestPrimitive.requestIdentifier, v_modifiedResource));
mcaPortIn.send(m_response(v_responsePrimitive));
}
[] mcaPortIn.receive(mw_request(?)) {
......@@ -1419,7 +1425,10 @@ module OneM2M_Testcases_AE {
//primitives for mcaPortIn
var MsgIn v_request;
var ResponsePrimitive v_responsePrimitive;
var integer v_aeIndex := -1;
var integer v_aeIndex := -1;
var integer v_resourceIndex := -1;
var integer v_parentIndex := -1;
var PrimitiveContent v_modifiedResource;
f_cf03Up();
......@@ -1437,8 +1446,12 @@ module OneM2M_Testcases_AE {
[] mcaPortIn.receive(mw_request(p_expectedUpdateRequest)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__, " : AE registration update request is accepted!");
v_responsePrimitive := valueof(m_responsePrimitive(int2004, v_request.primitive.requestPrimitive.requestIdentifier, omit));
v_parentIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
v_modifiedResource := f_ae_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex, v_request.primitive.requestPrimitive.resourceType);
v_resourceIndex := f_setLocalResource(v_modifiedResource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex);
if(v_resourceIndex != -1) {
mcaPort.send(m_response(m_responsePrimitive_content(int2004, v_request.primitive.requestPrimitive.requestIdentifier, v_modifiedResource)));
}
//send back responsePrimitive
mcaPortIn.send(m_response(v_responsePrimitive));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment