726 lines
22 KiB
C++
Executable File
726 lines
22 KiB
C++
Executable File
/**
|
|
* MRK Function Topic test executable
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by hjl, SLSE, 2016-04-18
|
|
*/
|
|
#include "mrk_tests.h"
|
|
|
|
#include <nglapplication/nglcoreapplication.h>
|
|
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
|
#include <QTimer>
|
|
#include <QDateTime>
|
|
#include <QString>
|
|
#include <QVector>
|
|
|
|
#include <MarkerManagement/mrk_ftc.h>
|
|
#include <MarkerManagement/mrk_dtc.h>
|
|
|
|
using namespace MarkerManagement;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
MrkTests::MrkTests(QObject *parent)
|
|
: QObject(parent)
|
|
, m_exerciseId(0)
|
|
, m_testId(0)
|
|
, m_markerId(0)
|
|
, m_eTestStep(eUnknown)
|
|
, m_bTestsSuccessful(true)
|
|
, m_logger(getLogger("MrkTests"))
|
|
{
|
|
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
|
|
} // end of ctor()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
MrkTests::~MrkTests()
|
|
{
|
|
} // end of dtor()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool MrkTests::init(int domainId, int exerciseId, int testId, int markerId, int snapshotId)
|
|
{
|
|
INFO_LOG(m_logger) << "MrkTests::init() "
|
|
<< " domainId:" << domainId
|
|
<< " exerciseId:" << exerciseId
|
|
<< " testId: " << testId
|
|
<< " markerId: " << markerId
|
|
;
|
|
|
|
m_testId = testId;
|
|
m_exerciseId = exerciseId;
|
|
m_markerId = markerId;
|
|
m_snapshotId = snapshotId;
|
|
|
|
// initialize DDS
|
|
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId));
|
|
if (!m_ddsConnector->init())
|
|
return false;
|
|
m_ddsConnector->initPublisherSubscriber();
|
|
|
|
// Access to FTC
|
|
DEBUG_LOG(m_logger) << "create ftc";
|
|
m_ftc = MarkerManagement::Interface::Ftc::create(m_ddsConnector);
|
|
DEBUG_LOG(m_logger) << "init ftc";
|
|
bool bRet = m_ftc->enableAll();
|
|
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
|
|
|
|
// Access to DTC
|
|
DEBUG_LOG(m_logger) << "create dtc";
|
|
m_dtc = MarkerManagement::Interface::Dtc::create(m_ddsConnector);
|
|
DEBUG_LOG(m_logger) << "init dtc";
|
|
bRet = m_dtc->enableAll();
|
|
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
|
|
|
|
return bRet;
|
|
} // end of init()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::startTest()
|
|
{
|
|
INFO_LOG(m_logger) << "startTest() exerciseId:" << m_exerciseId
|
|
<< " testId:" << m_testId
|
|
<< " markerId:" << m_markerId
|
|
;
|
|
|
|
connect(m_dtc.get(), &Interface::Dtc::markerChanged,
|
|
this, &MrkTests::onReceiveMarkerChanged);
|
|
|
|
if (m_testId <= 1)
|
|
QTimer::singleShot(0, this, &MrkTests::tryCreate);
|
|
else if (m_testId == 2)
|
|
QTimer::singleShot(0, this, &MrkTests::tryModify);
|
|
else if (m_testId == 3)
|
|
QTimer::singleShot(0, this, &MrkTests::tryRemove);
|
|
else if (m_testId == 4)
|
|
QTimer::singleShot(0, this, &MrkTests::tryCreateSnapshot);
|
|
else if (m_testId == 5)
|
|
QTimer::singleShot(0, this, &MrkTests::tryModifySnapshot);
|
|
else if (m_testId == 6)
|
|
QTimer::singleShot(0, this, &MrkTests::tryRemoveSnapshot);
|
|
|
|
else if (m_testId == 10)
|
|
QTimer::singleShot(0, this, &MrkTests::tryGetAllMarkers);
|
|
else if (m_testId == 11)
|
|
QTimer::singleShot(0, this, &MrkTests::tryGetMarker);
|
|
|
|
} // end of startTest()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::tryCreate()
|
|
{
|
|
m_eTestStep = eCreate;
|
|
MarkerModifyRequest data;
|
|
getMarkerCreateRequestData(data);
|
|
|
|
INFO_LOG(m_logger) << "trying to send MarkerCreateRequest";
|
|
if (!m_ftc->markerModifyRequest(data, this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting create data";
|
|
failExit();
|
|
}
|
|
} // end of tryCreate()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::tryModify()
|
|
{
|
|
m_eTestStep = eModify;
|
|
MarkerModifyRequest data;
|
|
getMarkerModifyRequestData(data);
|
|
|
|
INFO_LOG(m_logger) << "trying to send MarkerModifyRequest for markerId:" << data.id();
|
|
if (!m_ftc->markerModifyRequest(data, this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting modify data for markerId:" << data.id();
|
|
failExit();
|
|
}
|
|
} // end of tryModify()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::tryRemove()
|
|
{
|
|
m_eTestStep = eRemove;
|
|
MarkerRemoveRequest data;
|
|
|
|
data.id(m_markerId);
|
|
|
|
INFO_LOG(m_logger) << "trying to send remove request for markerId:" << data.id();
|
|
if (!m_ftc->markerRemoveRequest(data, this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting remove data for markerId:" << data.id();
|
|
failExit();
|
|
}
|
|
} // end of tryRemove()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::tryGetAllMarkers()
|
|
{
|
|
m_eTestStep = eGetAllMarkers;
|
|
DEBUG_LOG(m_logger) << "trying to get all markers";
|
|
|
|
m_dtc->waitForHistoricalDataMarker();
|
|
const QMap<qint32, MarkerManagement::Marker> map = m_dtc->markers();
|
|
if (map.isEmpty())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting all marker data";
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
return;
|
|
}
|
|
|
|
INFO_LOG(m_logger) << "Amout of existing markers:" << map.size();
|
|
m_markerId = map.firstKey();
|
|
for (auto it = map.begin(); it != map.end(); ++it)
|
|
{
|
|
INFO_LOG(m_logger) << "Mrk(" << it.key() << ") :"
|
|
<< " note:" << it.value().note()
|
|
<< " operatorId:" << it.value().operatorId()
|
|
<< " timeStamp:" << it.value().timeStamp()
|
|
<< " timeStampOffset:" << it.value().timeStampOffset()
|
|
<< " description count:" << it.value().descriptions().size();
|
|
}
|
|
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
|
|
} // end of tryGetAllMarkers()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::tryGetMarker()
|
|
{
|
|
DEBUG_LOG(m_logger) << "trying to get marker with id:" << m_markerId;
|
|
|
|
if (m_testId > 1)
|
|
m_eTestStep = eGetMarker;
|
|
|
|
if (m_markerId <= 0)
|
|
{
|
|
ERROR_LOG(m_logger) << "invalid markerId - test aborted.";
|
|
failExit();
|
|
}
|
|
|
|
m_dtc->waitForHistoricalDataMarker();
|
|
MarkerManagement::Marker data = m_dtc->marker(m_markerId);
|
|
|
|
if (data.id() <= 0)
|
|
{
|
|
ERROR_LOG(m_logger) << "Error receiving data for markerId " << m_markerId << " returnVal:" << data.id();
|
|
failExit();
|
|
}
|
|
else
|
|
{
|
|
INFO_LOG(m_logger) << "Mrk(" << data.id() << ") :"
|
|
<< " note:" << data.note()
|
|
<< " operatorId:" << data.operatorId()
|
|
<< " timeStamp:" << data.timeStamp()
|
|
<< " timeStampOffset:" << data.timeStampOffset()
|
|
;
|
|
}
|
|
|
|
if (m_testId == 0)
|
|
{
|
|
if (m_eTestStep == eCreate)
|
|
{
|
|
if (! onCompareCreatedData(data))
|
|
{
|
|
ERROR_LOG(m_logger) << "Compare created data failed!";
|
|
failExit();
|
|
}
|
|
else
|
|
{
|
|
QTimer::singleShot(0, this, &MrkTests::tryModify);
|
|
return;
|
|
}
|
|
}
|
|
else if (m_eTestStep == eModify)
|
|
{
|
|
if (! onCompareModifiedData(data))
|
|
{
|
|
ERROR_LOG(m_logger) << "Compare modified data failed!";
|
|
failExit();
|
|
}
|
|
else
|
|
{
|
|
QTimer::singleShot(0, this, &MrkTests::tryRemove);
|
|
return;
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
|
|
} // end of tryGetMarker()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::tryCreateSnapshot()
|
|
{
|
|
m_eTestStep = eCreate;
|
|
Snapshot data;
|
|
|
|
data.id(0); // create
|
|
data.name("Snapshot 1");
|
|
data.description("Dies ist ein Test");
|
|
data.mapSettings("78000 92000 xxxx");
|
|
data.operatorId(100);
|
|
data.timeStamp(QDateTime::currentMSecsSinceEpoch());
|
|
data.planOverlay("Plan Overlay");
|
|
|
|
INFO_LOG(m_logger) << "trying to send SnapshotCreateRequest";
|
|
if (!m_ftc->snapshotModifyRequest(data, this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting create data";
|
|
failExit();
|
|
}
|
|
} // end of tryCreateSnapshot()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::tryModifySnapshot()
|
|
{
|
|
m_eTestStep = eModify;
|
|
Snapshot data;
|
|
|
|
data.id(m_snapshotId);
|
|
data.name("Snapshot modify");
|
|
data.description("Dies ist ein Test modify");
|
|
data.planOverlay("Plan Overlay updated");
|
|
|
|
INFO_LOG(m_logger) << "trying to send SnapshotModifyRequest for snapshotId:" << data.id();
|
|
if (!m_ftc->snapshotModifyRequest(data, this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting modify data for snapshotId:" << data.id();
|
|
failExit();
|
|
}
|
|
} // end of tryModifySnapshot()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::tryRemoveSnapshot()
|
|
{
|
|
m_eTestStep = eRemove;
|
|
SnapshotRemoveRequest data;
|
|
|
|
data.id(m_snapshotId);
|
|
|
|
INFO_LOG(m_logger) << "trying to send remove request for snapshotId:" << data.id();
|
|
if (!m_ftc->snapshotRemoveRequest(data, this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting remove data for snapshotId:" << data.id();
|
|
failExit();
|
|
}
|
|
} // end of tryRemoveSnapshot()
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::onMarkerCreateReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
INFO_LOG(m_logger) << "Got createReply with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.translated();
|
|
|
|
m_markerId = replyObject.id();
|
|
|
|
if (replyObject.error())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting create data";
|
|
failExit();
|
|
return;
|
|
}
|
|
else
|
|
DEBUG_LOG(m_logger) << "Requesting create data ok. Got new id:" << replyObject.id() << " ... ok.";
|
|
|
|
if (m_testId == 0)
|
|
// QTimer::singleShot(0, this, &MrkTests::tryModify()));
|
|
QTimer::singleShot(0, this, &MrkTests::tryGetMarker);
|
|
else
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
|
|
} // end of onMarkerCreateReply()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::onMarkerModifyReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
if (m_eTestStep == TestStep::eCreate)
|
|
return onMarkerCreateReply(replyObject);
|
|
|
|
INFO_LOG(m_logger) << "Got modifyRequest with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.translated();
|
|
|
|
if (replyObject.error())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting modify data for id:" << replyObject.id();
|
|
failExit();
|
|
return;
|
|
}
|
|
else
|
|
DEBUG_LOG(m_logger) << "Requesting modify data for id:" << replyObject.id() << " ... ok.";
|
|
|
|
if (m_testId == 0)
|
|
// QTimer::singleShot(0, this, &MrkTests::tryDelete()));
|
|
QTimer::singleShot(0, this, &MrkTests::tryGetMarker);
|
|
else
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
|
|
} // end of onMarkerModifyReply()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::onMarkerRemoveReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
INFO_LOG(m_logger) << "Got removeReply with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.translated();
|
|
|
|
if (replyObject.error())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting remove data for markerId:" << replyObject.id();
|
|
failExit();
|
|
return;
|
|
}
|
|
else
|
|
DEBUG_LOG(m_logger) << "Requesting remove data for markerId:" << replyObject.id() << " ... ok.";
|
|
|
|
if (m_testId == 0)
|
|
{
|
|
QTimer::singleShot(0, this, &MrkTests::tryCreateSnapshot);
|
|
// ansonsten verheriger Ausstieg mit Errorlog.
|
|
}
|
|
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
|
|
} // end of onMarkerRemoveReply()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::onSnapshotCreateReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
INFO_LOG(m_logger) << "Got createReply with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.translated();
|
|
|
|
m_snapshotId = replyObject.id();
|
|
|
|
if (replyObject.error())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting create data";
|
|
failExit();
|
|
return;
|
|
}
|
|
else
|
|
DEBUG_LOG(m_logger) << "Requesting create data ok. Got new id:" << replyObject.id() << " ... ok.";
|
|
|
|
if (m_testId == 0)
|
|
QTimer::singleShot(0, this, &MrkTests::tryModifySnapshot);
|
|
else
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
|
|
} // end of onSnapshotCreateReply()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::onSnapshotModifyReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
if (m_eTestStep == TestStep::eCreate)
|
|
return onSnapshotCreateReply(replyObject);
|
|
|
|
INFO_LOG(m_logger) << "Got modifyRequest with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.translated();
|
|
|
|
if (replyObject.error())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting modify data for id:" << replyObject.id();
|
|
failExit();
|
|
return;
|
|
}
|
|
else
|
|
DEBUG_LOG(m_logger) << "Requesting modify data for id:" << replyObject.id() << " ... ok.";
|
|
|
|
if (m_testId == 0)
|
|
QTimer::singleShot(0, this, &MrkTests::tryRemoveSnapshot);
|
|
else
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
|
|
} // end of onSnapshotModifyReply()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::onSnapshotRemoveReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
INFO_LOG(m_logger) << "Got removeReply with id " << replyObject.id()
|
|
<< " and errorString " << replyObject.translated();
|
|
|
|
if (replyObject.error())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting remove data for markerId:" << replyObject.id();
|
|
failExit();
|
|
return;
|
|
}
|
|
else
|
|
DEBUG_LOG(m_logger) << "Requesting remove data for markerId:" << replyObject.id() << " ... ok.";
|
|
|
|
if (m_testId == 0)
|
|
{
|
|
INFO_LOG(m_logger) << "***** FTC/TDC test successfully finished. (used snapshotId:" << replyObject.id() << ") *****";
|
|
// ansonsten verheriger Ausstieg mit Errorlog.
|
|
}
|
|
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
|
|
} // end of onSnapshotRemoveReply()
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::onReceiveMarkerChanged(const Marker &data, DataModification modType)
|
|
{
|
|
// INFO_LOG(m_logger) << "onReceiveMarkerChanged() markerId:" << data.id()
|
|
// << " modificationType: = " << (int)modType<< " received";
|
|
|
|
switch (modType)
|
|
{
|
|
case DataModification::eAdded:
|
|
INFO_LOG(m_logger) << "*** Marker added received. markerId:" << data.id();
|
|
break;
|
|
|
|
case DataModification::eModified:
|
|
INFO_LOG(m_logger) << "*** Marker modified received. markerId:" << data.id();
|
|
break;
|
|
|
|
case DataModification::eRemoved:
|
|
INFO_LOG(m_logger) << "*** Marker removed received. markerId:" << data.id();
|
|
break;
|
|
}
|
|
|
|
} // end of onReceiveMarkerChanged()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::getMarkerCreateRequestData(MarkerModifyRequest &data)
|
|
{
|
|
time_t currentTime = time(nullptr);
|
|
if (m_testId == 0)
|
|
currentTime = currentTime / 10;
|
|
|
|
data.note("TestMarkerCreate");
|
|
data.operatorId(100);
|
|
data.timeStamp(currentTime);
|
|
data.timeStampOffset(33000);
|
|
|
|
getMarkerDescriptionCreateRequestData(data);
|
|
|
|
} // end of getMarkerCreateRequestData()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::getMarkerDescriptionCreateRequestData(MarkerModifyRequest &data)
|
|
{
|
|
// Info: FK fuer markerId wird in object_marker gesetzt.
|
|
data.descriptions().resize(3);
|
|
data.descriptions()[0].markerType(MarkerManagement::MarkerType::Audio);
|
|
data.descriptions()[0].content("Audio07, Audio08*, Audio09");
|
|
|
|
data.descriptions()[1].markerType(MarkerManagement::MarkerType::Video);
|
|
data.descriptions()[1].content("cam07, cam08, cam09*");
|
|
|
|
data.descriptions()[2].markerType(MarkerManagement::MarkerType::Video);
|
|
data.descriptions()[2].content("cam06, cam07, cam08, cam09*");
|
|
} // end of getMarkerDescriptionCreateRequestData()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::getMarkerModifyRequestData(MarkerModifyRequest &data)
|
|
{
|
|
time_t currentTime = time(nullptr);
|
|
if (m_testId == 0)
|
|
currentTime = currentTime / 10;
|
|
|
|
data.id(m_markerId);
|
|
data.note("TestMarkerModify");
|
|
data.operatorId(100);
|
|
data.timeStamp(currentTime * 1000);
|
|
data.timeStampOffset(77 * 1000);
|
|
|
|
getMarkerDescriptionCreateRequestData(data);
|
|
for (auto &desc : data.descriptions())
|
|
desc.content(std::string("+++MOD+++") + desc.content());
|
|
|
|
} // end of getMarkerModifyRequestData()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool MrkTests::onCompareCreatedData(Marker &data)
|
|
{
|
|
DEBUG_LOG(m_logger) << "start onCompareCreatedData() for id :" << data.id();
|
|
|
|
// Vergleicht die zurueckgelesen Datan mit den statischen create Daten
|
|
|
|
MarkerModifyRequest createData;
|
|
|
|
getMarkerCreateRequestData(createData);
|
|
|
|
if (createData.note() != data.note())
|
|
return false;
|
|
|
|
if (createData.operatorId() != data.operatorId())
|
|
return false;
|
|
|
|
if (createData.timeStamp() != data.timeStamp())
|
|
return false;
|
|
|
|
if (createData.timeStampOffset() != data.timeStampOffset())
|
|
return false;
|
|
|
|
// Descriptions vergleichen
|
|
|
|
if (createData.descriptions().size() != data.descriptions().size())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error onCompareCreatedData() different number of description data.";
|
|
failExit();
|
|
return false;
|
|
}
|
|
|
|
int foundCount = 0;
|
|
for (const auto &expected : createData.descriptions())
|
|
{
|
|
for (const auto &got : data.descriptions())
|
|
{
|
|
// we've got one description per type
|
|
if (got.markerType() != expected.markerType())
|
|
continue;
|
|
++foundCount;
|
|
|
|
if (got.content() != expected.content())
|
|
{
|
|
ERROR_LOG(m_logger) << "Content for description does not match: "
|
|
<< got.content() << " - "
|
|
<< expected.content();
|
|
failExit();
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
if (foundCount != 3)
|
|
{
|
|
ERROR_LOG(m_logger) << "Did not found all three expected descriptions";
|
|
failExit();
|
|
return false;
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << "successfull finished onCompareCreatedData() for id :" << data.id();
|
|
|
|
return true;
|
|
} // end of onCompareCreatedData()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool MrkTests::onCompareModifiedData(Marker &data)
|
|
{
|
|
DEBUG_LOG(m_logger) << "start onCompareModifiedData() for id :" << data.id();
|
|
|
|
MarkerModifyRequest modifyData;
|
|
|
|
getMarkerModifyRequestData(modifyData);
|
|
|
|
if (modifyData.id() != data.id())
|
|
return false;
|
|
|
|
if (modifyData.note() != data.note())
|
|
return false;
|
|
|
|
if (modifyData.operatorId() != data.operatorId())
|
|
return false;
|
|
|
|
if (modifyData.timeStamp() != data.timeStamp())
|
|
return false;
|
|
|
|
if (modifyData.timeStampOffset() != data.timeStampOffset())
|
|
return false;
|
|
|
|
// Alle Descriptions zu dieser MarkerId holen ...
|
|
int foundCount = 0;
|
|
for (const auto &expected : modifyData.descriptions())
|
|
{
|
|
for (const auto &got : data.descriptions())
|
|
{
|
|
// we've got one description per type
|
|
if (got.markerType() != expected.markerType())
|
|
continue;
|
|
++foundCount;
|
|
|
|
if (got.content() != expected.content())
|
|
{
|
|
ERROR_LOG(m_logger) << "Content for description does not match: "
|
|
<< got.content() << " - "
|
|
<< expected.content();
|
|
failExit();
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
if (foundCount != 3)
|
|
{
|
|
ERROR_LOG(m_logger) << "Did not found all three expected descriptions";
|
|
failExit();
|
|
return false;
|
|
}
|
|
|
|
DEBUG_LOG(m_logger) << "successfull finished onCompareModifiedData() for id :" << data.id();
|
|
|
|
return true;
|
|
} // end of onCompareModifiedData()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void MrkTests::failExit()
|
|
{
|
|
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 FTC/DTC tests), 1 create, 2 modify, 3 remove, 10 getAllMarker and Descriptions, 11 getMarker")
|
|
, QLatin1String("0")
|
|
});
|
|
|
|
addOption({ QStringList() << QLatin1String("m") << QLatin1String("markerId")
|
|
, QLatin1String("MarkerId.")
|
|
, QLatin1String("Used for tests 2, 3 & 11 only to select the marker")
|
|
, QLatin1String("0")
|
|
});
|
|
|
|
addOption({ QStringList() << QLatin1String("s") << QLatin1String("snapshotId")
|
|
, QLatin1String("SnapshotId.")
|
|
, QLatin1String("Used for tests 4, 5 & 6 only to select the snapshotId")
|
|
, QLatin1String("0")
|
|
});
|
|
}
|
|
|
|
int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : -1; }
|
|
int markerId() const { return isSet(QLatin1String("m")) ? value(QLatin1String("m")).toInt() : -1; }
|
|
int snapshotId() const { return isSet(QLatin1String("s")) ? value(QLatin1String("s")).toInt() : -1; }
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int main(int argc, char **argv)
|
|
{
|
|
NGLCoreApplication app(argc, argv);
|
|
app.createLogger("mrk", "log4cxx_mrk_module_tests.props");
|
|
|
|
int iRet = -1;
|
|
CmdLineParser options;
|
|
if (!options.init())
|
|
return iRet;
|
|
|
|
std::unique_ptr<MarkerManagement::MrkTests> MrkTests(new MarkerManagement::MrkTests);
|
|
if (!MrkTests->init(options.domainId(), options.exerciseId(), options.testId(), options.markerId(), options.snapshotId()))
|
|
return iRet;
|
|
|
|
QTimer::singleShot(2000, MrkTests.get(), &MarkerManagement::MrkTests::startTest);
|
|
|
|
STARTUP_LOG(app.baseLogger());
|
|
|
|
app.exec();
|
|
|
|
iRet = MrkTests->testsSuccessful() ? 0 : 1;
|
|
fprintf(stderr, "%d\n", iRet);
|
|
|
|
DEBUG_LOG(app.baseLogger()) << "** TEST result = " << iRet;
|
|
|
|
SHUTDOWN_LOG(app.baseLogger());
|
|
|
|
return iRet;
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
|