Russ,

When you call setProperty, it's expecting a String value, so you don't want to 
set the value of
the property to `service2` but rather you'd set the property to the identifier 
for service2. For example:

runner.addControllerService( "service-id2", service2 );  // add service2 with 
an identifier of "service-id2"
runner.addControllerService( "foo", service1 );

runner.setProperty( service1, SERVICE_PROPERTY_DESCRIPTOR, "service-id2" ); // 
set property so that service1 has ID of service 2
runner.enableControllerService( service2 ); // enable service2 so that it can 
be used by service1
runner.enableControllerService( service1 ); // enable service1

Does that help?

Thanks
-Mark


> On May 15, 2017, at 3:31 PM, Russell Bateman <[email protected]> wrote:
> 
> I've written a controller service that depends on another controller service. 
> One of the properties in the first service builds itself using 
> .identifiesControllerService( Service2.class ), but no 
> .allowableValues()because it was unclear what to put.
> 
> In my test code, I'm struggling as to how to reflect this relationship.
> 
>   TestRunner runner = TestRunners.newTestRunner( SomeProcessor.class );
>   Service1 service1 = new Service1();
>   Service2 service2 = new Service2();
> 
>   runner.addControllerService( "foo",  service1 );
>   runner.setProperty( service1, ..., "" );              // typical
>   setProperty() call
>   *runner.setProperty( service1, ..., service2 );  // this won't
>   compile; it's not an allowable value*
> 
>   runner.enableControllerService( service1 );
>   runner.assertValid( service1 );
>   etc.
> 
> How is this really done?
> 
> Thanks.

Reply via email to