Testing library separation: now not in launcher but isolated
[anna.git] / include / anna / testing / TestCondition.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef anna_testing_TestCondition_hpp
10 #define anna_testing_TestCondition_hpp
11
12 // Standard
13 #include <string>
14
15 // Project
16 #include <anna/core/DataBlock.hpp>
17
18
19 namespace anna {
20   namespace xml {
21     class Node;
22   }
23
24 namespace testing {
25
26
27 class TestCondition {
28
29   public:
30
31     struct Type { enum _v { Generic, Basic }; };
32     static const char* asText(const Type::_v type) throw();
33
34     TestCondition() : a_rcvFromEntity(true),
35                       a_regexp(""),
36                       a_code(""), a_bitR(""), a_hopByHop(""), a_applicationId(""),
37                       a_sessionId(""), a_resultCode(""),
38                       a_msisdn(""), a_imsi(""), a_serviceContextId("") { a_type = Type::Basic; }
39
40
41     // Source of the received message
42     void setReceivedFromEntity(bool rfe) throw() { a_rcvFromEntity = rfe; }
43     bool receivedFromEntity() const throw() { return a_rcvFromEntity; }
44
45     // Generic
46     void setRegexp(const std::string &regexp) throw() { a_regexp = regexp; }
47     // Basic
48     void setCode(const std::string &value) throw() { a_code = value; }
49     void setBitR(const std::string &value) throw() { a_bitR = value; }
50     void setHopByHop(const std::string &value) throw() { a_hopByHop = value; }
51     void setApplicationId(const std::string &value) throw() { a_applicationId = value; }
52     void setSessionId(const std::string &value) throw() { a_sessionId = value; }
53     void setResultCode(const std::string &value) throw() { a_resultCode = value; }
54     void setMsisdn(const std::string &value) throw() { a_msisdn = value; }
55     void setImsi(const std::string &value) throw() { a_imsi = value; }
56     void setServiceContextId(const std::string &value) throw() { a_serviceContextId = value; }
57
58     bool exists() const throw();
59     friend bool operator==(const TestCondition &c1, const TestCondition &c2) throw() {
60
61       if (c1.getType() != c2.getType()) return false;
62
63       if (c1.getType() == TestCondition::Type::Generic) {
64         if (c1.getRegexp() != c2.getRegexp()) return false;
65       }
66       else {
67         if (c1.getCode() != c2.getCode()) return false;
68         if (c1.getBitR() != c2.getBitR()) return false;
69         if (c1.getHopByHop() != c2.getHopByHop()) return false;
70         if (c1.getApplicationId() != c2.getApplicationId()) return false;
71         if (c1.getSessionId() != c2.getSessionId()) return false;
72         if (c1.getResultCode() != c2.getResultCode()) return false;
73         if (c1.getMsisdn() != c2.getMsisdn()) return false;
74         if (c1.getImsi() != c2.getImsi()) return false;
75         if (c1.getServiceContextId() != c2.getServiceContextId()) return false;
76       }
77
78       return true;
79     }
80
81
82
83     const Type::_v &getType() const throw() { return a_type; }
84
85     // Generic
86     const std::string & getRegexp() const throw() { return a_regexp; }
87     // Basic
88     const std::string & getCode() const throw() { return a_code; }
89     const std::string & getBitR() const throw() { return a_bitR; }
90     const std::string & getHopByHop() const throw() { return a_hopByHop; }
91     const std::string & getApplicationId() const throw() { return a_applicationId; }
92     const std::string & getSessionId() const throw() { return a_sessionId; }
93     const std::string & getResultCode() const throw() { return a_resultCode; }
94     const std::string & getMsisdn() const throw() { return a_msisdn; }
95     const std::string & getImsi() const throw() { return a_imsi; }
96     const std::string & getServiceContextId() const throw() { return a_serviceContextId; }
97
98
99     bool comply (const anna::DataBlock &message/*, bool matchSessionId*/) const throw();
100
101
102     anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
103
104
105   private:
106
107     // Source of the received message
108     bool a_rcvFromEntity;
109
110     // Type
111     Type::_v a_type;
112
113     // Generic:
114     std::string a_regexp;
115
116     // Basic:
117     std::string a_code;
118     std::string a_bitR;
119     std::string a_hopByHop;
120     std::string a_applicationId;
121     std::string a_sessionId;
122     std::string a_resultCode;
123     std::string a_msisdn;
124     std::string a_imsi;
125     std::string a_serviceContextId;
126 };
127
128 }
129 }
130
131 #endif
132