X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=blobdiff_plain;f=source%2Ftesting%2FTestCase.cpp;fp=source%2Ftesting%2FTestCase.cpp;h=c357e9326f915473695d2c64b9fc8d5255a3ba66;hp=991a254887e1cfa2fce2ee9a462eeace6901a5f3;hb=f34b8069233e9e09208339bb79d8576c1ff962e1;hpb=cef452116c2966d7eaa65ff31ee7613bf3ae1b93 diff --git a/source/testing/TestCase.cpp b/source/testing/TestCase.cpp index 991a254..c357e93 100644 --- a/source/testing/TestCase.cpp +++ b/source/testing/TestCase.cpp @@ -73,6 +73,7 @@ std::string TestCase::DebugSummary::asString() const { TestCase::TestCase(unsigned int id, const std::string &description) : a_id(id), + a_key(""), a_description((description != "") ? description : (anna::functions::asString("Testcase_%d", id))), a_state(State::Initialized), a_startTimestamp(0), @@ -107,6 +108,7 @@ anna::xml::Node* TestCase::asXML(anna::xml::Node* parent) const anna::xml::Node* result = parent->createChild("TestCase"); result->createAttribute("Id", a_id); + if (a_key != "") result->createAttribute("Key", a_key); result->createAttribute("Description", a_description); result->createAttribute("State", asText(a_state)); result->createAttribute("StartTimestamp", a_startTimestamp.asString()); @@ -311,7 +313,9 @@ void TestCase::assertInitialized() const noexcept(false) { throw anna::RuntimeException(anna::functions::asString("Cannot program anymore. The test case %llu (%s) has finished. You must reset it to append new steps (or do it during execution, which is also allowed).", a_id, a_description.c_str()), ANNA_FILE_LOCATION); } -void TestCase::assertMessage(const anna::DataBlock &db, bool toEntity) noexcept(false) { +std::string TestCase::assertMessage(const anna::DataBlock &db, bool toEntity) noexcept(false) { + + std::string key; bool isRequest = anna::diameter::codec::functions::isRequest(db); bool registerKeys = ((isRequest && toEntity) || (!isRequest && !toEntity) /* (*) */); @@ -330,16 +334,19 @@ void TestCase::assertMessage(const anna::DataBlock &db, bool toEntity) noexcept( if (registerKeys) { TestManager &testManager = TestManager::instantiate(); - testManager.registerKey1(anna::diameter::helpers::base::functions::getSessionId(db), this); + key = anna::diameter::helpers::base::functions::getSessionId(db); + testManager.registerKey1(key, this); - std::string subscriberId = anna::diameter::helpers::dcca::functions::getSubscriptionIdData(db, anna::diameter::helpers::dcca::AVPVALUES__Subscription_Id_Type::END_USER_E164); - if (subscriberId == "") // try with IMSI - subscriberId = anna::diameter::helpers::dcca::functions::getSubscriptionIdData(db, anna::diameter::helpers::dcca::AVPVALUES__Subscription_Id_Type::END_USER_IMSI); + key = anna::diameter::helpers::dcca::functions::getSubscriptionIdData(db, anna::diameter::helpers::dcca::AVPVALUES__Subscription_Id_Type::END_USER_E164); + if (key == "") // try with IMSI + key = anna::diameter::helpers::dcca::functions::getSubscriptionIdData(db, anna::diameter::helpers::dcca::AVPVALUES__Subscription_Id_Type::END_USER_IMSI); - if (subscriberId != "") - testManager.registerKey2(subscriberId, this); + if (key != "") + testManager.registerKey2(key, this); } + + return key; } void TestCase::addTimeout(const anna::Millisecond &timeout) noexcept(false) { @@ -351,7 +358,7 @@ void TestCase::addTimeout(const anna::Millisecond &timeout) noexcept(false) { void TestCase::addSendDiameterXml2e(const anna::DataBlock &db, anna::diameter::comm::OriginHost *host, int stepNumber) noexcept(false) { assertInitialized(); - assertMessage(db, true /* to entity */); + a_key = assertMessage(db, true /* to entity */); if (stepNumber != -1) { const TestStep *stepReferred = getStep(stepNumber); @@ -376,7 +383,7 @@ void TestCase::addSendDiameterXml2e(const anna::DataBlock &db, anna::diameter::c void TestCase::addSendDiameterXml2c(const anna::DataBlock &db, anna::diameter::comm::OriginHost *host, int stepNumber) noexcept(false) { assertInitialized(); - assertMessage(db, false /* to client */); + a_key = assertMessage(db, false /* to client */); if (stepNumber != -1) { const TestStep *stepReferred = getStep(stepNumber);