diff --git a/catalogue/InMemoryCatalogue.hpp b/catalogue/InMemoryCatalogue.hpp index 9cf3caecf2765adf8c68115a76b55a5f6892acb4..9b51e3d42dea7970d99f71424251991c1c1f7e33 100644 --- a/catalogue/InMemoryCatalogue.hpp +++ b/catalogue/InMemoryCatalogue.hpp @@ -23,14 +23,24 @@ namespace cta { namespace catalogue { +class CatalogueFactory; + /** * CTA catalogue class to be used for unit testing. */ class InMemoryCatalogue: public RdbmsCatalogue { -public: /** - * Constructor. + * The CatalogueFactory is a friend so that it can call the private + * constructor of this class. + */ + friend CatalogueFactory; + +private: + + /** + * Private constructor only to be called by the CatalogueFactory class (a + * friend). * * @param conn The connection to the underlying relational database. Please * note that the InMemoryCatalogue will own and therefore delete the @@ -38,6 +48,8 @@ public: */ InMemoryCatalogue(); +public: + /** * Destructor. */ diff --git a/catalogue/InMemoryCatalogueTest.cpp b/catalogue/InMemoryCatalogueTest.cpp index a4831a591bedd18cb527af6f31596c77f06ba058..1cb36f6c0a133d1c9f242ca5543f3dccc15189c0 100644 --- a/catalogue/InMemoryCatalogueTest.cpp +++ b/catalogue/InMemoryCatalogueTest.cpp @@ -28,28 +28,6 @@ namespace unitTests { -namespace { - std::map<std::string, cta::common::dataStructures::Tape> tapeListToMap( - const std::list<cta::common::dataStructures::Tape> &listOfTapes) { - using namespace cta; - - try { - std::map<std::string, cta::common::dataStructures::Tape> vidToTape; - - for (auto &&tape: listOfTapes) { - if(vidToTape.end() != vidToTape.find(tape.vid)) { - throw exception::Exception(std::string("Duplicate VID: value=") + tape.vid); - } - vidToTape[tape.vid] = tape; - } - - return vidToTape; - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } - } -} - class cta_catalogue_InMemoryCatalogueTest : public ::testing::Test { public: cta_catalogue_InMemoryCatalogueTest(): @@ -83,6 +61,32 @@ protected: cta::common::dataStructures::SecurityIdentity m_cliSI; cta::common::dataStructures::SecurityIdentity m_bootstrapAdminSI; cta::common::dataStructures::SecurityIdentity m_adminSI; + + /** + * Creates a map from VID to tape given the specified list of tapes. + * + * @param listOfTapes The list of tapes from which the map shall be created. + * @return The map from VID to tape. + */ + std::map<std::string, cta::common::dataStructures::Tape> tapeListToMap( + const std::list<cta::common::dataStructures::Tape> &listOfTapes) { + using namespace cta; + + try { + std::map<std::string, cta::common::dataStructures::Tape> vidToTape; + + for (auto &&tape: listOfTapes) { + if(vidToTape.end() != vidToTape.find(tape.vid)) { + throw exception::Exception(std::string("Duplicate VID: value=") + tape.vid); + } + vidToTape[tape.vid] = tape; + } + + return vidToTape; + } catch(exception::Exception &ex) { + throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); + } + } }; TEST_F(cta_catalogue_InMemoryCatalogueTest, createBootstrapAdminAndHostNoAuth) { diff --git a/catalogue/OracleCatalogue.hpp b/catalogue/OracleCatalogue.hpp index 031762da64acb2447560dd2f43abbf76003e1bd2..54960ae5c9ddb4c5660dda6e6f1eb33b5a02ca74 100644 --- a/catalogue/OracleCatalogue.hpp +++ b/catalogue/OracleCatalogue.hpp @@ -23,14 +23,24 @@ namespace cta { namespace catalogue { +class CatalogueFactory; + /** * CTA catalogue class to be used for unit testing. */ class OracleCatalogue: public RdbmsCatalogue { -public: /** - * Constructor. + * The CatalogueFactory is a friend so that it can call the private + * constructor of this class. + */ + friend CatalogueFactory; + +private: + + /** + * Private constructor only to be called by the CatalogueFactory class (a + * friend). * * @param username The database username. * @param password The database password. @@ -41,6 +51,8 @@ public: const std::string &password, const std::string &database); +public: + /** * Destructor. */ diff --git a/catalogue/RdbmsCatalogue.hpp b/catalogue/RdbmsCatalogue.hpp index c17a628c5ee15d068682898d2ed53db6823b04cc..fec8dd5917f38cf19df6c715ae1a4f90a6f171e6 100644 --- a/catalogue/RdbmsCatalogue.hpp +++ b/catalogue/RdbmsCatalogue.hpp @@ -50,13 +50,15 @@ class ArchiveFileRow; * CTA catalogue implemented using a relational database backend. */ class RdbmsCatalogue: public Catalogue { -public: +protected: /** - * Constructor. + * Protected constructor only to be called by sub-classes. */ RdbmsCatalogue(); +public: + /** * Destructor. */