2727#include " core/Resource.h"
2828#include " core/state/nodes/AgentInformation.h"
2929#include " core/ProcessorImpl.h"
30+ #include " range/v3/algorithm/find_if.hpp"
3031
3132using minifi::state::response::SerializedResponseNode;
3233
@@ -38,6 +39,25 @@ SerializedResponseNode& get(SerializedResponseNode& node, const std::string& fie
3839 throw std::logic_error (" No field '" + field + " '" );
3940}
4041
42+ namespace org ::apache::nifi::minifi::test::apple {
43+ class ExampleApacheService : public core ::controller::ControllerServiceBase, public core::controller::ControllerServiceHandle {
44+ public:
45+ using ControllerServiceBase::ControllerServiceBase;
46+
47+ void initialize () override {}
48+ void onEnable () override {}
49+
50+ [[nodiscard]] ControllerServiceHandle* getControllerServiceHandle () override { return this ; }
51+
52+ static constexpr const char * Description = " An example service" ;
53+ static constexpr auto Properties = std::array<core::PropertyReference, 0 >{};
54+ static constexpr bool SupportsDynamicProperties = false ;
55+ ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_CONTROLLER_SERVICES
56+ };
57+
58+ REGISTER_RESOURCE (ExampleApacheService, ControllerService);
59+ } // namespace org::apache::nifi::minifi::test::apple
60+
4161namespace test ::apple {
4262
4363class ExampleService : public core ::controller::ControllerServiceBase, public core::controller::ControllerServiceHandle {
@@ -67,7 +87,12 @@ class ExampleProcessor : public core::ProcessorImpl {
6787 .isRequired(false )
6888 .withAllowedTypes<ExampleService>()
6989 .build();
70- static constexpr auto Properties = std::to_array<core::PropertyReference>({ExampleProperty});
90+ static constexpr auto ExampleApacheProperty = core::PropertyDefinitionBuilder<>::createProperty(" Example Apache Property" )
91+ .withDescription(" An example property" )
92+ .isRequired(false )
93+ .withAllowedTypes<org::apache::nifi::minifi::test::apple::ExampleApacheService>()
94+ .build();
95+ static constexpr auto Properties = std::to_array<core::PropertyReference>({ExampleProperty, ExampleApacheProperty});
7196 static constexpr auto Relationships = std::array<core::RelationshipDefinition, 0 >{};
7297 static constexpr bool SupportsDynamicProperties = false ;
7398 static constexpr bool SupportsDynamicRelationships = false ;
@@ -93,27 +118,38 @@ TEST_CASE("Manifest indicates property type requirement") {
93118
94119 auto & processors = get (nodes.at (0 ), " processors" ).children ;
95120
96- auto example_proc_it = std::find_if (processors.begin (), processors.end (), [&] (auto & proc) {
121+ auto example_proc_it = std::find_if (processors.begin (), processors.end (), [&](auto & proc) {
97122 return get (proc, " type" ).value == " test.apple.ExampleProcessor" ;
98123 });
99124 REQUIRE (example_proc_it != processors.end ());
100125
101126 auto & properties = get (*example_proc_it, " propertyDescriptors" ).children ;
102127
103- auto prop_it = std::find_if (properties.begin (), properties.end (), [&] (auto & prop) {
104- return get (prop, " name" ).value == " Example Property" ;
105- });
128+ {
129+ auto prop_it = std::find_if (properties.begin (), properties.end (), [&](auto & prop) { return get (prop, " name" ).value == " Example Property" ; });
130+
131+ REQUIRE (prop_it != properties.end ());
106132
107- REQUIRE (prop_it != properties.end ());
133+ // TODO(adebreceni): based on Property::types_ a property could accept
134+ // multiple types, these would be dumped into the same object as the type of
135+ // field "typeProvidedByValue" is not an array but an object
136+ auto & type = get (*prop_it, " typeProvidedByValue" );
108137
109- // TODO(adebreceni): based on Property::types_ a property could accept
110- // multiple types, these would be dumped into the same object as the type of
111- // field "typeProvidedByValue" is not an array but an object
112- auto & type = get (*prop_it, " typeProvidedByValue" );
138+ CHECK (get (type, " type" ).value == " test.apple.ExampleService" );
139+ CHECK (get (type, " group" ).value == " test.apple" );
140+ CHECK (get (type, " artifact" ).value == " minifi-system" );
141+ }
142+ {
143+ auto prop_it = ranges::find_if (properties, [&](auto & prop) { return get (prop, " name" ).value == " Example Apache Property" ; });
144+ REQUIRE (prop_it != properties.end ());
113145
114- REQUIRE (get (type, " type" ).value == " test.apple.ExampleService" );
115- REQUIRE (get (type, " group" ).value == " test.apple" );
116- REQUIRE (get (type, " artifact" ).value == " minifi-system" );
146+ auto & type = get (*prop_it, " typeProvidedByValue" );
147+
148+ CHECK (get (type, " type" ).value == " org.apache.nifi.minifi.test.apple.ExampleApacheService" );
149+ // Backward compatibility test, if the group starts with org.apache.nifi.minifi we use that
150+ CHECK (get (type, " group" ).value == " org.apache.nifi.minifi" );
151+ CHECK (get (type, " artifact" ).value == " minifi-system" );
152+ }
117153}
118154
119155TEST_CASE (" Processors do not get instantiated during manifest creation" ) {
0 commit comments