Skip to content
Snippets Groups Projects
Commit 853ea695 authored by Parker, Peter's avatar Parker, Peter
Browse files

Refs #22608 - Traditional clang-format corrections.

parent d4e42ffd
No related branches found
No related tags found
No related merge requests found
......@@ -91,11 +91,8 @@ static const std::string DEFAULT_CLIENT_ID =
*/
ONCat_uptr ONCat::fromMantidSettings(bool authenticate) {
if (!authenticate) {
return Mantid::Kernel::make_unique<ONCat>(DEFAULT_ONCAT_URL,
nullptr,
OAuthFlow::NONE,
boost::none,
boost::none);
return Mantid::Kernel::make_unique<ONCat>(
DEFAULT_ONCAT_URL, nullptr, OAuthFlow::NONE, boost::none, boost::none);
}
auto &config = Mantid::Kernel::ConfigService::Instance();
......@@ -114,8 +111,7 @@ ONCat_uptr ONCat::fromMantidSettings(bool authenticate) {
}
return Mantid::Kernel::make_unique<ONCat>(
DEFAULT_ONCAT_URL,
Mantid::Kernel::make_unique<ConfigServiceTokenStore>(),
DEFAULT_ONCAT_URL, Mantid::Kernel::make_unique<ConfigServiceTokenStore>(),
hasClientCredentials ? OAuthFlow::CLIENT_CREDENTIALS
: OAuthFlow::RESOURCE_OWNER_CREDENTIALS,
hasClientCredentials ? client_id : DEFAULT_CLIENT_ID,
......@@ -186,9 +182,7 @@ bool ONCat::isUserLoggedIn() const {
return m_tokenStore->getToken().is_initialized();
}
std::string ONCat::url() const {
return m_url;
}
std::string ONCat::url() const { return m_url; }
void ONCat::logout() {
// Currently, ONCat OAuth does *not* allow clients to revoke tokens
......
......@@ -35,10 +35,10 @@ using Mantid::Catalog::OAuth::OAuthToken;
using Mantid::Catalog::ONCat::ONCat;
using Mantid::Catalog::ONCat::QueryParameter;
using Mantid::Kernel::Exception::InternetError;
using Mantid::Types::Core::DateAndTime;
using Mantid::TestHelpers::make_mock_oncat_api;
using Mantid::TestHelpers::make_mock_token_store;
using Mantid::TestHelpers::make_mock_token_store_already_logged_in;
using Mantid::Types::Core::DateAndTime;
//----------------------------------------------------------------------
// Helpers, Mocks and Variables
......@@ -204,8 +204,8 @@ public:
oncat.setInternetHelper(mock_oncat_api);
const auto entity = oncat.retrieve("api", "instruments", "HB2C",
{{"facility", "HFIR"}});
const auto entity =
oncat.retrieve("api", "instruments", "HB2C", {{"facility", "HFIR"}});
TS_ASSERT_EQUALS(entity.id(), std::string("HB2C"));
TS_ASSERT_EQUALS(entity.get<std::string>("name"), std::string("HB2C"));
......@@ -228,8 +228,8 @@ public:
oncat.setInternetHelper(mock_oncat_api);
const auto entity = oncat.retrieve("api", "instruments", "HB2C",
{{"facility", "HFIR"}});
const auto entity =
oncat.retrieve("api", "instruments", "HB2C", {{"facility", "HFIR"}});
TS_ASSERT_EQUALS(entity.id(), std::string("HB2C"));
TS_ASSERT_EQUALS(entity.get<std::string>("name"), std::string("HB2C"));
......@@ -286,9 +286,8 @@ public:
oncat.setInternetHelper(mock_oncat_api);
TS_ASSERT_THROWS(
oncat.list("api", "instruments", {{"facility", "HFIR"}}),
TokenRejectedError);
TS_ASSERT_THROWS(oncat.list("api", "instruments", {{"facility", "HFIR"}}),
TokenRejectedError);
TS_ASSERT(!oncat.isUserLoggedIn());
TS_ASSERT(mock_oncat_api->allResponsesCalledOnce());
......@@ -315,8 +314,7 @@ public:
oncat.setInternetHelper(mock_oncat_api);
oncat.retrieve("api", "instruments", "HB2C",
{{"facility", "HFIR"}});
oncat.retrieve("api", "instruments", "HB2C", {{"facility", "HFIR"}});
TS_ASSERT(mock_oncat_api->allResponsesCalledOnce());
......
......@@ -11,8 +11,8 @@
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/IArchiveSearch.h"
#include "MantidKernel/System.h"
#include "MantidCatalog/ONCat.h"
#include "MantidKernel/System.h"
#include <string>
......@@ -37,7 +37,7 @@ public:
//////////////////////////////////////////////////////////////////////
private:
ONCat_uptr m_oncat = nullptr;
ONCat_uptr m_oncat = nullptr;
};
} // namespace DataHandling
} // namespace Mantid
......
......@@ -32,7 +32,7 @@ using Mantid::Catalog::ONCat::QueryParameters;
namespace {
std::string toUpperCase(const std::string & s) {
std::string toUpperCase(const std::string &s) {
std::string result(s);
std::transform(s.begin(), s.end(), result.begin(), toupper);
return result;
......@@ -42,7 +42,7 @@ const static boost::regex FILE_REGEX("^(.*?)_(\\d+).*$");
const static std::string NOT_FOUND("");
Mantid::Kernel::Logger g_log("ORNLDataArchive");
}
} // namespace
namespace Mantid {
namespace DataHandling {
......@@ -96,9 +96,9 @@ DECLARE_ARCHIVESEARCH(ORNLDataArchive, ORNLDataSearch)
* @return The first matching location of an archived raw datafile, else an
* empty string.
*/
std::string
ORNLDataArchive::getArchivePath(const std::set<std::string> &basenames,
const std::vector<std::string> &suffixes) const {
std::string ORNLDataArchive::getArchivePath(
const std::set<std::string> &basenames,
const std::vector<std::string> &suffixes) const {
if (basenames.size() == 0) {
return NOT_FOUND;
}
......@@ -109,8 +109,8 @@ ORNLDataArchive::getArchivePath(const std::set<std::string> &basenames,
// Validate and parse the basename.
boost::smatch result;
if (!boost::regex_match(basename, result, FILE_REGEX)) {
g_log.debug() << "Unexpected input passed to getArchivePath():"
<< std::endl << basename << std::endl;
g_log.debug() << "Unexpected input passed to getArchivePath():" << std::endl
<< basename << std::endl;
return NOT_FOUND;
}
......@@ -136,13 +136,13 @@ ORNLDataArchive::getArchivePath(const std::set<std::string> &basenames,
// and run number, and *not* filtering by suffix at this point. (ONCat has
// a strict definition of what a file "extension" is, and has no way of
// filtering by, for example, "_event.nxs".)
const QueryParameters params {{"facility", facility},
{"instrument", instrument},
{"projection", "location"},
{"tags", "type/raw"},
{"sort_by", "ingested"},
{"sort_direction", "DESCENDING"},
{"ranges_q", "indexed.run_number:" + run}};
const QueryParameters params{{"facility", facility},
{"instrument", instrument},
{"projection", "location"},
{"tags", "type/raw"},
{"sort_by", "ingested"},
{"sort_direction", "DESCENDING"},
{"ranges_q", "indexed.run_number:" + run}};
// If we've not manually set up an ONCat instance (presumably for testing
// purposes) then we must instead create one using the settings in the
......@@ -151,7 +151,7 @@ ORNLDataArchive::getArchivePath(const std::set<std::string> &basenames,
// more information, but that would require users logging in and publically
// available information is more than enough for our purposes here, anyway.
auto defaultOncat = ONCat::fromMantidSettings();
auto * oncat = m_oncat ? m_oncat.get() : defaultOncat.get();
auto *oncat = m_oncat ? m_oncat.get() : defaultOncat.get();
const auto datafiles = [&]() {
try {
......@@ -170,7 +170,7 @@ ORNLDataArchive::getArchivePath(const std::set<std::string> &basenames,
}
g_log.debug() << "All datafiles returned from ONCat:" << std::endl;
for (const auto &datafile: datafiles) {
for (const auto &datafile : datafiles) {
g_log.debug() << datafile.toString() << std::endl;
}
......@@ -199,9 +199,7 @@ ORNLDataArchive::getArchivePath(const std::set<std::string> &basenames,
return NOT_FOUND;
}
void ORNLDataArchive::setONCat(ONCat_uptr oncat) {
m_oncat = std::move(oncat);
}
void ORNLDataArchive::setONCat(ONCat_uptr oncat) { m_oncat = std::move(oncat); }
} // namespace DataHandling
} // namespace Mantid
......@@ -10,9 +10,9 @@
#include <cxxtest/TestSuite.h>
#include "MantidAPI/ArchiveSearchFactory.h"
#include "MantidDataHandling/ORNLDataArchive.h"
#include "MantidCatalog/Exception.h"
#include "MantidCatalog/ONCat.h"
#include "MantidDataHandling/ORNLDataArchive.h"
#include "MantidKernel/Exception.h"
#include "MantidKernel/InternetHelper.h"
#include "MantidKernel/make_unique.h"
......@@ -41,16 +41,16 @@ public:
const auto generateRunUrl = [](const std::string &facility,
const std::string &instrument,
const std::string &runNumber) {
return std::string(
"https://oncat.ornl.gov/api/datafiles"
"?facility=") + facility +
"&instrument=" + instrument +
"&projection=location"
"&tags=type/raw"
"&sort_by=ingested"
"&sort_direction=DESCENDING"
"&ranges_q=indexed.run_number:" + runNumber;
const std::string &runNumber) {
return std::string("https://oncat.ornl.gov/api/datafiles"
"?facility=") +
facility + "&instrument=" + instrument +
"&projection=location"
"&tags=type/raw"
"&sort_by=ingested"
"&sort_direction=DESCENDING"
"&ranges_q=indexed.run_number:" +
runNumber;
};
auto mockAPI = make_mock_oncat_api(
......
......@@ -24,7 +24,7 @@ namespace {
std::vector<std::string> namesOfFacilitiesWithICAT() {
const auto &config = Kernel::ConfigService::Instance();
const auto facilityHasICAT = [&](std::string name){
const auto facilityHasICAT = [&](std::string name) {
return !config.getFacility(name).catalogInfo().soapEndPoint().empty();
};
......@@ -42,8 +42,7 @@ std::string defaultFacility() {
// empty string.
const auto facility = Kernel::ConfigService::Instance().getFacility().name();
const auto facilitiesWithICAT = namesOfFacilitiesWithICAT();
if (std::find(facilitiesWithICAT.begin(),
facilitiesWithICAT.end(),
if (std::find(facilitiesWithICAT.begin(), facilitiesWithICAT.end(),
facility) != facilitiesWithICAT.end()) {
return facility;
}
......@@ -54,7 +53,7 @@ std::string defaultFacility() {
return "";
}
}
} // namespace
/// Init method to declare algorithm properties
void CatalogLogin::init() {
......@@ -65,8 +64,7 @@ void CatalogLogin::init() {
declareProperty(Kernel::make_unique<Kernel::MaskedProperty<std::string>>(
"Password", "", requireValue),
"The password of the related username to use.");
declareProperty("FacilityName",
defaultFacility(),
declareProperty("FacilityName", defaultFacility(),
boost::make_shared<Kernel::StringListValidator>(
namesOfFacilitiesWithICAT()),
"Select a facility to log in to.");
......
......@@ -28,16 +28,14 @@ MockONCatAPI::MockONCatAPI(const MockResponseMap &responseMap)
MockONCatAPI::~MockONCatAPI() {}
bool MockONCatAPI::allResponsesCalledOnce() const {
return std::all_of(m_responseCallCounts.cbegin(),
m_responseCallCounts.cend(),
return std::all_of(m_responseCallCounts.cbegin(), m_responseCallCounts.cend(),
[](const MockResponseCallMapping &mapping) {
return mapping.second == 1;
});
}
bool MockONCatAPI::allResponsesCalled() const {
return std::all_of(m_responseCallCounts.cbegin(),
m_responseCallCounts.cend(),
return std::all_of(m_responseCallCounts.cbegin(), m_responseCallCounts.cend(),
[](const MockResponseCallMapping &mapping) {
return mapping.second >= 1;
});
......@@ -56,8 +54,7 @@ int MockONCatAPI::sendHTTPSRequest(const std::string &url,
// If the test that is using this has not set up a corresponding URL
// then throw an exception rather than segfault.
throw NotImplementedError(
url + " has not been assigned a corresponding response."
);
url + " has not been assigned a corresponding response.");
}
m_responseCallCounts[url] += 1;
......@@ -89,14 +86,11 @@ make_oncat_with_mock_api(const std::shared_ptr<MockONCatAPI> &mockAPI) {
MockTokenStore::MockTokenStore() : m_token(boost::none) {}
void MockTokenStore::setToken(
const boost::optional<OAuthToken> &token) {
void MockTokenStore::setToken(const boost::optional<OAuthToken> &token) {
m_token = token;
}
boost::optional<OAuthToken> MockTokenStore::getToken() {
return m_token;
}
boost::optional<OAuthToken> MockTokenStore::getToken() { return m_token; }
IOAuthTokenStore_uptr make_mock_token_store() {
return Mantid::Kernel::make_unique<MockTokenStore>();
......
......@@ -1579,8 +1579,10 @@ void ApplicationWindow::customMenu(MdiSubWindow *w) {
}
 
const auto &config = Mantid::Kernel::ConfigService::Instance();
const auto showCatalogMenu = !config.getFacility(
config.getFacility().name()).catalogInfo().soapEndPoint().empty();
const auto showCatalogMenu = !config.getFacility(config.getFacility().name())
.catalogInfo()
.soapEndPoint()
.empty();
 
if (showCatalogMenu) {
auto catalogMenuAction = myMenuBar()->addMenu(icat);
......
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