Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS_MRK_TEST
|
||||
nom_tests.cpp
|
||||
nom_tests.h
|
||||
../settings.cpp
|
||||
../settings.h
|
||||
)
|
||||
|
||||
IF(BUILD_TESTING AND TARGET svcNomClient)
|
||||
# Testing FunctionTopic Functionality (FTC)
|
||||
ADD_EXECUTABLE(nomTests ${SRCS_MRK_TEST})
|
||||
TARGET_LINK_LIBRARIES(nomTests
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
RTI::nddscpp2
|
||||
svcNomClient
|
||||
svcOpmClient
|
||||
LtsCommandLineParser
|
||||
ddsconnector
|
||||
nglcoreapplication
|
||||
nglsettings
|
||||
ngltools
|
||||
)
|
||||
IF(NOT BUILD_RPM)
|
||||
NGL_INSTALL(AAR SV TARGETS nomTests DESTINATION bin/test)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_nom_module_tests.props DESTINATION bin/test)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# Service: NotificationManagement
|
||||
###########################################################
|
||||
|
||||
#log4j.logger.NOM=DEBUG
|
||||
#log4j.logger.NOM.main=DEBUG
|
||||
#log4j.logger.NOM.MainHandler=DEBUG
|
||||
#log4j.logger.NOM.DdsHandler=DEBUG
|
||||
#log4j.logger.NOM.DbHandler=DEBUG
|
||||
#log4j.logger.NOM.HandlerNotification=DEBUG
|
||||
#log4j.logger.NOM.ObjectNotification=DEBUG
|
||||
|
||||
# File
|
||||
###########################################################
|
||||
log4j.appender.file=Lts::RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# INFO,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
# Examples for files:
|
||||
@@ -0,0 +1,593 @@
|
||||
/**
|
||||
* MRK Function Topic test executable
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, ESZS, 2025-06-23
|
||||
*/
|
||||
#include "nom_tests.h"
|
||||
#include "ngltools/ngltools_filesystem.h"
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#include <NotificationManagement/nom_ftc.h>
|
||||
#include <NotificationManagement/nom_dtc.h>
|
||||
#include <ParticipantManagement/ppm_operator_rights.h>
|
||||
#include <FileManagement/flm_operator_rights.h>
|
||||
#include <iostream>
|
||||
#include <NotificationManagement/settings.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <QSettings>
|
||||
|
||||
using namespace NotificationManagement;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NomTests::NomTests(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_exerciseId(0)
|
||||
, m_testId(0)
|
||||
, m_notificationId(0)
|
||||
, m_eTestStep(eUnknown)
|
||||
, m_bTestsSuccessful(true)
|
||||
, m_logger(getLogger("NomTests"))
|
||||
{
|
||||
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
|
||||
} // end of ctor()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NomTests::~NomTests()
|
||||
{
|
||||
} // end of dtor()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool NomTests::init(int domainId, int exerciseId, int testId, int notificationId)
|
||||
{
|
||||
INFO_LOG(m_logger) << "MrkTests::init() "
|
||||
<< " domainId:" << domainId
|
||||
<< " exerciseId:" << exerciseId
|
||||
<< " testId: " << testId
|
||||
<< " notificationId: " << notificationId
|
||||
;
|
||||
|
||||
m_testId = testId;
|
||||
m_exerciseId = exerciseId;
|
||||
m_notificationId = notificationId;
|
||||
|
||||
// initialize DDS
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::AllExercises, exerciseId));
|
||||
if (!m_ddsConnector->init())
|
||||
return false;
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
|
||||
// Access to FTC
|
||||
TRACE_LOG(m_logger) << "create ftc";
|
||||
m_ftc = NotificationManagement::Interface::Ftc::create(m_ddsConnector);
|
||||
TRACE_LOG(m_logger) << "init ftc";
|
||||
bool bRet = m_ftc->enableAll();
|
||||
TRACE_LOG(m_logger) << "init end - bRet = " << bRet;
|
||||
|
||||
// Access to DTC
|
||||
TRACE_LOG(m_logger) << "create dtc";
|
||||
m_dtc = NotificationManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
TRACE_LOG(m_logger) << "init dtc";
|
||||
bRet &= m_dtc->enableAll();
|
||||
TRACE_LOG(m_logger) << "init end - bRet = " << bRet;
|
||||
|
||||
|
||||
// Access to OPM DTC
|
||||
TRACE_LOG(m_logger) << "create opmDtc";
|
||||
m_opmDtc = OperatorManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
m_opmDtc->enableUser();
|
||||
|
||||
return bRet;
|
||||
} // end of init()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NomTests::startTest()
|
||||
{
|
||||
INFO_LOG(m_logger) << "startTest() exerciseId:" << m_exerciseId
|
||||
<< " testId:" << m_testId
|
||||
<< " notificationId:" << m_notificationId
|
||||
;
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::nomNotificationChanged,
|
||||
this, &NomTests::onReceiveNotificationChanged);
|
||||
|
||||
switch(m_testId)
|
||||
{
|
||||
case 0:
|
||||
QTimer::singleShot(0, this, &NomTests::tryCreate);//command ./nomTests -d xx -e xx -t 0
|
||||
break;
|
||||
case 1:
|
||||
QTimer::singleShot(0, this, &NomTests::tryCreateHQ);//command ./nomTests -d xx -e xx -t 1
|
||||
break;
|
||||
case 2:
|
||||
QTimer::singleShot(0, this, &NomTests::tryReadReceipt);
|
||||
break;
|
||||
case 3:
|
||||
QTimer::singleShot(0, this, &NomTests::tryRemove);
|
||||
break;
|
||||
case 10:
|
||||
QTimer::singleShot(0, this, &NomTests::tryGetAllNotifications);
|
||||
break;
|
||||
case 11:
|
||||
QTimer::singleShot(0, this, &NomTests::tryGetNotification);
|
||||
break;
|
||||
}
|
||||
|
||||
} // end of startTest()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NomTests::tryCreate()
|
||||
{
|
||||
m_eTestStep = eCreate;
|
||||
CreateNotificationRequest data;
|
||||
getCreateNotificationRequestData(data);
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send CreateNotificationRequest";
|
||||
if (!m_ftc->createNotificationRequest(data, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
}
|
||||
}
|
||||
|
||||
void NomTests::tryCreateHQ()
|
||||
{
|
||||
|
||||
QScopedPointer<NGL::Settings> s (new NGL::Settings(NGL::findProjectConfigFile()));
|
||||
qint64 currentTime = QDateTime::currentMSecsSinceEpoch();
|
||||
qint64 expiryTime = currentTime + Settings::expiryIntervalMSec();
|
||||
NotificationManagement::NomNotification notif;
|
||||
|
||||
notif.title(tr("HQ Reports ").toStdString());
|
||||
|
||||
// format: "[Open HQ Report Dialog](//flmHQReport/party=3&folder=51&file=12)"
|
||||
// Open HQ Report Dialog : this text link will display on notification and is clickable
|
||||
// url().host() to get host scheme_identifier: flmHQReport
|
||||
// QString data = url().path().mid(1) to get "party=3&folder=51&file=12".
|
||||
// with QUrlQuery query(data); // get each parameter: query.queryItemValue("party").toInt(); // same for the others
|
||||
/// retrieve data in flm_explorer_gui_plugin.cpp
|
||||
|
||||
int partyId = 3; // place holder from ex_42.pppm_party PartyId BLUE
|
||||
int folderId = 51; // place holder from flm_folder
|
||||
int fileId = 12; // place holder from flm_file_content
|
||||
QString linkName = QStringLiteral("Open HQ Report Dialog");
|
||||
QString content = QStringLiteral("[%1](//flmHQReport/?party=%2&folder=%3&file=%4)");
|
||||
content = content.arg(linkName).arg(partyId).arg(folderId).arg(fileId);
|
||||
notif.content(content.toStdString());
|
||||
notif.timeStamp(currentTime);
|
||||
notif.expiryTime(expiryTime);
|
||||
|
||||
notif.priority(static_cast<NotificationManagement::Priority_def::type>(Settings::notificationPriority()));
|
||||
notif.processedPriority(NotificationManagement::Priority_def::Highest);
|
||||
notif.exerciseId(m_exerciseId);
|
||||
|
||||
for (const auto &userId : m_opmDtc->getOperatorsByOperatorRight(OperatorRights::FileManagementFilesEdit))
|
||||
{
|
||||
NotificationManagement::Address addr;
|
||||
addr.addressId(userId);
|
||||
addr.isRead(false);
|
||||
QString name = QStringLiteral("Operator ") + QString::number(userId);
|
||||
addr.name(name.toStdString());
|
||||
addr.addressType(NotificationManagement::AddressType_def::Operator);
|
||||
addr.addressSubId(userId+10);
|
||||
notif.recipientIds().push_back(addr);
|
||||
}
|
||||
|
||||
// NotificationManagement::Address addrSender;
|
||||
// addrSender.addressId(FileManagement::Offset);
|
||||
// addrSender.name(tr("[FileManagement2](flmHQReport)").toStdString());
|
||||
// addrSender.addressType(NotificationManagement::AddressType_def::Service);
|
||||
// addrSender.addressSubId(321);
|
||||
// notif.sender(addrSender);
|
||||
|
||||
NotificationManagement::CreateNotificationRequest notifReq;
|
||||
notifReq.notification(notif);
|
||||
|
||||
if (!m_ftc->createNotificationRequest(notifReq, this))
|
||||
ERROR_LOG(m_logger) << "Error requesting create Notification data";
|
||||
|
||||
} // end of tryCreate()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NomTests::tryReadReceipt()
|
||||
{
|
||||
m_eTestStep = eReadReceipt;
|
||||
|
||||
m_dtc->waitForHistoricalDataNomNotification();
|
||||
NotificationManagement::NomNotification data = m_dtc->nomNotification(m_notificationId);
|
||||
|
||||
NotificationManagement::Address recipientAddress = data.recipientIds().front();
|
||||
//NotificationManagement::Address recipientAddress = data.recipientIds().at(2);
|
||||
NotificationManagement::ReadReceiptRequest request;
|
||||
request.addressId(recipientAddress.id());
|
||||
request.operatorId(recipientAddress.addressId());
|
||||
request.workstationId(0);
|
||||
|
||||
request.notificationIds({m_notificationId});
|
||||
request.processed(true);
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send CreateNotificationRequest";
|
||||
if (!m_ftc->readReceiptRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting readReceipt data";
|
||||
failExit();
|
||||
}
|
||||
} // end of tryReadReceipt
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NomTests::tryRemove()
|
||||
{
|
||||
m_eTestStep = eRemove;
|
||||
/*
|
||||
NotificationRemoveRequest data;
|
||||
|
||||
data.id(m_notificationId);
|
||||
|
||||
INFO_LOG(m_logger) << "trying to send remove request for notificationId:" << data.id();
|
||||
if (!m_ftc->notificationRemoveRequest(data, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting remove data for notificationId:" << data.id();
|
||||
failExit();
|
||||
}
|
||||
*/
|
||||
|
||||
} // end of tryRemove()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NomTests::tryGetAllNotifications()
|
||||
{
|
||||
m_eTestStep = eGetAllNotifications;
|
||||
DEBUG_LOG(m_logger) << "trying to get all notifications";
|
||||
|
||||
m_dtc->waitForHistoricalDataNomNotification();
|
||||
if (m_dtc->nomNotifications().isEmpty())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting all notification data";
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const NomNotification ¬if : m_dtc->nomNotifications())
|
||||
{
|
||||
// needed for Test 11 tryGetNotification
|
||||
m_notificationId = notif.id();
|
||||
|
||||
INFO_LOG(m_logger) << "Nom(" << notif.id() << ") :"
|
||||
<< " title:" << notif.title()
|
||||
<< " content:" << notif.content()
|
||||
<< " timeStamp:" << notif.timeStamp()
|
||||
<< " priority:" << notif.priority()
|
||||
<< " processed: " << notif.processed()
|
||||
<< " processedTime: " << notif.processTime()
|
||||
<< " processPrio: " << notif.processedPriority()
|
||||
<< " recipient count:" << notif.recipientIds().size();
|
||||
|
||||
INFO_LOG(m_logger) << "SenderAddress(" << notif.sender().id() << ") :"
|
||||
<< " name: " << notif.sender().name()
|
||||
<< ", addressId: " << notif.sender().addressId()
|
||||
<< ", addressSubId: " << notif.sender().addressSubId()
|
||||
<< ", addressSubSubId: " << notif.sender().addressSubSubId()
|
||||
<< ", addressType: " << notif.sender().addressType();
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
|
||||
} // end of tryGetAllNotifications()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NomTests::tryGetNotification()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "trying to get notification with id:" << m_notificationId;
|
||||
|
||||
if (m_testId > 1)
|
||||
m_eTestStep = eGetNotification;
|
||||
|
||||
if (m_notificationId <= 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "invalid notificationId - test aborted.";
|
||||
failExit();
|
||||
}
|
||||
|
||||
m_dtc->waitForHistoricalDataNomNotification();
|
||||
NotificationManagement::NomNotification notif = m_dtc->nomNotification(m_notificationId);
|
||||
|
||||
if (notif.id() <= 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error receiving data for notificationId " << m_notificationId << " returnVal:" << notif.id();
|
||||
failExit();
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO_LOG(m_logger) << "NomNotification(" << notif.id() << ") :"
|
||||
<< " title:" << notif.title()
|
||||
<< " content:" << notif.content()
|
||||
<< " timeStamp:" << notif.timeStamp()
|
||||
<< " priority:" << notif.priority()
|
||||
<< " processed: " << notif.processed()
|
||||
<< " processedTime: " << notif.processTime()
|
||||
<< " processPrio: " << notif.processedPriority()
|
||||
<< " recipient count:" << notif.recipientIds().size();
|
||||
|
||||
for (const NotificationManagement::Address &addr : notif.recipientIds())
|
||||
{
|
||||
INFO_LOG(m_logger) << "Recipient(" << addr.id() << ") :"
|
||||
<< " name: " << addr.name()
|
||||
<< ", addressId: " << addr.addressId()
|
||||
<< ", addressSubId: " << addr.addressSubId()
|
||||
<< ", addressSubSubId: " << addr.addressSubSubId()
|
||||
<< ", addressType: " << addr.addressType()
|
||||
<< ", isRead: " << addr.isRead();
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "SenderAddress(" << notif.sender().id() << ") :"
|
||||
<< " name: " << notif.sender().name()
|
||||
<< ", addressId: " << notif.sender().addressId()
|
||||
<< ", addressSubId: " << notif.sender().addressSubId()
|
||||
<< ", addressSubSubId: " << notif.sender().addressSubSubId()
|
||||
<< ", addressType: " << notif.sender().addressType();
|
||||
}
|
||||
|
||||
if (m_testId == 0)
|
||||
{
|
||||
if (m_eTestStep == eCreate)
|
||||
{
|
||||
if (! onCompareCreatedData(notif))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Compare created data failed!";
|
||||
failExit();
|
||||
}
|
||||
else
|
||||
{
|
||||
QTimer::singleShot(0, this, &NomTests::tryReadReceipt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
|
||||
} // end of tryGetNotification()
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NomTests::onCreateNotificationReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got createReply with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
m_notificationId = 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, &NomTests::tryModify()));
|
||||
QTimer::singleShot(0, this, &NomTests::tryGetNotification);
|
||||
else
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
|
||||
} // end of onNotificationCreateReply()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NomTests::onReadReceiptReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
|
||||
INFO_LOG(m_logger) << "Got onReadReceipt with id " << replyObject.id()
|
||||
<< " and errorString " << replyObject.translated();
|
||||
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting ReadReceipt data for id:" << replyObject.id();
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "Requesting ReadReceipt data for id:" << replyObject.id() << " ... ok.";
|
||||
|
||||
if (m_testId == 0)
|
||||
// QTimer::singleShot(0, this, &MrkTests::tryDelete()));
|
||||
QTimer::singleShot(0, this, &NomTests::tryGetNotification);
|
||||
else
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
|
||||
} // end of onReadReceiptReply()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*
|
||||
void NomTests::onNotificationRemoveReply(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 NotificationId:" << replyObject.id();
|
||||
failExit();
|
||||
return;
|
||||
}
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "Requesting remove data for NotificationId:" << 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 onNotificationRemoveReply()
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NomTests::onReceiveNotificationChanged(const NomNotification &data, DataModification modType)
|
||||
{
|
||||
// INFO_LOG(m_logger) << "onReceiveNotificationChanged() notificationId:" << data.id()
|
||||
// << " modificationType: = " << (int)modType<< " received";
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
INFO_LOG(m_logger) << "*** NomNotification added received. notificationId:" << data.id();
|
||||
break;
|
||||
|
||||
case DataModification::eModified:
|
||||
INFO_LOG(m_logger) << "*** NomNotification modified received. notificationId:" << data.id();
|
||||
break;
|
||||
|
||||
case DataModification::eRemoved:
|
||||
INFO_LOG(m_logger) << "*** NomNotification removed received. notificationId:" << data.id();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
} // end of onReceiveNotificationChanged()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NomTests::getCreateNotificationRequestData(CreateNotificationRequest &data)
|
||||
{
|
||||
qint64 currentTime = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
// 100 seconds
|
||||
qint64 expiryTime = currentTime + 100 * 1000;
|
||||
NotificationManagement::NomNotification notif;
|
||||
|
||||
notif.title("TestNotificationCreate");
|
||||
notif.content("Dies ist ein Test mit Content");
|
||||
notif.timeStamp(currentTime);
|
||||
notif.expiryTime(expiryTime);
|
||||
notif.priority(NotificationManagement::Priority_def::High);
|
||||
notif.processedPriority(NotificationManagement::Priority_def::Low);
|
||||
notif.exerciseId(m_exerciseId);
|
||||
|
||||
for (int i=10; i< 24; i++)
|
||||
{
|
||||
NotificationManagement::Address addr;
|
||||
addr.addressId(i);
|
||||
addr.isRead(false);
|
||||
QString name = QStringLiteral("Operator ") + QString::number(i);
|
||||
addr.name(name.toStdString());
|
||||
addr.addressType(NotificationManagement::AddressType_def::Operator);
|
||||
addr.addressSubId(i+10);
|
||||
notif.recipientIds().push_back(addr);
|
||||
}
|
||||
|
||||
NotificationManagement::Address wsAddr;
|
||||
wsAddr.addressId(302);
|
||||
wsAddr.isRead(false);
|
||||
QString name = QStringLiteral("Workstation 2 ");
|
||||
wsAddr.name(name.toStdString());
|
||||
wsAddr.addressType(NotificationManagement::AddressType_def::Workstation);
|
||||
notif.recipientIds().push_back(wsAddr);
|
||||
|
||||
NotificationManagement::Address addrSender;
|
||||
addrSender.addressId(ParticipantManagement::Offset);
|
||||
addrSender.name(QStringLiteral("svcParticipantManagement ").toStdString());
|
||||
addrSender.addressType(NotificationManagement::AddressType_def::Service);
|
||||
notif.sender(addrSender);
|
||||
|
||||
data.notification(notif);
|
||||
} // end of getCreateNotificationRequestData()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool NomTests::onCompareCreatedData(NomNotification &data)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "start onCompareCreatedData() for id :" << data.id();
|
||||
|
||||
// Vergleicht die zurueckgelesen Datan mit den statischen create Daten
|
||||
|
||||
CreateNotificationRequest createData;
|
||||
|
||||
getCreateNotificationRequestData(createData);
|
||||
|
||||
if (createData.notification().title() != data.title())
|
||||
return false;
|
||||
|
||||
if (createData.notification().priority() != data.priority())
|
||||
return false;
|
||||
if (createData.notification().content() != data.content())
|
||||
return false;
|
||||
if (createData.notification().processedPriority() != data.processedPriority())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
} // end of onCompareCreatedData()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void NomTests::failExit()
|
||||
{
|
||||
m_bTestsSuccessful = false;
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption({ QStringList() << QStringLiteral("t") << QStringLiteral("testId")
|
||||
, QStringLiteral("TestId.")
|
||||
, QStringLiteral("Default: 0 (all FTC/DTC tests), 1 create, 2 readReceipt, 3 remove, 10 getAllNotification and Recipients, 11 getNotification")
|
||||
, QStringLiteral("0")
|
||||
});
|
||||
|
||||
addOption({ QStringList() << QStringLiteral("n") << QStringLiteral("notificationId")
|
||||
, QStringLiteral("NotificationId.")
|
||||
, QStringLiteral("Used for tests 2, 3 & 11 only to select the notification")
|
||||
, QStringLiteral("0")
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
int testId() const { return isSet(QStringLiteral("t")) ? value(QStringLiteral("t")).toInt() : -1; }
|
||||
int notificationId() const { return isSet(QStringLiteral("n")) ? value(QStringLiteral("n")).toInt() : -1; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("nom", "log4cxx_nom_module_tests.props");
|
||||
|
||||
int iRet = -1;
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return iRet;
|
||||
|
||||
std::unique_ptr<NotificationManagement::NomTests> NomTests(new NotificationManagement::NomTests);
|
||||
if (!NomTests->init(options.domainId(), options.exerciseId(), options.testId(), options.notificationId()))
|
||||
return iRet;
|
||||
|
||||
QTimer::singleShot(2000, NomTests.get(), &NotificationManagement::NomTests::startTest);
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
app.exec();
|
||||
|
||||
iRet = NomTests->testsSuccessful() ? 0 : 1;
|
||||
fprintf(stderr, "%d\n", iRet);
|
||||
|
||||
DEBUG_LOG(app.baseLogger()) << "** TEST result = " << iRet;
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
|
||||
return iRet;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
*
|
||||
* EXM Function Topic test executable
|
||||
*
|
||||
* ModuleTests for createNotification/readReceipt
|
||||
* ---------------------------------------------------
|
||||
* Client FTC is implemented
|
||||
*
|
||||
* => (!) Preconditon:
|
||||
* - Service svcNotificationManagent running
|
||||
*
|
||||
* -------------------------------------------------
|
||||
*
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, ESZS, 2025-06-23
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <NotificationManagement/nom_ftc.h>
|
||||
#include <NotificationManagement/nom_ftc_types.h>
|
||||
#include <NotificationManagement/nom_dtc.h>
|
||||
#include <NotificationManagement/nom_dtc_types.h>
|
||||
#include <NotificationManagement/logger.h>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
namespace NotificationManagement
|
||||
{
|
||||
class NomTests : public QObject
|
||||
, protected NotificationManagement::Interface::Ftc::CreateNotificationReplyHandler
|
||||
, protected NotificationManagement::Interface::Ftc::ReadReceiptReplyHandler
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NomTests(QObject *parent = nullptr);
|
||||
~NomTests();
|
||||
|
||||
bool init(int domainId, int exerciseId, int testId, int notificationId);
|
||||
bool testsSuccessful() const { return m_bTestsSuccessful; }
|
||||
|
||||
public Q_SLOTS:
|
||||
void startTest();
|
||||
|
||||
protected Q_SLOTS:
|
||||
// used to check FTC
|
||||
void tryCreate();
|
||||
void tryCreateHQ();
|
||||
void tryReadReceipt();
|
||||
void tryRemove();
|
||||
|
||||
|
||||
// used to check DTC
|
||||
void tryGetAllNotifications();
|
||||
void tryGetNotification();
|
||||
|
||||
// used to check DTC signal/slot connection
|
||||
void onReceiveNotificationChanged(const NomNotification &data, DataModification modType);
|
||||
|
||||
protected:
|
||||
// Callbackfunctions for FTC
|
||||
void onCreateNotificationReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onReadReceiptReply(const Core::FunctionReplyObject &reply) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
bool onCompareCreatedData(NomNotification &data);
|
||||
//bool onCompareModifiedData(NomNotification &data);
|
||||
|
||||
private:
|
||||
void getCreateNotificationRequestData(CreateNotificationRequest &data);
|
||||
void failExit();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<NotificationManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<NotificationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
|
||||
qint32 m_exerciseId;
|
||||
int m_testId;
|
||||
int m_notificationId;
|
||||
|
||||
enum TestStep
|
||||
{
|
||||
eUnknown,
|
||||
eCreate,
|
||||
eReadReceipt,
|
||||
eRemove,
|
||||
eGetAllNotifications,
|
||||
eGetNotification
|
||||
} m_eTestStep;
|
||||
|
||||
bool m_bTestsSuccessful;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
|
||||
} // namespace NotificationManagement
|
||||
Reference in new issue
Block a user