/**
 *    @author   ETSI / STF517
 *    @version  $URL$
 *              $Id$
 *    @desc     MAPEM Testcases (TP version: 0.0.1)
 *
 */

module ItsMapem_TestCases {
    
    // LibItsMapemSpatem
    import from LibItsMapemSpatem_TestSystem all;
    
    // ItsMapemSpatem
    import from ItsMapem_TpFunctions all;
    
    group mapeMessageDissemination { 
        
        group mapeMessageFormat { 
            
            /**
             * @desc Check that protocolVersion is set to 1 and messageID is set to 4
             * <pre>
             * Pics Selection: PICS_RSU_ROLE and PICS_MAPEM_GENERATION
             * Initial conditions: 
             *   with {
             *        the IUT being in the "initial state"
             *        and the IUT sending MAPEM
             *    }
             * Expected behaviour:
             *    ensure that {
             *        when { 
             *            a MAPEM is generated
             *        }
             *        then {
             *            the IUT sends a valid MAPEM
             *                containing ITS PDU header
             *                    containing protocolVersion
             *                        indicating value '1'
             *                    and containing messageID
             *                        indicating value '5'
             *        }
             *    }
             * </pre>
             * 
             * @version   1.0.4
             * @see       ETSI TS 103 191-2 v0.0.1 TP_IS_RLT_MSGF_BV_01
             * @reference ETSI TS 103 301 V1.0.4 Clause 6.3
             */
            testcase TC_IS_RLT_MSGF_BV_01 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
                
                f_IS_RLT_MSGF_BV_01();
                
            } // End of testcase TC_IS_RLT_MSGF_BV_01
            
        } // End of group mapeMessageFormat
        
        group mapeEventGeneration { 
            
            /**
             * @desc Check that IVI Service generates a new MAPEM on reception of a valid AppMAPEM_Trigger request
             * <pre>
             * Pics Selection: PICS_RSU_ROLE and PICS_MAPEM_GENERATION
             * Initial conditions: 
             *   with {
             *        the IUT being in the "initial state"
             *        and the IUT sending MAPEM
             *    }
             * Expected behaviour:
             *    ensure that {
             *        when { 
             *            a MAPEM is generated
             *        }
             *        then {
             *            the IUT sends a valid MAPEM
             *        }
             *    }
             * </pre>
             * 
             * @version   1.0.4
             * @see       ETSI TS 103 191-2 v0.0.1 TP_IS_RLT_EVGN_BV_01
             * @reference ETSI TS 103 301 V1.0.4 Clause 6.4.1
             */
            testcase TC_IS_RLT_EVGN_BV_01 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
                
                f_IS_RLT_EVGN_BV_01();
                
            } // End of testcase TC_IS_RLT_EVGN_BV_01
            
            /**
             * @desc Check that RLT Service transmits new content
             * <pre>
             * Pics Selection: PICS_RSU_ROLE and PICS_MAPEM_GENERATION
             * Initial conditions: 
             *   with {
             *        the IUT being in the "initial state"
             *        and the IUT sending MAPEM
             *            containing map
             *                not containing LayerType
             *                and not containing LayerID
             *                and containing restrictionList
             *                    indicating the value RL_1
             *    }
             * Expected behaviour:
             *    ensure that {
             *        when { 
             *            the IUT is alerted about a new restrictionList indicating the value RL_2
             *        }
             *        then {
             *            the IUT sends a valid MAPEM
             *                containing map
             *                    not containing LayerType
             *                    and not containing LayerID
             *                    and containing restrictionList
             *                        indicating indicating the value R_2
             *        }
             *    }
             * </pre>
             * 
             * @version   1.0.4
             * @see       ETSI TS 103 191-2 v0.0.1 TP_IS_RLT_EVGN_BV_02
             * @reference ETSI TS 103 301 V1.0.4 Clause 6.4.1
             */
            testcase TC_IS_RLT_EVGN_BV_02 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
                
                f_IS_RLT_EVGN_BV_02();
                
            } // End of testcase TC_IS_RLT_EVGN_BV_02
            
            /**
             * @desc Check that RLT Service transmits fragmented MAPEM when the message size exceeds the allowed message length 
             * <pre>
             * Pics Selection: PICS_RSU_ROLE and PICS_MAPEM_GENERATION
             * Initial conditions: 
             *   with {
             *        the IUT being in the "initial state"
             *        and the IUT has sent a MAPEM
             *    }
             * Expected behaviour:
             *    ensure that {
             *        when { 
             *            the IUT is alerted about a new content
             *                indicating a new value which exceeds the allowed message length 
             *        }
             *        then {
             *            the IUT sends a first valid MAPEM
             *            containing map
             *                containing LayerType
             *                and containing LayerID
             *                    indication a value LID_1
             *            and the IUT sends a second valid MAPEM
             *                containing map
             *                    containing LayerType
             *                    and containing LayerID
             *                        indication a value LID_2 = LID_1 + 1
             *        }
             *    }
             * </pre>
             * 
             * @version   1.0.4
             * @see       ETSI TS 103 191-2 v0.0.1 TP_IS_RLT_EVGN_BV_03
             * @reference ETSI TS 103 301 V1.0.4 Clause 6.4.1
             */
            testcase TC_IS_RLT_EVGN_BV_03 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
                
                f_IS_RLT_EVGN_BV_03();
                
            } // End of testcase TC_IS_RLT_EVGN_BV_03
            
        } // End of group mapeEventGeneration
        
        group mapeCommunication {
            
            /**
             * @desc Check that the RLT Service transmits continuously both MAPEM and SPATEM
             * <pre>
             * Pics Selection: PICS_RSU_ROLE and PICS_MAPEM_GENERATION and PICS_SPATEM_GENERATION
             * Initial conditions: 
             *   with {
             *        the IUT being in the "initial state"
             *        and the IUT sending MAPEM
             *        and the IUT has not sent any SPATEM yet
             *    }
             * Expected behaviour:
             *    ensure that {
             *        when { 
             *            the IUT receives an AppSPATEM_Start request from the application layer
             *        }
             *        then {
             *            the IUT sends a valid SPATEM
             *            and the IUT sends a valid MAPEM
             *        }
             *    }
             * </pre>
             * 
             * @version   1.0.4
             * @see       ETSI TS 103 191-2 v0.0.1 TP_IS_RLT_COMM_BV_01
             * @reference ETSI TS 103 301 V1.0.4 Clause 6.4.3.1
             */
            testcase TC_IS_RLT_COMM_BV_01 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
                
                f_IS_RLT_COMM_BV_01();
                
            } // End of testcase TC_IS_RLT_COMM_BV_01
            
            /**
             * @desc Check that MAPEM uses BTP_B packet
             * <pre>
             * Pics Selection: PICS_RSU_ROLE and PICS_MAPEM_GENERATION
             * Initial conditions: 
             *   with {
             *        the IUT being in the "initial state"
             *        and the IUT sending MAPEM 
             *    }
             * Expected behaviour:
             *    ensure that {
             *        when { 
             *            a MAPEM is generated
             *        }
             *        then {
             *            the IUT sends a valid MAPEM
             *                encapsulated in a BTP-B packet
             *        }
             *    }
             * </pre>
             * 
             * @version   1.0.4
             * @see       ETSI TS 103 191-2 v0.0.1 TP_IS_RLT_COMM_BV_02_01
             * @reference ETSI TS 103 301 V1.0.4 Clause 6.4.3.2
             */
            testcase TC_IS_RLT_COMM_BV_02_01 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
                
                f_IS_RLT_COMM_BV_02_01();
                
            } // End of testcase TC_IS_RLT_COMM_BV_02_01
            
            /**
             * @desc Check that the destination port for MAPEM is set to 2003
             * <pre>
             * Pics Selection: PICS_RSU_ROLE and PICS_MAPEM_GENERATION
             * Initial conditions: 
             *   with {
             *        the IUT being in the "initial state"
             *        and the IUT sending MAPEM 
             *    }
             * Expected behaviour:
             *    ensure that {
             *        when { 
             *            a MAPEM is generated
             *        }
             *        then {
             *            the IUT sends a valid MAPEM
             *                encapsulated in a BTP packet
             *                   containing a destination port value set to 2003
             *                   and containing a destination port info value set to 0
             *        }
             *    }
             * </pre>
             * 
             * @version   1.0.4
             * @see       ETSI TS 103 191-2 v0.0.1 TP_IS_RLT_COMM_BV_02_02
             * @reference ETSI TS 103 301 V1.0.4 Clause 6.4.3.2
             */
            testcase TC_IS_RLT_COMM_BV_02_02 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
                
                f_IS_RLT_COMM_BV_02_02();
                
            } // End of testcase TC_IS_RLT_COMM_BV_02_02
            
            /**
             * @desc Check that TLM service encapsulates MAPEM in a GBC with the HeaderType field set to the value of 4
             * <pre>
             * Pics Selection: PICS_RSU_ROLE and PICS_MAPEM_GENERATION
             * Initial conditions: 
             *   with {
             *        the IUT being in the "initial state"
             *        and the IUT sending MAPEM
             *    }
             * Expected behaviour:
             *    ensure that {
             *        when { 
             *            a MAPEM is generated
             *        }
             *        then {
             *            the IUT sends a valid MAPEM
             *                encapsulated in a GBC packet
             *                    containing a correctly formatted Common Header
             *                        containing HeaderType field
             *                            indicating the value '4'
             *        }
             *    }
             * </pre>
             * 
             * @version   1.0.4
             * @see       ETSI TS 103 191-2 v0.0.1 TP_IS_RLT_COMM_BV_03
             * @reference ETSI TS 103 301 V1.0.4 Clause 6.4.3.1
             */
            testcase TC_IS_RLT_COMM_BV_03 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
                
                f_IS_RLT_COMM_BV_03();
                
            } // End of testcase TC_IS_RLT_COMM_BV_03
            
        } // End of group mapeCommunication 
        
    } // End of group mapeMessageDissemination
    
    group mapeMessageProcessing {
        
        /**
         * @desc Check that the IUT can successfully process all mandatory fields of MAPEM received
         * <pre>
         * Pics Selection: not PICS_RSU_ROLE and PICS_MAPEM_RECEPTION
         * Initial conditions: 
         *   with {
         *        the IUT being in the "initial state"
         *        and the IUT having receive a valid MAPEM
         *    }
         * Expected behaviour:
         *    ensure that {
         *        when { 
         *            the IUT receives a valid MAPEM
         *        }
         *        then {
         *            the IUT forwards the MAPEM content to upper layers
         *            and the IUT forwards the MAPEM content to other facilities
         *        }
         *    }
         * </pre>
         * 
         * @version   1.0.4
         * @see       ETSI TS 103 191-2 v0.0.1 TP_IS_RLT_MSGF_BV_02
         * @reference ETSI TS 103 301 V1.0.4 Clause 6.3
         */
        testcase TC_IS_RLT_MSGF_BV_02 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
            
            f_IS_RLT_MSGF_BV_02();
            
        } // End of testcase TC_IS_RLT_MSGF_BV_02
        
    } // End of group mapeMessageProcessing
    
//    group MapemSpatemMessageDissemination { 
//            
//        /**
//        * @desc Verify that when sending a MapData message the DSRCmsgSubID is set to value 1.
//        * <pre>
//        * Pics Selection: PICS_RSU_ROLE
//        * Initial conditions: 
//        *   with {
//        *        the IUT being in the "initial state"
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            a MapData message is generated
//        *        }
//        *        then {
//        *            the IUT sends a valid MapData message
//        *                containing DSRCmsgSubID
//        *                    set to value 1
//        *        }
//        *    }
//        * </pre>
//        * 
//        * @version   0.0.1
//        * @see       ETSI TS 103 191-2 v0.0.1 TP/MAPEM-SPATEM/MSD/BV-01
//        * @reference ETSI TS 103 301 V1.0.4 Clause 7.34
//        */
//        testcase TC_IS_RLT_MSD_BV_01 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_mapSubId1 ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received MAPEM with DSRCmsgSubID == 1. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                }
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_anyMap ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": FAIL: Received an incorrect MAPEM message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
//                }
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                            
//        } // End of testcase TC_IS_RLT_MSD_BV-01
//
//        /**
//        * @desc Verify that when sending a SPATEM the DSRCmsgSubID is set to value 1.
//        * <pre>
//        * Pics Selection: PICS_RSU_ROLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            a SPATEM is generated
//        *        }
//        *        then {
//        *            the IUT sends a valid SPATEM message
//        *                containing DSRCmsgSubID
//        *                    set to value 1
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version     0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSD//BV-02
//        * @reference ETSI TS 103 301 V1.0.4 Clause 7.34
//        */
//        testcase TC_IS_RLT_MSD_BV_02 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//            
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            // Triggering a SPATEM message
//            f_utTriggerEvent ( m_utTriggerEvent ( spateMsg ) );
//            
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_spatemInd ( mw_spatemPdu ( mw_itsPduHeaderSpatem , mw_spatSubId1 ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received SPATEM with DSRCmsgSubID == 1. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                }
//                [] mapemSpatemPort.receive ( mw_spatemInd ( mw_spatemPdu ( mw_itsPduHeaderSpatem , mw_defaultSpatem ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": FAIL: Received an incorrect MAPEM message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
//                }
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSD_BV-02
//
//        /**
//        * @desc Repetition < 10s. Verify that: when the IUT is composing a new message with the same content as the most recent message
//        * with the same DSRCmsgID, and less than 10 seconds have elapsed since it sent the previous message, the IUT uses the same MsgCount value.
//        * <pre>
//        * Pics Selection: PICS_RSU_ROLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *        and the IUT has sent a MapData message
//        *            containing MsgCount
//        *                set to VALUE_1
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            a new MapData message with the same content is generated
//        *            and the repetition time is lesser than 10 s
//        *        }
//        *        then {
//        *            the IUT sends a valid MapData message
//        *                containing MsgCount
//        *                    set to VALUE_1
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version   0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSD//BV-05
//        * @reference ETSI TS 103 301 V1.0.4 Clause 7.92
//        */
//        testcase TC_IS_RLT_MSD_BV_05 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//            var MsgCount    v_msgCount;
//            var MapemInd        v_message;
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            // Triggering MAPEM repetition lesser than 10s
//            v_msgCount := f_utTriggerEvent ( m_utTriggerEvent ( mapRepL10s ) );
//            // Receiving first MAPEM message
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_anyMap ) ) ) -> value v_message { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received first MAPEM message. ***");
//                    v_msgCount := v_message.msgIn.msgMapem.map_.msgIssueRevision;
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
//                }
//            }
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            // Receiving repetition MAPEM before 10s
//            tc_ac.start (10.0);
//            alt {
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_anyMap ) ) ) -> value v_message { 
//                    tc_ac.stop;
//                    if ( v_message.msgIn.msgMapem.map_.msgIssueRevision == v_msgCount ) {
//                        log("*** " & testcasename() & ": PASS: Successfully received Second MAPEM with correct Count. ***");
//                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                    }
//                    else {
//                        log("*** " & testcasename() & ": FAIL: Received an incorrect MAPEM message. ***");
//                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//                    }
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
//                }
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSD_BV-05
//
//        /**
//        * @desc Repetition >= 10s Verify that: when the IUT is composing a new message with the same content as the most recent message
//        * with the same DSRCmsgID, and at least 10 seconds have elapsed since it sent the previous message, the IUT sets the MsgCount to any valid value.
//        * <pre>
//        * Pics Selection: PICS_RSU_ROLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *        and the IUT has sent a MapData message
//        *            containing MsgCount
//        *                set to VALUE_1
//}
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            a new MapData message with the same content is generated
//        *            and the repetition time is greather or egal  than 10 s
//        *        }
//        *        then {
//        *            the IUT sends a valid MapData message
//        *                containing MsgCount
//        *                    set to any valid value
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version   0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSD//BV-06
//        * @reference ETSI TS 103 301 V1.0.4 Clause 7.92
//        */
//        testcase TC_IS_RLT_MSD_BV_06 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//            var MsgCount    v_msgCount;
//            var MapemInd        v_message;
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            // Triggering MAPEM repetition greather than 10s
//            v_msgCount := f_utTriggerEvent ( m_utTriggerEvent ( mapRepG10s ) );
//            // Receiving first MAPEM message
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_anyMap ) ) ) -> value v_message { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received first MAPEM message. ***");
//                    v_msgCount := v_message.msgIn.msgMapem.map_.msgIssueRevision;
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
//                }
//            }
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            // Receiving repetition MAPEM after 10s
//            tc_ac.start (20.0);
//            alt {
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_anyMap ) ) ) -> value v_message { 
//                    tc_ac.stop;
//                    if ( v_message.msgIn.msgMapem.map_.msgIssueRevision != v_msgCount ) {
//                        log("*** " & testcasename() & ": PASS: Successfully received Second MAPEM with correct Count. ***");
//                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                    }
//                    else {
//                        log("*** " & testcasename() & ": FAIL: Received an incorrect MAPEM message. ***");
//                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//                    }
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
//                }
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSD_BV-06
//
//        /**
//        * @desc Verify that the MsgCRC (if present) is the last data element of the MapData message.
//        * <pre>
//        * Pics Selection: PICS_RSU_ROLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            a MapData message is generated
//        *        }
//        *        then {
//        *            the IUT sends a valid MapData message
//        *                not containing MsgCRC
//        *                or
//        *                containing MsgCRC
//        *                    as the last data element of the message
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version   0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSD//BV-08
//        * @reference ETSI TS 103 301 V1.0.4 Clause 7.93
//        */
//        testcase TC_IS_RLT_MSD_BV_08 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_mapNoMsgCrc ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received MAPEM with no MsgCRC. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                }
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_mapMsgCrcLast ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received MAPEM with MsgCRC as the last data element of the message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                }
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_anyMap ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": FAIL: Received an incorrect MAPEM message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
//                }
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSD_BV-08
//
//        /**
//        * @desc Verify that the LayerType is not contained in the MapData message.
//        * <pre>
//        * Pics Selection: PICS_RSU_ROLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            a MapData message is generated
//        *        }
//        *        then {
//        *            the IUT sends a valid MapData message
//        *                not containing LayerType
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version     0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSD//BV-09
//        * @reference ETSI TS 103 301 V1.0.4 Clause 7.83
//        */
//        testcase TC_IS_RLT_MSD_BV_09 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_mapNoLayerType ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received MAPEM with no LayerType. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                }
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_anyMap ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": FAIL: Received an incorrect MAPEM message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
//                }
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSD_BV-09
//
//        /**
//        * @desc Verify that the IntersectionReferenceID contained in the SPATEM correspond to a previously received intersection MAPEM.
//        * <pre>
//        * Pics Selection: PICS_RSU_ROLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *        and the IUT has sent a MapData message
//        *            containing IntersectionList
//        *                containing INTERSECTION_1
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            a SPATEM is generated
//        *        }
//        *        then {
//        *            the IUT sends a valid SPATEM message
//        *                 containing IntersectionReferenceID
//        *                    corresponding to INTERSECTION_1 
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version     0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSD//BV-10
//        * @reference ETSI TS 103 301 V1.0.4 Clause 6.29
//        */
//        testcase TC_IS_RLT_MSD_BV_10 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//            var MapemInd        v_message;
//            var SpatemInd        v_spat;
//            var IntersectionGeometryList v_intersections;
//            var integer        i,j;
//            var boolean        v_result := false;
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            // Receiving MAPEM - Saving IntersectionList
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_anyMap ) ) ) -> value v_message { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received MAPEM message. ***");
//                    v_intersections := v_message.msgIn.msgMapem.map_.intersections;
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
//                }
//            }
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            f_utTriggerEvent ( m_utTriggerEvent ( spateMsg ) );
//            
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_spatemInd ( mw_spatemPdu ( mw_itsPduHeaderSpatem , mw_defaultSpatem ) ) ) -> value v_spat { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": Successfully received SPATEM message. ***");
//                    for ( i := 0 ; i < lengthof ( v_intersections ) and not v_result ; i := i+1 ) {
//                        for ( j := 0 ; j < lengthof ( v_spat.msgIn.msgSpatem.spat.intersections ) ; j := j+1 ) {
//                            if ( v_intersections[ i ].id == v_spat.msgIn.msgSpatem.spat.intersections[ j ].id ) {
//                                v_result := true;
//                            }
//                        }
//                    }
//                    if ( v_result ) {
//                        log("*** " & testcasename() & ": PASS: concordance of intersection ID. ***");
//                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                    }
//                    else {
//                        log("*** " & testcasename() & ": FAIL: non concordance of intersection ID. ***");
//                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//                    }
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
//                }
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSD_BV-10
//
//        /**
//        * @desc Verify that the MapData message is well formatted.
//        * <pre>
//        * Pics Selection: PICS_RSU_ROLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            a MapData message is generated
//        *        }
//        *        then {
//        *            the IUT sends a valid MapData message
//        *                containing DSRCmsgSubID
//        *                    set to value 1
//        *                containing MsgCount
//        *                not containing LayerType
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version     0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSD//BV-11
//        * @reference ETSI TS 103 301 V1.0.4 Clause 10
//        */
//        testcase TC_IS_RLT_MSD_BV_11 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_mapWellFormatted ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received a well formatted MAPEM. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                }
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_anyMap ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": FAIL: Received an incorrect MAPEM message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
//                }
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSD_BV-11
//
//        /**
//        * @desc Verify that the SPATEM is well formatted.
//        * <pre>
//        * Pics Selection: PICS_RSU_ROLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            a SPATEM is generated
//        *        }
//        *        then {
//        *            the IUT sends a valid SPATEM message
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version     0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSD//BV-12
//        * @reference ETSI TS 103 301 V1.0.4 Clause 10
//        */
//        testcase TC_IS_RLT_MSD_BV_12 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            // Triggering a SPATEM message
//            f_utTriggerEvent ( m_utTriggerEvent ( spateMsg ) );
//            
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_spatemInd ( mw_spatemPdu ( mw_itsPduHeaderSpatem , mw_spatSubId1 ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received SPATEM with DSRCmsgSubID == 1. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                }
//                [] mapemSpatemPort.receive ( mw_spatemInd ( mw_spatemPdu ( mw_itsPduHeaderSpatem , mw_defaultSpatem ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": FAIL: Received an incorrect MAPEM message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
//                }
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSD_BV-12
//
//        /**
//        * @desc Verify that when sending a MapData message, the IUT encapsulates the message into a GN SHB message.
//        * <pre>
//        * Pics Selection: PICS_RSU_ROLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            a MapData message is generated
//        *        }
//        *        then {
//        *            the IUT sends a valid MapData message encapsulated into a GN SHB message
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version     0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSD//BV-15
//        * @reference No clause – Implicit to use in ITS
//        */
//        testcase TC_IS_RLT_MSD_BV_15 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//            var MapemInd        v_message;
//            const UInt8 c_gnHtTsb := 5;
//            const UInt8 c_gnHstShb := 0;
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_mapemIndWithGnParameters ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_mapWellFormatted ), -, c_gnHtTsb, c_gnHstShb ) ) -> value v_message { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received MAPEM. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                }
//                [] mapemSpatemPort.receive ( mw_mapemInd ( mw_mapemPdu ( mw_itsPduHeaderMapem , mw_anyMap ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": FAIL: Received an incorrect MAPEM message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
//                }
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSD_BV-15
//
//        /**
//        * @desc Verify that when sending a SPATEM message, the IUT encapsulates the message into a GN SHB message.
//        * <pre>
//        * Pics Selection: PICS_RSU_ROLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            a SPATEM is generated
//        *        }
//        *        then {
//        *            the IUT sends a valid SPATEM encapsulated into a GN SHB message
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version     0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSD//BV-16
//        * @reference No clause – Implicit to use in ITS
//        */
//        testcase TC_IS_RLT_MSD_BV_16 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//            var SpatemInd        v_message;
//            const UInt8 c_gnHtTsb := 5;
//            const UInt8 c_gnHstShb := 0;
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            f_utTriggerEvent ( m_utTriggerEvent ( spateMsg ) );
//            
//            tc_ac.start;
//            alt {
//                [] mapemSpatemPort.receive ( mw_spatemIndWithGnParameters ( mw_spatemPdu ( mw_itsPduHeaderSpatem , mw_spatSubId1 ), -, c_gnHtTsb, c_gnHstShb ) ) -> value v_message { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": PASS: Successfully received SPATEM. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//                }
//                [] mapemSpatemPort.receive ( mw_spatemInd ( mw_spatemPdu ( mw_itsPduHeaderSpatem , mw_defaultSpatem ) ) ) { 
//                    tc_ac.stop;
//                    log("*** " & testcasename() & ": FAIL: Received an incorrect MAPEM message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//                }
//                []    tc_ac.timeout {
//                    log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
//                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
//                }
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSD_BV-16
//
//    } // End of group MapemSpatemMessageDissemination
//
//    group MapemSpatemMessageProcessing { 
//
//        /**
//        * @desc Verify  that: when the IUT receives a GN SHB message encapsulating a MapData message, it pass the message to the application layer.
//        * <pre>
//        * Pics Selection: PICS_VEHICLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            the IUT receives a valid MapData message encapsulated into a GN SHB message
//            *    }
//        *        then {
//        *            the IUT forwards the MapData message content to upper layers
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version   0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSP//BV-01
//        * @reference No clause – Implicit to use in ITS
//        */
//        testcase TC_IS_RLT_MSP_BV_01 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//            var MapReq        v_mapReq;
//            var integer        i;
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            v_mapReq := valueof (  m_mapemReq ( m_mapemPdu ( m_map ) ) );
//            mapemSpatemPort.send( v_mapReq ) ;
//            
//            f_sleep(PX_TAC);
//            for ( i:=0 ; i < lengthof ( vc_utMapEvents ) and not match ( v_mapReq.msgOut, vc_utMapEvents[i].mapeMsg ) ; i := i+1 ) {
//                // empty on purpose 
//            }
//            if ( i < lengthof ( vc_utMapEvents ) ) {
//                log("*** " & testcasename() & ": PASS: MAPEM was transmitted to upper layer ***");
//                f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//            }
//            else {
//                log("*** " & testcasename() & ": FAIL: MAPEM was not transmitted to upper layer ***");
//                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSP_BV_01
//
//        /**
//        * @desc Verify  that: when the IUT receives a GN SHB message encapsulating a SPATEM message, it pass the message to the application layer.
//        * <pre>
//        * Pics Selection: PICS_VEHICLE
//        * Initial conditions: 
//        *    with {
//        *        the IUT being in the "initial state"
//        *    }
//        * Expected behaviour:
//        *    ensure that {
//        *        when { 
//        *            the IUT receives a valid SPATEM encapsulated into a GN SHB message
//            *    }
//        *        then {
//        *            the IUT forwards the SPATEM content to upper layers
//        *        }
//        *    }
//        * </pre>
//        *
//        * @version   0.0.1
//        * @see         ETSI TS 103 191-2 V0.0.1 TP/MAPEM-SPATEM/MSP//BV-02
//        * @reference No clause – Implicit to use in ITS
//        */
//        testcase TC_IS_RLT_MSP_BV_02 () runs on ItsMapemSpatem system ItsMapemSpatemSystem {
//                
//            // Local variables
//            var SpatemReq        v_spatReq;
//            var integer        i;
//                
//            // Test component configuration
//            f_cfUp();
//                
//            // Preamble
//            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                
//            // Test Body
//            v_spatReq := valueof (  m_spatemReq ( m_spatemPdu ( m_spat ) ) );
//            mapemSpatemPort.send ( v_spatReq ) ;
//            
//            f_sleep(PX_TAC);
//            for ( i:=0 ; i < lengthof ( vc_utSpatemEvents ) and not match ( v_spatReq.msgOut , vc_utSpatemEvents[i].spateMsg ) ; i:=i+1 ) {
//                // empty on purpose 
//            }
//            if ( i < lengthof ( vc_utSpatemEvents ) ) {
//                log("*** " & testcasename() & ": PASS: SPATEM was transmitted to upper layer ***");
//                f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
//            }
//            else {
//                log("*** " & testcasename() & ": FAIL: SPATEM was not transmitted to upper layer ***");
//                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
//            }
//                
//            // Postamble
//            f_poDefault();
//            f_cfDown();
//                
//        } // End of testcase TC_IS_RLT_MSP_BV_02
//
//    } // End of group MapemSpatemMessageProcessing
//    
} // End of module ItsMapem_TestCases
