Updated documentation for mock a1 tool
[ric-app/admin.git] / test / unit_test_indicator.cc
1 /*
2 ==================================================================================
3
4         Copyright (c) 2018-2019 AT&T Intellectual Property.
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19 /* Author : Ashwin Sridharan
20    Date    : Feb 2019
21 */
22
23 #define CATCH_CONFIG_MAIN
24 #include <catch2/catch.hpp>
25 #include <Indication_builder.hpp>
26
27 TEST_CASE("E2AP PDUs", "RIC Indication PDU"){
28
29   int req_id = 100;
30   int req_seq_no = 200;
31   int func_id = 999;
32   int action_id = 18;
33   int sn = 20;
34   int type = 1;
35   std::string header = "Indication Header";
36   std::string message = "addition request";
37   std::string call_process_id = "message_23";
38   
39   
40   E2AP_PDU_builder e2ap_pdu_builder(1);
41   IndicationBuilder ric_indication(e2ap_pdu_builder.get_e2ap_pdu());
42   IndicationHelper he_indication;
43   he_indication.set_request(req_id, req_seq_no);
44   he_indication.set_function_id(func_id);
45   he_indication.set_action_id(action_id);
46   he_indication.set_indication_sn(sn);
47   he_indication.set_indication_type(type);
48
49   he_indication.set_indication_header(header.c_str(), header.length());
50   he_indication.set_indication_message(message.c_str(), message.length());
51   he_indication.set_call_process_id(call_process_id.c_str(), call_process_id.length());
52
53   ric_indication.setRICrequestID(he_indication);
54   ric_indication.setRANfunctionID(he_indication);
55   ric_indication.setRICactionID(he_indication);
56   ric_indication.setRICindicationSN(he_indication);
57   ric_indication.setRICindicationType(he_indication);
58   ric_indication.setRICindicationHeader(he_indication);
59   ric_indication.setRICindicationMessage(he_indication);
60   ric_indication.setRICcallProcessID(he_indication);
61   
62   unsigned char buffer[1024];
63   unsigned int pdu_length;
64   
65   bool res = e2ap_pdu_builder.encode_pdu(buffer, 1024, &pdu_length);
66   REQUIRE (res == true);
67
68   res = e2ap_pdu_builder.decode_pdu(buffer, pdu_length);
69   REQUIRE (res == true);
70
71   IndicationHelper he_indication2;
72   ric_indication.reset(e2ap_pdu_builder.get_e2ap_pdu());
73   ric_indication.get_fields(he_indication2);
74   REQUIRE(he_indication2.get_request_id() == req_id);
75   REQUIRE(he_indication2.get_req_seq() == req_seq_no);
76   REQUIRE(he_indication2.get_function_id() == func_id);
77   REQUIRE(he_indication2.get_indication_sn() == sn);
78   REQUIRE(he_indication2.get_action_id() == action_id);
79   REQUIRE(he_indication2.get_indication_type() == type);
80
81   std::string header2(static_cast<const char *>(he_indication2.get_indication_header()), he_indication2.get_indication_header_size());
82   REQUIRE(header2 == header);
83   
84 }
85