ChrisSamo632 edited a comment on pull request #5299:
URL: https://github.com/apache/nifi/pull/5299#issuecomment-912969553


   > Hi @ChrisSamo632
   > I don't understand where and how to preform those unit tests... All the 
unit tests I see are testing processor functionalities whereas the ones you 
requested are checking class ones
   > It's just that I'm not sure if I should create a new test file for 
AbstractElasticsearchHttpProcessor and there create a mock class inheriting it 
and then test and assert using Junit or do something else...
   > I would love some guidance here, thank you very much :)
   
   Probably got a few options, which you've already touched on in your question:
   * Create an `AbstractElasticsearchHttpProcessorTest.java` (or `.groovy`) 
class that tests the new `getESUrl` method with different inputs (e.g. a single 
URL, no URLs, multiple URLs with/without whitespaces that need trimming) and 
create a `MockElasticsearchHttpProcessor.java` class to use for the tests (see 
[TestAbstractKinesisRecordProcessor](https://github.com/apache/nifi/blob/main/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/kinesis/stream/record/TestAbstractKinesisRecordProcessor.java#L83)
 for such an example)
   * Create an `abstract` version of 
`AbstractElasticsearchHttpProcessorTest.java` with appropriate `@Test` methods 
and make this the super class of all the test classes for the processors that 
use the updated `AbstractElasticsearchHttpProcessor` class (e.g. 
`FetchElasticsearchHttpTest`), then we can also be sure that each of these 
processors is configured to use the new method too - this is the kind of 
approach I've taken in https://github.com/apache/nifi/pull/5193, for example
   
   I don't think there's necessarily a "right" way to do the tests, but I think 
it's possible without too much difficulty and therefore worthwhile


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to