| 66 | } |
| 67 | |
| 68 | std::shared_ptr<core::Processor> TestPlan::addProcessor(const std::shared_ptr<core::Processor> &processor, const std::string& /*name*/, const std::initializer_list<core::Relationship>& relationships, |
| 69 | bool linkToPrevious) { |
| 70 | if (finalized) { |
| 71 | return nullptr; |
| 72 | } |
| 73 | std::lock_guard<std::recursive_mutex> guard(mutex); |
| 74 | |
| 75 | utils::Identifier uuid = utils::IdGenerator::getIdGenerator()->generate(); |
| 76 | |
| 77 | processor->setStreamFactory(stream_factory); |
| 78 | // initialize the processor |
| 79 | processor->initialize(); |
| 80 | processor->setFlowIdentifier(flow_version_->getFlowIdentifier()); |
| 81 | |
| 82 | processor_mapping_[processor->getUUID()] = processor; |
| 83 | |
| 84 | if (!linkToPrevious) { |
| 85 | termination_ = *(relationships.begin()); |
| 86 | } else { |
| 87 | std::shared_ptr<core::Processor> last = processor_queue_.back(); |
| 88 | |
| 89 | if (last == nullptr) { |
| 90 | last = processor; |
| 91 | termination_ = *(relationships.begin()); |
| 92 | } |
| 93 | |
| 94 | std::stringstream connection_name; |
| 95 | connection_name << last->getUUIDStr() << "-to-" << processor->getUUIDStr(); |
| 96 | logger_->log_info("Creating %s connection for proc %d", connection_name.str(), processor_queue_.size() + 1); |
| 97 | std::shared_ptr<minifi::Connection> connection = std::make_shared<minifi::Connection>(flow_repo_, content_repo_, connection_name.str()); |
| 98 | |
| 99 | for (const auto& relationship : relationships) { |
| 100 | connection->addRelationship(relationship); |
| 101 | } |
| 102 | |
| 103 | // link the connections so that we can test results at the end for this |
| 104 | connection->setSource(last); |
| 105 | connection->setDestination(processor); |
| 106 | |
| 107 | connection->setSourceUUID(last->getUUID()); |
| 108 | connection->setDestinationUUID(processor->getUUID()); |
| 109 | last->addConnection(connection); |
| 110 | if (last != processor) { |
| 111 | processor->addConnection(connection); |
| 112 | } |
| 113 | relationships_.push_back(connection); |
| 114 | } |
| 115 | |
| 116 | std::shared_ptr<core::ProcessorNode> node = std::make_shared<core::ProcessorNode>(processor); |
| 117 | |
| 118 | processor_nodes_.push_back(node); |
| 119 | |
| 120 | // std::shared_ptr<core::ProcessContext> context = std::make_shared<core::ProcessContext>(node, controller_services_provider_, prov_repo_, flow_repo_, configuration_, content_repo_); |
| 121 | |
| 122 | auto contextBuilder = core::ClassLoader::getDefaultClassLoader().instantiate<core::ProcessContextBuilder>("ProcessContextBuilder"); |
| 123 | |
| 124 | contextBuilder = contextBuilder->withContentRepository(content_repo_)->withFlowFileRepository(flow_repo_)->withProvider(controller_services_provider_.get())->withProvenanceRepository(prov_repo_)->withConfiguration(configuration_); |
| 125 |
no test coverage detected