Skip to content
Snippets Groups Projects
Commit d82ec198 authored by Steven Murray's avatar Steven Murray
Browse files

All unit tests now pass

parent 06d87caa
No related branches found
No related tags found
No related merge requests found
......@@ -156,6 +156,22 @@ std::list<cta::StorageClass> cta::MockClientAPI::getStorageClasses(
//------------------------------------------------------------------------------
void cta::MockClientAPI::createTapePool(const SecurityIdentity &requester,
const std::string &name, const std::string &comment) {
checkTapePoolDoesNotAlreadyExists(name);
TapePool tapePool(name, requester.user, comment);
m_tapePools[name] = tapePool;
}
//------------------------------------------------------------------------------
// checkTapePoolDoesNotAlreadyExists
//------------------------------------------------------------------------------
void cta::MockClientAPI::checkTapePoolDoesNotAlreadyExists(
const std::string &name) const {
std::map<std::string, TapePool>::const_iterator itor = m_tapePools.find(name);
if(itor != m_tapePools.end()) {
std::ostringstream message;
message << "The " << name << " tape pool already exists";
throw Exception(message.str());
}
}
//------------------------------------------------------------------------------
......@@ -163,6 +179,13 @@ void cta::MockClientAPI::createTapePool(const SecurityIdentity &requester,
//------------------------------------------------------------------------------
void cta::MockClientAPI::deleteTapePool(const SecurityIdentity &requester,
const std::string &name) {
std::map<std::string, TapePool>::iterator itor = m_tapePools.find(name);
if(itor == m_tapePools.end()) {
std::ostringstream message;
message << "The " << name << " tape pool does not exist";
throw Exception(message.str());
}
m_tapePools.erase(itor);
}
//------------------------------------------------------------------------------
......@@ -171,6 +194,11 @@ void cta::MockClientAPI::deleteTapePool(const SecurityIdentity &requester,
std::list<cta::TapePool> cta::MockClientAPI::getTapePools(
const SecurityIdentity &requester) const {
std::list<cta::TapePool> tapePools;
for(std::map<std::string, TapePool>::const_iterator itor =
m_tapePools.begin(); itor != m_tapePools.end(); itor++) {
tapePools.push_back(itor->second);
}
return tapePools;
}
......
......@@ -267,6 +267,11 @@ protected:
*/
FileSystemStorageClasses m_storageClasses;
/**
* Mapping from tape pool name to tape pool.
*/
std::map<std::string, TapePool> m_tapePools;
/**
* The root node of the file-system.
*/
......@@ -392,6 +397,13 @@ protected:
void splitString(const std::string &str, const char separator,
std::vector<std::string> &result) const throw();
/**
* Throws an exception if the specified tape pool already exixts.
*
* @paran name The name of the tape pool.
*/
void checkTapePoolDoesNotAlreadyExists(const std::string &name) const;
}; // class MockClientAPI
} // namespace cta
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment