[ 
https://issues.apache.org/jira/browse/NIFI-14153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17912613#comment-17912613
 ] 

Daniel Stieglitz edited comment on NIFI-14153 at 1/13/25 10:21 PM:
-------------------------------------------------------------------

I discovered that this rule does have some limitations. These are the 
limitations I noticed even though Intellij actually flags them:
 * This rule does not discover cases where assertTrue can be simplified with 
assertArrayEquals e.g. TestSchemaRecordReaderWriter on line 155.
 * This rule does not discover cases where assertTrue(someObject instanceof 
someClass) can be replaced with assertInstanceOf e.g. AuthorizerFactoryTest 
line 266.
 * This rule does not discover cases where 
assertTrue(someClass.isIstanceof(someObject)) could be replaced with 
assertInstanceOf. e.g. TestAvroTypeUtil lines 913 and 914.

 

For all three of the above cases I manually searched for these cases and made 
appropriate replacements.


was (Author: JIRAUSER294662):
It seems that this rule does not catch when assertTrue can be simplified to 
assertArrayEquals e.g. TestSchemaRecordReaderWriter on line 155 although in 
Intellij it flags this.

 

TODO must manually search for

assertTrue(Arrays\.equals and replace the assertTrue with assertArrayEquals.

 

Also this rule does not seem to pick up with assertTrue(someObject instanceof 
someClass);

which should be replaced with assertInstanceOf as Intellij suggests

e.g. AuthorizerFactoryTest line 266

TODO must manually search for

assertTrue(.*instanceof and replace them with  assertInstanceOf 

 

Another item not picked up is assertTrue(someClass.isIstanceof(someObject)) 
which should be replaced with assertInstanceOf as Intellij suggests e.g. 
TestAvroTypeUtil line 913 and 914.

TODO must manually search for assertTrue
(.*isInstance and replace with assertInstanceOf.

> Apply PMD's SimplifiableTestAssertion across the code base
> ----------------------------------------------------------
>
>                 Key: NIFI-14153
>                 URL: https://issues.apache.org/jira/browse/NIFI-14153
>             Project: Apache NiFi
>          Issue Type: Improvement
>            Reporter: Daniel Stieglitz
>            Assignee: Daniel Stieglitz
>            Priority: Minor
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to