/**
 *    @author      ETSI / STF517
 *    @version     $URL$
 *                 $Id$
 *    @desc        Testcases for RLT Service
 *    @reference   ETSI TS 103 301 v1.1.1
 *    @copyright   ETSI Copyright Notification
 *                 No part may be reproduced except as authorized by written permission.
 *                 The copyright and the foregoing restriction extend to reproduction in all media.
 *                 All rights reserved.
 *
 */

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_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.1.1
             * @see       ETSI TS 103 191-2 v1.2.1 TP_IS_RLT_MSGF_BV_01
             * @reference ETSI TS 103 301 v1.1.1 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_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.1.1
             * @see       ETSI TS 103 191-2 v1.2.1 TP_IS_RLT_EVGN_BV_01
             * @reference ETSI TS 103 301 v1.1.1 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_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.1.1
             * @see       ETSI TS 103 191-2 v1.2.1 TP_IS_RLT_EVGN_BV_02
             * @reference ETSI TS 103 301 v1.1.1 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_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.1.1
             * @see       ETSI TS 103 191-2 v1.2.1 TP_IS_RLT_EVGN_BV_03
             * @reference ETSI TS 103 301 v1.1.1 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_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.1.1
             * @see       ETSI TS 103 191-2 v1.2.1 TP_IS_RLT_COMM_BV_01
             * @reference ETSI TS 103 301 v1.1.1 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_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.1.1
             * @see       ETSI TS 103 191-2 v1.2.1 TP_IS_RLT_COMM_BV_02_01
             * @reference ETSI TS 103 301 v1.1.1 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_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.1.1
             * @see       ETSI TS 103 191-2 v1.2.1 TP_IS_RLT_COMM_BV_02_02
             * @reference ETSI TS 103 301 v1.1.1 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_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.1.1
             * @see       ETSI TS 103 191-2 v1.2.1 TP_IS_RLT_COMM_BV_03
             * @reference ETSI TS 103 301 v1.1.1 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: 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.1.1
         * @see       ETSI TS 103 191-2 v1.2.1 TP_IS_RLT_MSGF_BV_02
         * @reference ETSI TS 103 301 v1.1.1 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
    
} // End of module ItsMapem_TestCases
