866 lines
27 KiB
C++
Executable File
866 lines
27 KiB
C++
Executable File
/**
|
|
* Module tests for SVC Report Management
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Hanna E. Rathje, SLSE, 2015-09-10
|
|
*/
|
|
|
|
#include "rep_tests.h"
|
|
|
|
#include <nglapplication/nglcoreapplication.h>
|
|
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
|
#include <QTimer>
|
|
#include <QTest>
|
|
|
|
#include <ReportManagement/rep_dtc.h>
|
|
#include <ReportManagement/rep_ftc.h>
|
|
#include <LtsUtilsCore/dds_vector.h>
|
|
#include <ngldb/db_service_handler.h>
|
|
#include <ReportManagement/settings.h>
|
|
#include <nglsettings/nglsettings_settings.h>
|
|
|
|
// ------------------------------------------------------------------
|
|
namespace ReportManagement
|
|
{
|
|
RepTests::RepTests(QObject *parent)
|
|
: QObject(parent)
|
|
, m_exerciseId(0)
|
|
, m_testId(0)
|
|
, m_reportId(0)
|
|
, m_operatorId(100)
|
|
, m_bTestsSuccessful(true)
|
|
, m_logger(getLogger("Test"))
|
|
{
|
|
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
RepTests::~RepTests()
|
|
{}
|
|
|
|
// ------------------------------------------------------------------
|
|
bool RepTests::init(int domainId, int exerciseId, int testId, int reportId, int operatorId)
|
|
{
|
|
INFO_LOG(m_logger) << "init begin";
|
|
|
|
m_testId = testId;
|
|
m_exerciseId = exerciseId;
|
|
m_reportId = reportId;
|
|
m_operatorId = operatorId;
|
|
|
|
// initialize DDS
|
|
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, m_exerciseId));
|
|
if (!m_ddsConnector->init())
|
|
return false;
|
|
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
|
m_ddsConnector->initPublisherSubscriber();
|
|
|
|
// initialize database
|
|
m_dbHandler = std::make_shared<DbHandler>();
|
|
if(!m_dbHandler->init(m_exerciseId, Settings::settings()))
|
|
{
|
|
ERROR_LOG(m_logger) << "Initialisation dbHandler failed.";
|
|
return false;
|
|
}
|
|
DEBUG_LOG(m_logger) << "Initialisation dbHandler succesful.";
|
|
m_db = m_dbHandler->db();
|
|
|
|
DEBUG_LOG(m_logger) << "create dtc";
|
|
m_dtc = ReportManagement::Interface::Dtc::create(m_ddsConnector);
|
|
DEBUG_LOG(m_logger) << "create ftc";
|
|
m_ftc = ReportManagement::Interface::Ftc::create(m_ddsConnector);
|
|
DEBUG_LOG(m_logger) << "init ftc/dtc";
|
|
bool bRet = m_ftc->enableAll() && m_dtc->enableAll();
|
|
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
|
|
|
|
DEBUG_LOG(m_logger) << "Domain Id = " << domainId;
|
|
DEBUG_LOG(m_logger) << "Exercise Id = " << exerciseId;
|
|
DEBUG_LOG(m_logger) << "Test Id = " << testId;
|
|
DEBUG_LOG(m_logger) << "Report Id = " << reportId;
|
|
DEBUG_LOG(m_logger) << "Operator Id = " << operatorId;
|
|
|
|
//TODO: add connects
|
|
|
|
return bRet;
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void RepTests::startTest()
|
|
{
|
|
INFO_LOG(m_logger) << "startTest";
|
|
// create reports
|
|
if (m_testId == 11)
|
|
tryCreate(ReportManagement::ReportType::UnitPower);
|
|
else if (m_testId == 12)
|
|
tryCreate(ReportManagement::ReportType::ParticipantDistance);
|
|
else if (m_testId == 13)
|
|
tryCreate(ReportManagement::ReportType::MineArea);
|
|
else if (m_testId == 14)
|
|
tryCreate(ReportManagement::ReportType::Nbc);
|
|
else if (m_testId == 15)
|
|
tryCreate(ReportManagement::ReportType::Firings);
|
|
else if (m_testId == 16)
|
|
tryCreate(ReportManagement::ReportType::ChargeResupply);
|
|
else if (m_testId == 17)
|
|
tryCreate(ReportManagement::ReportType::ChargeAdministration);
|
|
else if (m_testId == 18)
|
|
tryCreate(ReportManagement::ReportType::VehicleRepair);
|
|
else if (m_testId == 19)
|
|
tryCreate(ReportManagement::ReportType::AirSupport);
|
|
else if (m_testId == 20)
|
|
tryCreate(ReportManagement::ReportType::BuildingDamage);
|
|
else if (m_testId == 21)
|
|
tryCreate(ReportManagement::ReportType::ExplosiveDevice);
|
|
else if (m_testId == 22)
|
|
tryCreate(ReportManagement::ReportType::Decontamination);
|
|
else if (m_testId == 23)
|
|
tryCreate(ReportManagement::ReportType::SanitationMaterial);
|
|
else if (m_testId == 24)
|
|
tryCreate(ReportManagement::ReportType::Treatment);
|
|
else if (m_testId == 25)
|
|
tryCreate(ReportManagement::ReportType::MedevacNineLiner);
|
|
else if (m_testId == 26)
|
|
tryCreate(ReportManagement::ReportType::TreatmentPriority);
|
|
else if (m_testId == 27)
|
|
tryCreate(ReportManagement::ReportType::TreatmentChain);
|
|
else if (m_testId == 28)
|
|
addTestDataTreatmentTimeline(); // add test data for treatment timeline
|
|
else if (m_testId == 29)
|
|
tryCreate(ReportManagement::ReportType::TreatmentTimeline, ReportManagement::VisualisationType::Table);
|
|
else if (m_testId == 30)
|
|
tryCreate(ReportManagement::ReportType::TreatmentTimeline, ReportManagement::VisualisationType::Line);
|
|
|
|
// modify reports
|
|
else if (m_testId == 2)
|
|
tryModify();
|
|
// remove
|
|
else if (m_testId == 3)
|
|
tryDelete();
|
|
// get report data
|
|
else if (m_testId == 4)
|
|
tryGetData();
|
|
// change status
|
|
else if (m_testId == 5)
|
|
tryChangeStatus();
|
|
else
|
|
{
|
|
ERROR_LOG(m_logger) << "Unknown test case!";
|
|
failExit();
|
|
}
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void RepTests::tryCreate(ReportType repType, VisualisationType visType)
|
|
{
|
|
INFO_LOG(m_logger) << "trying to send createRequest Report";
|
|
CreateModifyReportRequest request;
|
|
|
|
QString repName = QStringLiteral("Test Report - type ") + QString::number(repType.underlying());
|
|
request.name(repName.toStdString());
|
|
request.description("Test Report Description");
|
|
request.reportType(repType);
|
|
|
|
request.operatorId(m_operatorId);
|
|
request.fileStatus(ReportManagement::FileStatus::Valid);
|
|
request.lastModified(QDateTime::currentMSecsSinceEpoch());
|
|
|
|
// common request data
|
|
request.startTime(QDateTime(QDate::currentDate().addYears(-2), QTime(9, 30)).toMSecsSinceEpoch());
|
|
request.endTime(QDateTime(QDate::currentDate().addDays(1), QTime(16, 30)).toMSecsSinceEpoch());
|
|
if (repType != ReportType::Nbc) // && repType != ReportType::MineArea)
|
|
request.partyId(2);
|
|
|
|
// participant Ids
|
|
std::vector<qint32> vecPartIds;
|
|
vecPartIds.resize(9);
|
|
vecPartIds[0] = 5;
|
|
vecPartIds[1] = 6;
|
|
vecPartIds[2] = 7;
|
|
vecPartIds[3] = 8;
|
|
vecPartIds[4] = 9;
|
|
vecPartIds[5] = 12;
|
|
vecPartIds[6] = 13;
|
|
vecPartIds[7] = 14;
|
|
vecPartIds[8] = 15;
|
|
request.participantIds(vecPartIds);
|
|
|
|
// participant types
|
|
std::vector<qint32> vecPartTypes;
|
|
vecPartTypes.resize(2);
|
|
|
|
vecPartTypes[0] = 55;
|
|
vecPartTypes[1] = 74;
|
|
|
|
request.participantTypes(vecPartTypes);
|
|
|
|
switch (repType.underlying())
|
|
{
|
|
case ReportManagement::ReportType::UnitPower:
|
|
{
|
|
request.startTime(QDateTime(QDate::currentDate().addYears(-1), QTime(9, 30)).toMSecsSinceEpoch());
|
|
request.startTime(QDateTime(QDate::currentDate().addDays(-1), QTime(9, 30)).toMSecsSinceEpoch());
|
|
request.intervalTime(7200000); // 120 min
|
|
request.visualisationType(ReportManagement::VisualisationType::Line);
|
|
request.groupByParty(false);
|
|
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::ParticipantDistance:
|
|
{
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::MineArea:
|
|
{
|
|
request.mineAreaIds().resize(1);
|
|
request.mineAreaIds()[0] = 2;
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::Nbc:
|
|
{
|
|
request.nbcIds().resize(1);
|
|
request.nbcIds()[0] = 3;
|
|
|
|
request.chargeTypeIds().resize(1);
|
|
request.chargeTypeIds()[0] = 341;
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::Firings:
|
|
{
|
|
request.startTime(QDateTime(QDate::currentDate().addDays(-1), QTime(9, 30)).toMSecsSinceEpoch());
|
|
// request.intervalTime(1800000); // 30 min
|
|
|
|
request.intervalTime(0);
|
|
request.chargeTypeIds().resize(2);
|
|
request.chargeTypeIds()[0] = 38;
|
|
request.chargeTypeIds()[1] = 39;
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::AirSupport:
|
|
{
|
|
request.startTime(QDateTime(QDate::currentDate().addDays(-1), QTime(9, 30)).toMSecsSinceEpoch());
|
|
request.partyId(4);
|
|
|
|
vecPartIds.resize(3);
|
|
vecPartIds[0] = 52;
|
|
vecPartIds[1] = 53;
|
|
vecPartIds[2] = 54;
|
|
request.participantIds(vecPartIds);
|
|
|
|
vecPartTypes.resize(2);
|
|
|
|
vecPartTypes[0] = 57;
|
|
vecPartTypes[1] = 78;
|
|
|
|
request.participantTypes(vecPartTypes);
|
|
|
|
request.intervalTime(0);
|
|
request.chargeTypeIds().resize(4);
|
|
request.chargeTypeIds()[0] = 471;
|
|
request.chargeTypeIds()[1] = 472;
|
|
request.chargeTypeIds()[2] = 473;
|
|
request.chargeTypeIds()[3] = 474;
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::ExplosiveDevice:
|
|
{
|
|
request.startTime(QDateTime(QDate::currentDate().addDays(-1), QTime(9, 30)).toMSecsSinceEpoch());
|
|
request.partyId(3);
|
|
|
|
vecPartIds.resize(3);
|
|
vecPartIds[0] = 30;
|
|
vecPartIds[1] = 31;
|
|
vecPartIds[2] = 32;
|
|
request.participantIds(vecPartIds);
|
|
|
|
vecPartTypes.resize(2);
|
|
|
|
vecPartTypes[0] = 77;
|
|
vecPartTypes[1] = 78;
|
|
|
|
request.participantTypes(vecPartTypes);
|
|
|
|
request.intervalTime(0);
|
|
request.chargeTypeIds().resize(3);
|
|
request.chargeTypeIds()[0] = 48;
|
|
request.chargeTypeIds()[1] = 49;
|
|
request.chargeTypeIds()[2] = 70;
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::ChargeResupply:
|
|
{
|
|
request.chargeTypeIds().resize(2);
|
|
request.chargeTypeIds()[0] = 38;
|
|
request.chargeTypeIds()[1] = 39;
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::ChargeAdministration:
|
|
{
|
|
request.startTime(QDateTime(QDate::currentDate().addMonths(-1), QTime(9, 30)).toMSecsSinceEpoch());
|
|
request.chargeTypeIds().resize(2);
|
|
request.chargeTypeIds()[0] = 371;
|
|
request.chargeTypeIds()[1] = 372;
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::VehicleRepair:
|
|
{
|
|
// participant Ids
|
|
vecPartIds.clear();
|
|
vecPartIds.resize(3);
|
|
vecPartIds[0] = 30;
|
|
vecPartIds[1] = 31;
|
|
vecPartIds[2] = 32;
|
|
request.participantIds(vecPartIds);
|
|
|
|
// participant types
|
|
vecPartTypes.clear();
|
|
vecPartTypes.resize(2);
|
|
vecPartTypes[0] = 77;
|
|
vecPartTypes[1] = 78;
|
|
request.participantTypes(vecPartTypes);
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::Decontamination:
|
|
{
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::Treatment:
|
|
{
|
|
request.startTime() = 1594218400000;
|
|
request.endTime() = 1594219400000;
|
|
|
|
vecPartIds.clear();
|
|
vecPartIds.resize(3);
|
|
vecPartIds[0] = 5;
|
|
vecPartIds[1] = 6;
|
|
vecPartIds[2] = 7;
|
|
request.participantIds(vecPartIds);
|
|
|
|
vecPartTypes.clear();
|
|
vecPartTypes.resize(1);
|
|
vecPartTypes[0] = 55;
|
|
request.participantTypes(vecPartTypes);
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::TreatmentChain:
|
|
{
|
|
request.startTime() = 1594218400000;
|
|
request.endTime() = 1594219400000;
|
|
|
|
vecPartIds.clear();
|
|
vecPartIds.resize(3);
|
|
vecPartIds[0] = 5;
|
|
vecPartIds[1] = 6;
|
|
vecPartIds[2] = 7;
|
|
request.participantIds(vecPartIds);
|
|
|
|
vecPartTypes.clear();
|
|
vecPartTypes.resize(1);
|
|
vecPartTypes[0] = 55;
|
|
request.participantTypes(vecPartTypes);
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Bar);
|
|
request.groupByParty(false);
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::TreatmentTimeline:
|
|
{
|
|
request.startTime() = 1646118000000;
|
|
request.endTime() = 1646118010000;
|
|
|
|
vecPartIds.clear();
|
|
vecPartIds.resize(2);
|
|
vecPartIds[0] = 5;
|
|
vecPartIds[1] = 6;
|
|
request.participantIds(vecPartIds);
|
|
|
|
vecPartTypes.clear();
|
|
vecPartTypes.resize(1);
|
|
vecPartTypes[0] = 55;
|
|
request.participantTypes(vecPartTypes);
|
|
|
|
request.visualisationType(visType);
|
|
request.groupByParty(true);
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::TreatmentPriority:
|
|
{
|
|
request.startTime() = 1594218400000;
|
|
request.endTime() = 1594219400000;
|
|
|
|
vecPartIds.clear();
|
|
vecPartIds.resize(3);
|
|
vecPartIds[0] = 5;
|
|
vecPartIds[1] = 6;
|
|
vecPartIds[2] = 7;
|
|
request.participantIds(vecPartIds);
|
|
|
|
vecPartTypes.clear();
|
|
vecPartTypes.resize(1);
|
|
vecPartTypes[0] = 55;
|
|
request.participantTypes(vecPartTypes);
|
|
|
|
request.cornerBottomLeft().lon(0.09);
|
|
request.cornerBottomLeft().lat(0.245);
|
|
request.width(40000);
|
|
request.height(100000);
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
break;
|
|
}
|
|
|
|
case ReportManagement::ReportType::BuildingDamage:
|
|
{
|
|
request.startTime(QDateTime(QDate::currentDate().addMonths(-1), QTime(9, 30)).toMSecsSinceEpoch());
|
|
request.chargeTypeIds().resize(1);
|
|
request.chargeTypeIds()[0] = 301; // building Id
|
|
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
|
|
break;
|
|
}
|
|
case ReportManagement::ReportType::SanitationMaterial:
|
|
{
|
|
|
|
// request.startTime(QDateTime(QDate::currentDate().addMonths(-1), QTime(9, 30)).toMSecsSinceEpoch());
|
|
int noMaterials = 27;
|
|
request.chargeTypeIds().resize(noMaterials);
|
|
for (int i = 0; i < noMaterials; i++)
|
|
request.chargeTypeIds()[i] = i+1;
|
|
// request.chargeTypeIds().resize(1);
|
|
// request.chargeTypeIds()[0] = 8;
|
|
request.startTime(1650455273000);
|
|
request.endTime(1651232873000);
|
|
|
|
vecPartIds.clear();
|
|
vecPartTypes.clear();
|
|
request.partyId(2);
|
|
request.participantIds(vecPartIds);
|
|
request.participantTypes(vecPartTypes);
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
break;
|
|
}
|
|
|
|
case ReportManagement::ReportType::MedevacNineLiner:
|
|
{
|
|
request.cornerBottomLeft().lon(0.09);
|
|
request.cornerBottomLeft().lat(0.245);
|
|
request.width(40000);
|
|
request.height(100000);
|
|
request.startTime(QDateTime(QDate::currentDate().addMonths(-1), QTime(9, 30)).toMSecsSinceEpoch());
|
|
request.visualisationType(ReportManagement::VisualisationType::Table);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
ERROR_LOG(m_logger) << "Unknown report type!";
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!m_ftc->createModifyReportRequest(request, this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting create data";
|
|
failExit();
|
|
}
|
|
QTest::qWait(2000);
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void RepTests::tryModify()
|
|
{
|
|
DEBUG_LOG(m_logger) << "trying to send modify request for report Id = " << m_reportId;
|
|
|
|
m_dtc->waitForHistoricalDataReportInfo(1000);
|
|
ReportInfo rep = m_dtc->reportInfo(m_reportId);
|
|
|
|
CreateModifyReportRequest request;
|
|
|
|
request.id(m_reportId);
|
|
request.name("Test Report Updated");
|
|
request.description("Updated Description");
|
|
|
|
request.reportType(rep.reportType());
|
|
request.description(rep.description());
|
|
request.partyId(rep.partyId());
|
|
request.startTime(rep.startTime());
|
|
request.endTime(rep.endTime());
|
|
request.visualisationType(rep.visualisationType());
|
|
request.intervalTime(rep.intervalTime());
|
|
request.chargeTypeIds(rep.chargeTypeIds());
|
|
request.groupByParty(rep.groupByParty());
|
|
request.mineAreaIds(rep.mineAreaIds());
|
|
request.nbcIds(rep.nbcIds());
|
|
request.participantIds(rep.participantIds());
|
|
request.participantTypes(rep.participantTypes());
|
|
request.unitIds(rep.unitIds());
|
|
|
|
request.operatorId(m_operatorId);
|
|
request.fileStatus(ReportManagement::FileStatus::Valid);
|
|
request.lastModified(QDateTime::currentMSecsSinceEpoch());
|
|
|
|
DEBUG_LOG(m_logger) << "Start modify";
|
|
DEBUG_LOG(m_logger) << "Report type = " << rep.reportType();
|
|
|
|
if (!m_ftc->createModifyReportRequest(request, this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting modify data";
|
|
failExit();
|
|
}
|
|
QTest::qWait(1000);
|
|
DEBUG_LOG(m_logger) << "AFTER modify";
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void RepTests::tryGetData()
|
|
{
|
|
DEBUG_LOG(m_logger) << "trying to send get data request for report Id = " << m_reportId;
|
|
GetReportDataRequest request;
|
|
|
|
request.reportId(m_reportId);
|
|
request.reportType(ReportManagement::ReportType::ChargeAdministration);
|
|
|
|
if (!m_ftc->getReportDataRequest(request, this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting modify data";
|
|
failExit();
|
|
}
|
|
QTest::qWait(1000);
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
void RepTests::tryChangeStatus()
|
|
{
|
|
DEBUG_LOG(m_logger) << "trying to send change status request for report Id = " << m_reportId;
|
|
ReportChangeStatusRequest request;
|
|
|
|
request.id(m_reportId);
|
|
request.operatorId(m_operatorId);
|
|
request.fileStatus(ReportManagement::FileStatus::Deleted);
|
|
request.lastModified(QDateTime::currentMSecsSinceEpoch());
|
|
|
|
if (!m_ftc->reportChangeStatusRequest(request, this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting change status";
|
|
failExit();
|
|
}
|
|
QTest::qWait(1000);
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void RepTests::tryDelete()
|
|
{
|
|
INFO_LOG(m_logger) << "trying to send delete request for report Id = " << m_reportId;
|
|
if (!m_ftc->removeReportRequest(RemoveReportRequest(m_reportId), this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting delete data";
|
|
failExit();
|
|
}
|
|
QTest::qWait(1000);
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void RepTests::onCreateModifyReportReply(const CreateModifyReportReply &replyObject)
|
|
{
|
|
DEBUG_LOG(m_logger) << "END (onCreateModifyReportReply)";
|
|
if (replyObject.errorString().size() > 0)
|
|
{
|
|
ERROR_LOG(m_logger) << "Got onCreateModifyReportReply error: " << replyObject.errorString();
|
|
failExit();
|
|
return;
|
|
}
|
|
INFO_LOG(m_logger) << "Got createModifyReply with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.errorString();
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void RepTests::onRemoveReportReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
DEBUG_LOG(m_logger) << "END (onRemoveReportReply)";
|
|
if (replyObject.error())
|
|
{
|
|
ERROR_LOG(m_logger) << "Got onRemoveReportReply error: " << replyObject();
|
|
failExit();
|
|
return;
|
|
}
|
|
INFO_LOG(m_logger) << "Got removeReply with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.translated();
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void RepTests::onGetReportDataReply(const GetReportDataReply &replyObject)
|
|
{
|
|
DEBUG_LOG(m_logger) << "END (onGetReportDataReply)";
|
|
if (replyObject.errorString().size() > 0)
|
|
{
|
|
ERROR_LOG(m_logger) << "Got onGetReportDataReply error: " << replyObject.errorString();
|
|
failExit();
|
|
return;
|
|
}
|
|
INFO_LOG(m_logger) << "Got createReply with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.errorString();
|
|
|
|
QByteArray reportData = LtsUtils::toQByteArray(replyObject.reportData());
|
|
|
|
DEBUG_LOG(m_logger) << "Size reportData: " << reportData.size();
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void RepTests::onReportChangeStatusReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
DEBUG_LOG(m_logger) << "END (onReportChangeStatusReply)";
|
|
if (replyObject.error())
|
|
{
|
|
ERROR_LOG(m_logger) << "Got onReportChangeStatusReply error: " << replyObject();
|
|
failExit();
|
|
return;
|
|
}
|
|
INFO_LOG(m_logger) << "Got changeStatusReply with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.translated();
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
void RepTests::addTestDataTreatmentTimeline()
|
|
{
|
|
// Report Treatment Timeline
|
|
ERROR_LOG(m_logger) << "START addTestDataTreatmentTimeline" ;
|
|
|
|
ReportManagement::Database::RepTreatmentTimelineData resData;
|
|
resData.id = 10;
|
|
resData.participantId = 5;
|
|
resData.participantTypeId = 55;
|
|
resData.partyId = 2;
|
|
resData.vulnerability = 460942;
|
|
resData.vulnerabilityState = 1;
|
|
|
|
resData.id++;
|
|
resData.eventTypeId = ReportManagement::EventType::VBGChanged;
|
|
resData.eventTime = 1646118000000;
|
|
resData.vitality = 90;
|
|
resData.properties = QString();
|
|
|
|
if (!m_db->insert(resData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while inserting Event for participantId: " << resData.participantId;
|
|
failExit();
|
|
}
|
|
|
|
resData.id++;
|
|
resData.eventTypeId = ReportManagement::EventType::VitalityChanged;
|
|
resData.eventTime = 1646118001000;
|
|
resData.vitality = 60;
|
|
resData.properties = QString();
|
|
if (!m_db->insert(resData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while inserting Event for participantId: " << resData.participantId;
|
|
failExit();
|
|
}
|
|
|
|
resData.id++;
|
|
resData.eventTypeId = ReportManagement::EventType::NineLinerSet;
|
|
resData.eventTime = 1646118002000;
|
|
resData.vitality = 60;
|
|
resData.vulnerability = 460942;
|
|
resData.vulnerabilityState = 1;
|
|
resData.properties = QString();
|
|
if (!m_db->insert(resData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while inserting Event for participantId: " << resData.participantId;
|
|
failExit();
|
|
}
|
|
|
|
resData.id++;
|
|
resData.eventTypeId = ReportManagement::EventType::TransportRequested;
|
|
resData.eventTime = 1646118005000;
|
|
resData.vitality = 70;
|
|
resData.properties = QString();
|
|
if (!m_db->insert(resData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while inserting Event for participantId: " << resData.participantId;
|
|
failExit();
|
|
}
|
|
|
|
resData.id++;
|
|
resData.eventTypeId = ReportManagement::EventType::TransportInitiated;
|
|
resData.eventTime = 1646118006000;
|
|
resData.vitality = 70;
|
|
resData.properties = QString();
|
|
if (!m_db->insert(resData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while inserting Event for participantId: " << resData.participantId;
|
|
failExit();
|
|
}
|
|
|
|
resData.id++;
|
|
resData.eventTypeId = ReportManagement::EventType::EnterFunctionalArea;
|
|
resData.eventTime = 1646118007000;
|
|
resData.vitality = 70;
|
|
std::string json = R"({"area_id": 1, "area_name": "test area"})";
|
|
resData.properties = QString::fromStdString(json);
|
|
if (!m_db->insert(resData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while inserting Event for participantId: " << resData.participantId;
|
|
failExit();
|
|
}
|
|
|
|
resData.id++;
|
|
resData.eventTypeId = ReportManagement::EventType::Treatment;
|
|
resData.eventTime = 1646118008000;
|
|
resData.vitality = 70;
|
|
resData.properties = QString();
|
|
if (!m_db->insert(resData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while inserting Event for participantId: " << resData.participantId;
|
|
failExit();
|
|
}
|
|
|
|
resData.id++;
|
|
resData.eventTypeId = ReportManagement::EventType::Treatment;
|
|
resData.eventTime = 1646118009000;
|
|
resData.vitality = 100;
|
|
resData.properties = QString();
|
|
if (!m_db->insert(resData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while inserting Event for participantId: " << resData.participantId;
|
|
failExit();
|
|
}
|
|
|
|
resData.id++;
|
|
resData.participantId = 6;
|
|
resData.eventTypeId = ReportManagement::EventType::VBGChanged;
|
|
resData.eventTime = 1646118008000;
|
|
resData.vitality = 100;
|
|
resData.vulnerability = 460942;
|
|
resData.vulnerabilityState = 1;
|
|
resData.properties = QString();
|
|
if (!m_db->insert(resData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while inserting Event for participantId: " << resData.participantId;
|
|
failExit();
|
|
}
|
|
|
|
resData.id++;
|
|
resData.eventTypeId = ReportManagement::EventType::SetInjury;
|
|
resData.eventTime = 1646118009000;
|
|
resData.vitality = 70;
|
|
resData.properties = QString::fromStdString(json);
|
|
if (!m_db->insert(resData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while inserting Event for participantId: " << resData.participantId;
|
|
failExit();
|
|
}
|
|
|
|
resData.id++;
|
|
resData.eventTypeId = ReportManagement::EventType::EnterFunctionalArea;
|
|
resData.eventTime = 1646118009000;
|
|
resData.vitality = 100;
|
|
resData.properties = QString::fromStdString(json);
|
|
if (!m_db->insert(resData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error while inserting Event for participantId: " << resData.participantId;
|
|
failExit();
|
|
}
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------
|
|
void RepTests::failExit()
|
|
{
|
|
ERROR_LOG(m_logger) << "FAIL EXIT !";
|
|
m_bTestsSuccessful = false;
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
}
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
|
{
|
|
public:
|
|
CmdLineParser()
|
|
: LtsCommandLineParser()
|
|
{
|
|
addOption({ QStringList() << QLatin1String("t") << QLatin1String("testId")
|
|
, QLatin1String("TestId.")
|
|
, QLatin1String("Default: 0 (all tests)")
|
|
, QLatin1String("0")
|
|
});
|
|
addOption({ QStringList() << QLatin1String("r") << QLatin1String("reportId")
|
|
, QLatin1String("ReportId.")
|
|
, QLatin1String("Default: -1 (reportId will be set in tests)")
|
|
, QLatin1String("0")
|
|
});
|
|
addOption({ QStringList() << QLatin1String("o") << QLatin1String("operatorId")
|
|
, QLatin1String("OperatorId.")
|
|
, QLatin1String("Default: 100")
|
|
, QLatin1String("10")
|
|
});
|
|
}
|
|
|
|
int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : -1; }
|
|
int reportId() const { return isSet(QLatin1String("r")) ? value(QLatin1String("r")).toInt() : -1; }
|
|
int operatorId() const { return isSet(QLatin1String("o")) ? value(QLatin1String("o")).toInt() : 100; }
|
|
|
|
};
|
|
|
|
// ------------------------------------------------------------------
|
|
int main(int argc, char **argv)
|
|
{
|
|
NGLCoreApplication app(argc, argv);
|
|
app.createLogger("REP", 0);
|
|
|
|
CmdLineParser options;
|
|
if (!options.init())
|
|
return -1;
|
|
|
|
std::unique_ptr<ReportManagement::RepTests> RepTests(new ReportManagement::RepTests);
|
|
|
|
if (!RepTests->init(options.domainId(), options.exerciseId(), options.testId(), options.reportId(), options.operatorId()))
|
|
return -1;
|
|
|
|
QTimer::singleShot(0, RepTests.get(), &ReportManagement::RepTests::startTest);
|
|
|
|
STARTUP_LOG(app.baseLogger());
|
|
|
|
app.exec();
|
|
|
|
int iRet = RepTests->testsSuccessful() ? 0 : 1;
|
|
fprintf(stderr, "\n%d\n\n", iRet);
|
|
|
|
INFO_LOG(app.baseLogger()) << "** TEST result = " << iRet;
|
|
|
|
SHUTDOWN_LOG(app.baseLogger());
|
|
|
|
return iRet;
|
|
}
|
|
|