You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by sanjeet rath <ra...@gmail.com> on 2019/10/22 02:24:13 UTC

Unit test is getting failed for custom ,Awscredentialprovidercontrolerservice

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

Re: Unit test is getting failed for custom ,Awscredentialprovidercontrolerservice

Posted by sanjeet rath <ra...@gmail.com>.
Thanks Bryan, got ur point.
Now everything is working fine.


On Tue, 22 Oct, 2019, 7:46 PM Bryan Bende, <bb...@gmail.com> wrote:

> 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 <ot...@gmail.com>
> 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 (rath.sanjeet@gmail.com)
> 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
> >
>

Re: Unit test is getting failed for custom ,Awscredentialprovidercontrolerservice

Posted by Bryan Bende <bb...@gmail.com>.
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 <ot...@gmail.com> 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 (rath.sanjeet@gmail.com) 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
>

Re: Unit test is getting failed for custom ,Awscredentialprovidercontrolerservice

Posted by Otto Fowler <ot...@gmail.com>.
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 (rath.sanjeet@gmail.com)
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