Hi Team, please help me with the trailed mail issue.i got stuck here.
Thanks & Regards sanjeet On Fri, 18 Oct, 2019, 10:02 PM sanjeet rath, <[email protected]> wrote: > Hi , > > While testing a controller service (Awscredentialprovidercontrolerservice) > i am getting IlligalStateException, > in the runner.enablecontrolerService(...) , when i am removing LINE3 code > i am getting null pointer exception in the useStratergy value(in the custom > validate). > What i have annalysed the properties list, i am getting all the > properties values that are present in the default > Awscredentialprovidercontrolerservice class. > It should have my properties list which i have defined in the custom > Awscredentialprovidercontrolerservice class. > > > code: > @Test > public void testAwscredentialprovidercontrolerservice() { > final TestRunner runner = TestRunners.newTestRunner(puts3Object.class); > Final Awscredentialprovidercontrolerservice serviceImpl = new > Awscredentialprovidercontrolerservice() > Runner.setProperty(..) > > #LINE3#runner.setProperty(serviceImpl,AbstractAWSCredentialsProviderProcessor.AWS_CREDENTIALS_PROVIDER_SERVICE,"awsCredsProviderService"); > runner.enablecontrolerService(serviceImpl) > } > > In the custom Awscredentialprovidercontrolerservice I have added , > > public static final PropertyDescriptor AWS_CONTROLER_SERVICE = new > PropertyDescriptor.Builder() > .name(“AWS Service") > .description("Specified the SSL Context Service that can be used to > create secure connections") > .required(true) > .identifiesControllerService(Awscredentialprovidercontrolerservice > .class) > > Thanks, > Sanjeet > > > On Thu, 17 Oct, 2019, 11:42 PM Bryan Bende, <[email protected]> wrote: > >> You should be able use mockito (or any other mocking framework), >> something like... >> >> AWSCredentialsProviderService service = >> Mockito.mock(AWSCredentialsProviderService.class) >> //setup whatever you want the mock to do >> >> runner.setProperty(service, >> AbstractAWSCredentialsProviderProcessor.AWS_CREDENTIALS_PROVIDER_SERVICE, >> "awsCredsProviderService"); >> runner.enableControllerService(service); >> >> On Thu, Oct 17, 2019 at 1:54 PM sanjeet rath <[email protected]> >> wrote: >> > >> > Thanks a lot bryan , for helping me to identify proper UNIT testing. >> > I will go with ur suggestion, will write unit testing for custom >> > controlerservice and separate for custom processor service. >> > If possible Can u give me a example of mock the >> > AWSCredentialsProviderService interface. >> > >> > Regards, >> > sanjeet >> > >> > On Thu, Oct 17, 2019 at 9:41 PM Bryan Bende <[email protected]> wrote: >> > >> > > Please only email one list, removing users... >> > > >> > > The AWS processors depend on an interface called >> > > AWSCredentialsProviderService. The unit test of the processor should >> > > not need to depend on real implementations of this interface, >> > > otherwise it is really an integration test of multiple components. >> > > >> > > I would suggest testing your processor and service separately... the >> > > processor test can mock the AWSCredentialsProviderService interface. >> > > >> > > >> > > On Thu, Oct 17, 2019 at 11:50 AM sanjeet rath <[email protected] >> > >> > > wrote: >> > > > >> > > > Hi Team, >> > > > >> > > > I am new to this community, today i have joined and this is my first >> > > query.(already from last 15 days i got stuck here) >> > > > >> > > > I have build a nifi custom processor.to put a object in AWS s3 >> > > bucket.(Just Modified Puts3Object processor in NIFI- AWS-PROCESSOR >> project) >> > > > In this processor Awscredentialprovidercontrolerservice is the >> default >> > > one to connect AWS. >> > > > >> > > > But our project structure we have a custom controller service >> > > ,Awscredentialprovidercontrolerservice controller service to connect >> AWS >> > > with our defined attributes.(This is present in a separate project >> > > NIFI-AWS-CUSTOM_PING_CONTROLER) >> > > > I want to use this custom controller service , instead of the >> default >> > > Awscredentialprovidercontrolerservice one which is present in the >> NIFI- >> > > AWS-PROCESSOR project >> > > > >> > > > My question is I want to do the unit testing (Using JUnit & >> Mockito) to >> > > validate this custom Awscredentialprovidercontrolerservice is working >> or >> > > not like if I get invalid bucket name then test case should failed. >> > > > >> > > > My code structure: >> > > > @Test >> > > > public void testRetryLogin() { >> > > > final TestRunner runner = TestRunners.newTestRunner(new >> > > puts3Object); >> > > > final Awscredentialprovidercontrolerservice serviceimpl= new >> > > Awscredentialprovidercontrolerservice() >> > > > Runner.setproperty(…) >> > > > Runner.enablecontrolerservice(serviceimpl) >> > > > runner.run(); >> > > > // will do assert } >> > > > >> > > > This gives me compiler error in error in >> > > Awscredentialprovidercontrolerservice instance creation line as custom >> > > controller service project is not available to this processor service >> > > project. If we add dependency in pom file to make it available then >> it will >> > > be circular dependency. >> > > > Because already in custom controlerservice pom file , custom >> processor >> > > is already added in dependency.. >> > > > >> > > > Thanks in advance :) >> > > > >> > > > -- >> > > > Sanjeet Kumar Rath, >> > > > mob- +91 8777577470 >> > > > >> > > >> > >> > >> > -- >> > Sanjeet Kumar Rath, >> > mob- +91 8777577470 >> >
