This is an automated email from the ASF dual-hosted git repository. adebreceni pushed a commit to branch minifi-api-reduced in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit ff80ed560ca972e4f930ff1ccac34c5ceb57053d Author: Adam Debreceni <[email protected]> AuthorDate: Mon Apr 28 11:37:14 2025 +0200 Rebase fix --- extensions/gcp/tests/DeleteGCSObjectTests.cpp | 2 +- extensions/gcp/tests/FetchGCSObjectTests.cpp | 2 +- extensions/gcp/tests/ListGCSBucketTests.cpp | 2 +- extensions/gcp/tests/PutGCSObjectTests.cpp | 2 +- libminifi/test/libtest/unit/ProcessorUtils.h | 46 +++++++++++++++++++++++++++ libminifi/test/libtest/unit/TestUtils.h | 22 +------------ 6 files changed, 51 insertions(+), 25 deletions(-) diff --git a/extensions/gcp/tests/DeleteGCSObjectTests.cpp b/extensions/gcp/tests/DeleteGCSObjectTests.cpp index f4498d730..bde7e010f 100644 --- a/extensions/gcp/tests/DeleteGCSObjectTests.cpp +++ b/extensions/gcp/tests/DeleteGCSObjectTests.cpp @@ -22,7 +22,7 @@ #include "google/cloud/storage/testing/mock_client.h" #include "google/cloud/storage/internal/object_metadata_parser.h" #include "google/cloud/storage/testing/canonical_errors.h" -#include "unit/TestUtils.h" +#include "unit/ProcessorUtils.h" namespace gcs = ::google::cloud::storage; namespace minifi_gcp = org::apache::nifi::minifi::extensions::gcp; diff --git a/extensions/gcp/tests/FetchGCSObjectTests.cpp b/extensions/gcp/tests/FetchGCSObjectTests.cpp index c233f8d67..ea87c7e63 100644 --- a/extensions/gcp/tests/FetchGCSObjectTests.cpp +++ b/extensions/gcp/tests/FetchGCSObjectTests.cpp @@ -22,7 +22,7 @@ #include "google/cloud/storage/testing/mock_client.h" #include "google/cloud/storage/internal/object_metadata_parser.h" #include "google/cloud/storage/testing/canonical_errors.h" -#include "unit/TestUtils.h" +#include "unit/ProcessorUtils.h" namespace gcs = ::google::cloud::storage; namespace minifi_gcp = org::apache::nifi::minifi::extensions::gcp; diff --git a/extensions/gcp/tests/ListGCSBucketTests.cpp b/extensions/gcp/tests/ListGCSBucketTests.cpp index e0b435a13..16b2c8dad 100644 --- a/extensions/gcp/tests/ListGCSBucketTests.cpp +++ b/extensions/gcp/tests/ListGCSBucketTests.cpp @@ -21,7 +21,7 @@ #include "google/cloud/storage/testing/mock_client.h" #include "google/cloud/storage/internal/object_metadata_parser.h" #include "google/cloud/storage/testing/canonical_errors.h" -#include "unit/TestUtils.h" +#include "unit/ProcessorUtils.h" namespace gcs = ::google::cloud::storage; namespace minifi_gcp = org::apache::nifi::minifi::extensions::gcp; diff --git a/extensions/gcp/tests/PutGCSObjectTests.cpp b/extensions/gcp/tests/PutGCSObjectTests.cpp index f099b3d77..ee7c26ca3 100644 --- a/extensions/gcp/tests/PutGCSObjectTests.cpp +++ b/extensions/gcp/tests/PutGCSObjectTests.cpp @@ -24,7 +24,7 @@ #include "google/cloud/storage/internal/object_metadata_parser.h" #include "google/cloud/storage/retry_policy.h" #include "google/cloud/storage/testing/canonical_errors.h" -#include "unit/TestUtils.h" +#include "unit/ProcessorUtils.h" namespace gcs = ::google::cloud::storage; namespace minifi_gcp = org::apache::nifi::minifi::extensions::gcp; diff --git a/libminifi/test/libtest/unit/ProcessorUtils.h b/libminifi/test/libtest/unit/ProcessorUtils.h new file mode 100644 index 000000000..36a270d9d --- /dev/null +++ b/libminifi/test/libtest/unit/ProcessorUtils.h @@ -0,0 +1,46 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include "core/Processor.h" +#include "minifi-cpp/core/ProcessorMetadata.h" + +namespace org::apache::nifi::minifi::test::utils { + +template<typename T> +std::unique_ptr<core::Processor> make_processor(std::string_view name, std::optional<minifi::utils::Identifier> uuid = std::nullopt) { + if (!uuid) { + uuid = minifi::utils::IdGenerator::getIdGenerator()->generate(); + } + auto processor_impl = std::make_unique<T>(core::ProcessorMetadata{ + .uuid = uuid.value(), + .name = std::string{name}, + .logger = minifi::core::logging::LoggerFactory<T>::getLogger(uuid.value()) + }); + return std::make_unique<core::Processor>(name, uuid.value(), std::move(processor_impl)); +} + +template<typename T, typename ...Args> +std::unique_ptr<core::Processor> make_custom_processor(Args&&... args) { + auto processor_impl = std::make_unique<T>(std::forward<Args>(args)...); + auto name = processor_impl->getName(); + auto uuid = processor_impl->getUUID(); + return std::make_unique<core::Processor>(name, uuid, std::move(processor_impl)); +} + +} // namespace org::apache::nifi::minifi::test::utils \ No newline at end of file diff --git a/libminifi/test/libtest/unit/TestUtils.h b/libminifi/test/libtest/unit/TestUtils.h index ff3b435a3..83e9bce23 100644 --- a/libminifi/test/libtest/unit/TestUtils.h +++ b/libminifi/test/libtest/unit/TestUtils.h @@ -41,6 +41,7 @@ #include "range/v3/algorithm/any_of.hpp" #include "core/Processor.h" #include "core/logging/LoggerFactory.h" +#include "./ProcessorUtils.h" using namespace std::literals::chrono_literals; @@ -233,27 +234,6 @@ inline bool runningAsUnixRoot() { #endif } -template<typename T> -std::unique_ptr<core::Processor> make_processor(std::string_view name, std::optional<minifi::utils::Identifier> uuid = std::nullopt) { - if (!uuid) { - uuid = minifi::utils::IdGenerator::getIdGenerator()->generate(); - } - auto processor_impl = std::make_unique<T>(core::ProcessorMetadata{ - .uuid = uuid.value(), - .name = std::string{name}, - .logger = minifi::core::logging::LoggerFactory<T>::getLogger(uuid.value()) - }); - return std::make_unique<core::Processor>(name, uuid.value(), std::move(processor_impl)); -} - -template<typename T, typename ...Args> -std::unique_ptr<core::Processor> make_custom_processor(Args&&... args) { - auto processor_impl = std::make_unique<T>(std::forward<Args>(args)...); - auto name = processor_impl->getName(); - auto uuid = processor_impl->getUUID(); - return std::make_unique<core::Processor>(name, uuid, std::move(processor_impl)); -} - } // namespace org::apache::nifi::minifi::test::utils namespace Catch {
