martinzink commented on code in PR #1457:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1457#discussion_r1067899983


##########
libminifi/test/Utils.h:
##########
@@ -183,33 +188,57 @@ bool sendMessagesViaSSL(const 
std::vector<std::string_view>& contents,
   asio::error_code err;
   socket.lowest_layer().connect(remote_endpoint, err);
   if (err) {
-    return false;
+    return err;
   }
   socket.handshake(asio::ssl::stream_base::client, err);
   if (err) {
-    return false;
+    return err;
   }
   for (auto& content : contents) {
     std::string tcp_message(content);
     tcp_message += '\n';
     asio::write(socket, asio::buffer(tcp_message, tcp_message.size()), err);
     if (err) {
-      return false;
+      return err;
     }
   }
-  return true;
+  return std::error_code();
 }
 
 #ifdef WIN32
 inline std::error_code hide_file(const std::filesystem::path& file_name) {
-    const bool success = SetFileAttributesA(file_name.string().c_str(), 
FILE_ATTRIBUTE_HIDDEN);
-    if (!success) {
-      // note: All possible documented error codes from GetLastError are in 
[0;15999] at the time of writing.
-      // The below casting is safe in [0;std::numeric_limits<int>::max()], int 
max is guaranteed to be at least 32767
-      return { static_cast<int>(GetLastError()), std::system_category() };
-    }
-    return {};
+  const bool success = SetFileAttributesA(file_name.string().c_str(), 
FILE_ATTRIBUTE_HIDDEN);
+  if (!success) {
+    // note: All possible documented error codes from GetLastError are in 
[0;15999] at the time of writing.
+    // The below casting is safe in [0;std::numeric_limits<int>::max()], int 
max is guaranteed to be at least 32767
+    return { static_cast<int>(GetLastError()), std::system_category() };
   }
+  return {};
+}
 #endif /* WIN32 */
 
+template<typename T>
+concept DerivedFromProcessor = std::derived_from<T, minifi::core::Processor>;  
// NOLINT(readability/braces)
+
+template<typename T>
+concept HasPortProperty = requires(T x) { {T::Port} -> 
std::convertible_to<core::Property>; };  // NOLINT(readability/braces)
+
+template<typename T>
+concept HasGetPortFn = requires(T x) { {x.getPort()} -> 
std::convertible_to<uint16_t>; };  // NOLINT(readability/braces)
+
+template<class T>
+requires DerivedFromProcessor<T> && HasPortProperty<T> && HasGetPortFn<T>
+uint16_t scheduleProcessorOnRandomPort(const std::shared_ptr<TestPlan>& 
test_plan, const std::shared_ptr<T>& processor) {

Review Comment:
   Good idea, I've added your suggestion (slightly changed it because the 
NOLINTBEGIN NOLINTEND doesnt seemed to work, and also its not clang tidy but 
our cpplint.py that doesnt play well with concepts.
   I found the problem in the linter script so ill will create a PR for it in 
https://github.com/cpplint/cpplint/blob/develop/cpplint.py and/or update our 
version



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to