You shouldn't be modifying the service code to make the test pass. You need to set whatever properties are needed to make it valid by using Runner.setProperty(service, property name, value)
On Tue, Oct 22, 2019 at 6:54 AM Otto Fowler <[email protected]> wrote: > > https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/credentials/provider/service/AWSCredentialsProviderControllerServiceTest.java > > It may be helpful for you to look at other things in the code base. Here are > the tests for the current service > > > > > On October 21, 2019 at 22:31:38, sanjeet rath ([email protected]) wrote: > > Hi Team, > > Our project structure we have a custom controller service > ,Awscredentialprovidercontrolerservice controller service to connect AWS > with our defined 5 attributes means properties.(This is present in a separate > project NIFI-AWS-CUSTOM_PING_CONTROLER). > > In NiFi UI this controller service is working fine .But in Unit testing I am > using bellow code to test. > > @Test > public void test Awscredentialprovidercontrolerservice() { > > final TestRunner runner = TestRunners.newTestRunner(new puts3Object); > final Awscredentialprovidercontrolerservice serviceimpl= new > Awscredentialprovidercontrolerservice() > Runner.setproperty(…) //Setting my 5 properties which I have created for my > custom controller service > Runner.enablecontrolerservice(serviceimpl) > // will do assert } > > Here in enabling controller service gives null pointer exception in the > custom validate method , its excepting all the default Properties also need > to be declared like Accesskey, secret key etc(which is present in the default > Awscredentialprovidercontrolerservice class) in my custom controller > Awscredentialprovidercontrolerservice. > > After declaring the default properties in my custom > Awscredentialprovidercontrolerservice unit test is working fine.But problem > is these parameters are appearing in the NiFi UI of my custom > Awscredentialprovidercontrolerservice. > > So I have 2 option, either after declaring of the default properties, is > there any way to stop displaying I Nifi UI. > > Or As its working fine in UI flow without setting default properties in > custom Awscredentialprovidercontrolerservice.so should I set something in > Unit test case to make it passed > > Thanks & Regards > -- > Sanjeet Kumar Rath, > mob- +91 8777577470 >
