lordgamez commented on code in PR #1503: URL: https://github.com/apache/nifi-minifi-cpp/pull/1503#discussion_r1108569955
########## controller/tests/ControllerTests.cpp: ########## @@ -0,0 +1,479 @@ +/** + * + * 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. + */ +#include <vector> +#include <memory> +#include <utility> +#include <string> +#include <filesystem> +#include "TestBase.h" +#include "Catch.h" +#include "io/ClientSocket.h" +#include "core/Processor.h" +#include "Controller.h" +#include "c2/ControllerSocketProtocol.h" +#include "utils/IntegrationTestUtils.h" +#include "c2/ControllerSocketMetricsPublisher.h" +#include "core/controller/ControllerServiceProvider.h" +#include "controllers/SSLContextService.h" + +#include "state/UpdateController.h" + +using namespace std::literals::chrono_literals; + +namespace org::apache::nifi::minifi::test { + +class TestStateController : public minifi::state::StateController { + public: + TestStateController() + : is_running(false) { + } + + std::string getComponentName() const override { + return "TestStateController"; + } + + minifi::utils::Identifier getComponentUUID() const override { + static auto dummyUUID = minifi::utils::Identifier::parse("12345678-1234-1234-1234-123456789abc").value(); + return dummyUUID; + } + + int16_t start() override { + is_running = true; + return 0; + } + + int16_t stop() override { + is_running = false; + return 0; + } + + bool isRunning() const override { + return is_running; + } + + int16_t pause() override { + return 0; + } + + int16_t resume() override { + return 0; + } + + std::atomic<bool> is_running; +}; + +class TestUpdateSink : public minifi::state::StateMonitor { + public: + explicit TestUpdateSink(std::shared_ptr<StateController> controller) + : is_running(true), + clear_calls(0), + controller(std::move(controller)), + update_calls(0) { + } + + void executeOnComponent(const std::string&, std::function<void(minifi::state::StateController&)> func) override { + func(*controller); + } + + void executeOnAllComponents(std::function<void(minifi::state::StateController&)> func) override { + func(*controller); + } + + std::string getComponentName() const override { + return "TestUpdateSink"; + } + + minifi::utils::Identifier getComponentUUID() const override { + static auto dummyUUID = minifi::utils::Identifier::parse("12345678-1234-1234-1234-123456789abc").value(); + return dummyUUID; + } + + int16_t start() override { + is_running = true; + return 0; + } + + int16_t stop() override { + is_running = false; + return 0; + } + + bool isRunning() const override { + return is_running; + } + + int16_t pause() override { + return 0; + } + + int16_t resume() override { + return 0; + } + std::vector<BackTrace> getTraces() override { + std::vector<BackTrace> traces; + return traces; + } + + int16_t drainRepositories() override { + return 0; + } + + std::map<std::string, std::unique_ptr<minifi::io::InputStream>> getDebugInfo() override { + return {}; + } + + int16_t clearConnection(const std::string& /*connection*/) override { + clear_calls++; + return 0; + } + + int16_t applyUpdate(const std::string& /*source*/, const std::string& /*configuration*/, bool /*persist*/ = false, const std::optional<std::string>& /*flow_id*/ = std::nullopt) override { + update_calls++; + return 0; + } + + int16_t applyUpdate(const std::string& /*source*/, const std::shared_ptr<minifi::state::Update>& /*updateController*/) override { + return 0; Review Comment: I think we should, I suppose this overload was unused in the tests, so the stub was not implemented for it, updated in 2a82c349ac8f334e2a3f49640f136b26e0b7ce23 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
