9#include <hlt/softwaretrigger/core/SoftwareTriggerDBHandler.h>
10#include <framework/database/Configuration.h>
11#include <framework/database/Database.h>
13#include <framework/utilities/TestHelpers.h>
14#include <gtest/gtest.h>
23 namespace SoftwareTrigger {
43 conf.prependTestingPayloadLocation(
m_tmpDir->
getTempDir() +
"/testPayloads/TestDatabase.txt");
58 TEST_F(SoftwareTriggerDBHandlerTest, downloadAndChanged)
60 SoftwareTriggerObject preFilledObject;
72 EXPECT_B2FATAL(SoftwareTriggerDBHandler(
"test"));
77 SoftwareTriggerDBHandler dbHandler(
"test");
78 const auto& cutsWithNames = dbHandler.getCutsWithNames();
80 cutsWithNames.at(
"software_trigger_cut&test&cutOne")->checkPreScaled(preFilledObject));
81 EXPECT_THROW(cutsWithNames.at(
"software_trigger_cut&test&cutTwo"), std::out_of_range);
93 SoftwareTriggerDBHandler otherDBHandler(
"test2");
94 const auto& otherCutsWithNames = otherDBHandler.getCutsWithNames();
97 otherCutsWithNames.at(
"software_trigger_cut&test2&cutOne")->checkPreScaled(preFilledObject));
99 otherCutsWithNames.at(
"software_trigger_cut&test2&cutTwo")->checkPreScaled(preFilledObject));
104 TEST_F(SoftwareTriggerDBHandlerTest, pythonUpAndDownload)
106 IntervalOfValidity iov(0, 0, -1, -1);
114 ASSERT_NE(downloadedCutOne,
nullptr);
116 EXPECT_EQ(cutOne->decompile(), downloadedCutOne->decompile());
117 EXPECT_EQ(cutOne->getPreScaleFactor(), downloadedCutOne->getPreScaleFactor());
118 EXPECT_EQ(cutOne->isRejectCut(), downloadedCutOne->isRejectCut());
126 ASSERT_NE(downloadedCutTwo,
nullptr);
128 EXPECT_EQ(cutTwo->decompile(), downloadedCutTwo->decompile());
129 EXPECT_EQ(cutTwo->getPreScaleFactor(), downloadedCutTwo->getPreScaleFactor());
130 EXPECT_EQ(cutTwo->isRejectCut(), downloadedCutTwo->isRejectCut());
static Configuration & getInstance()
Get a reference to the instance which will be used when the Database is initialized.
static DataStore & Instance()
Instance of singleton Store.
void setInitializeActive(bool active)
Setter for m_initializeActive.
void reset(EDurability durability)
Frees memory occupied by data store items and removes all objects from the map.
A class that describes the interval of experiments/runs for which an object in the database is valid.
static std::unique_ptr< SoftwareTriggerCut > compile(const std::string &cut_string, const unsigned int prescaleFactor, const bool rejectCut=false)
Compile a new SoftwareTriggerCut from a cut string (by using the GeneralCut::compile function) and an...
Class to test the down- and upload of trigger cuts to the DB.
void SetUp()
Setup the local DB and the datastore with the event meta data.
TestHelpers::TempDirCreator * m_tmpDir
Do everything in a temporary dir.
void TearDown()
Destroy the DB and the DataStore.
static void uploadTriggerMenu(const std::string &baseCutIdentifier, const std::vector< std::string > &cutIdentifiers, bool acceptMode, const IntervalOfValidity &iov)
Upload a new (or replace an old version) trigger menu with the given base and specific names.
static void upload(const std::unique_ptr< SoftwareTriggerCut > &cut, const std::string &baseCutIdentifier, const std::string &cutIdentifier, const IntervalOfValidity &iov)
Upload a new (or replace an old version) cut with the given base and specific name.
static std::unique_ptr< SoftwareTriggerCut > download(const std::string &baseCutIdentifier, const std::string &cutIdentifier)
Download a cut from the database.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Type-safe access to single objects in the data store.
bool construct(Args &&... params)
Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.
changes working directory into a newly created directory, and removes it (and contents) on destructio...
std::string getTempDir() const
Returns path of temporary directory.
void reset(bool keepEntries=false)
Invalidate all payloads.
static DBStore & Instance()
Instance of a singleton DBStore.
static void reset(bool keepConfig=false)
Reset the database instance.
@ c_accept
Accept this event.
@ c_noResult
There were not enough information to decide on what to do with the event.
Abstract base class for different kinds of events.