System test feature
[anna.git] / example / diameter / launcher / testing / TestCondition.hpp
diff --git a/example/diameter/launcher/testing/TestCondition.hpp b/example/diameter/launcher/testing/TestCondition.hpp
new file mode 100644 (file)
index 0000000..7ff58d9
--- /dev/null
@@ -0,0 +1,100 @@
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+
+#ifndef example_diameter_launcher_TestCondition_hpp
+#define example_diameter_launcher_TestCondition_hpp
+
+// Standard
+#include <string>
+
+// Project
+#include <anna/core/DataBlock.hpp>
+
+
+namespace anna {
+  namespace xml {
+    class Node;
+  }
+}
+
+
+class TestCondition {
+
+  public:
+
+    struct Type { enum _v { Generic, Basic }; };
+    static const char* asText(const Type::_v type) throw();
+
+    TestCondition() : a_rcvFromEntity(true),
+                      a_regexp(""),
+                      a_code(""), a_bitR(""), a_resultCode(""), a_sessionId(""),
+                      a_hopByHop(""), a_msisdn(""), a_imsi(""), a_serviceContextId("") { a_type = Type::Basic; }
+
+
+    // Source of the received message
+    void setReceivedFromEntity(bool rfe) throw() { a_rcvFromEntity = rfe; }
+    bool receivedFromEntity() const throw() { return a_rcvFromEntity; }
+
+    // Generic
+    void setRegexp(const std::string &regexp) throw() { a_regexp = regexp; }
+    // Basic
+    void setCode(const std::string &value) throw() { a_code = value; }
+    void setBitR(const std::string &value) throw() { a_bitR = value; }
+    void setResultCode(const std::string &value) throw() { a_resultCode = value; }
+    void setSessionId(const std::string &value) throw() { a_sessionId = value; }
+    void setHopByHop(const std::string &value) throw() { a_hopByHop = value; }
+    void setMsisdn(const std::string &value) throw() { a_msisdn = value; }
+    void setImsi(const std::string &value) throw() { a_imsi = value; }
+    void setServiceContextId(const std::string &value) throw() { a_serviceContextId = value; }
+
+    bool exists() const throw();
+    friend bool operator==(const TestCondition &c1, const TestCondition &c2) throw();
+
+    // Generic
+    const std::string & getRegexp() const throw() { return a_regexp; }
+    // Basic
+    const std::string & getCode() const throw() { return a_code; }
+    const std::string & getBitR() const throw() { return a_bitR; }
+    const std::string & getResultCode() const throw() { return a_resultCode; }
+    const std::string & getSessionId() const throw() { return a_sessionId; }
+    const std::string & getHopByHop() const throw() { return a_hopByHop; }
+    const std::string & getMsisdn() const throw() { return a_msisdn; }
+    const std::string & getImsi() const throw() { return a_imsi; }
+    const std::string & getServiceContextId() const throw() { return a_serviceContextId; }
+
+
+    bool comply (const anna::DataBlock &message/*, bool matchSessionId*/) const throw();
+
+
+    anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
+
+
+  private:
+
+    // Source of the received message
+    bool a_rcvFromEntity;
+
+    // Type
+    Type::_v a_type;
+
+    // Generic:
+    std::string a_regexp;
+
+    // Basic:
+    std::string a_code;
+    std::string a_bitR;
+    std::string a_resultCode;
+    std::string a_sessionId;
+    std::string a_hopByHop;
+    std::string a_msisdn;
+    std::string a_imsi;
+    std::string a_serviceContextId;
+};
+
+
+#endif