pouryafard75 / RM-ASTDiff

MIT License
2 stars 1 forks source link

Match method call with method reference #83

Closed tsantalis closed 9 months ago

tsantalis commented 1 year ago

https://github.com/apache/kafka/commit/913a019d6c9b03eb44706deb7fb164f79c1f601f#diff-8be2ce40c210584b1895e2dcec0949876b8da1b65fa3a8e3ebf80123f4e5efb3 clients/src/test/java/org/apache/kafka/common/record/ByteBufferLogInputStreamTest.java

@pouryafard75 Is it possible to support this kind of match? logInputStream.nextBatch() -> logInputStream::nextBatch

Screenshot from 2023-05-27 23-33-18

tsantalis commented 1 year ago

clients/src/test/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinatorTest.java

Screenshot from 2023-05-28 00-13-26

tsantalis commented 1 year ago

clients/src/test/java/org/apache/kafka/common/record/DefaultRecordBatchTest.java

for (Record record: batch) {
    record.isValid();
}
batch.forEach(Record::isValid)

Screenshot from 2023-05-30 13-07-51

pouryafard75 commented 1 year ago

Fixed after c579b49451d85539b33d8f24e04c788277def049. Annotations were also fixed after f7f8cd2992338a59239143df4007bd7e5f4d4920. @tsantalis

image
pouryafard75 commented 1 year ago

@tsantalis @victorgveloso

This case can be further improved by mapping the expected value inside the @test annotation with the first argument of the assertThrows().

victorgveloso commented 1 year ago

If the existing implementation results in an Annotation Added refactoring, my implementation at https://github.com/tsantalis/RefactoringMiner/pull/225 would do that.

That looks for matching type literals between the value in @Test(expected=) MemberValuePair and the first assertThrows parameter.

However, @tsantalis claimed to add a native detection for assertThrows which should be more precise than my implementation and may address this particular problem @pouryafard75 spotted.

tsantalis commented 1 year ago

@pouryafard75 I fixed the matching of the expected value inside the annotation with the first argument of the assertThrows() but I don't get the method reference name matched.

Was this feature in one of the recent PRs? Screenshot from 2023-06-08 22-33-23

pouryafard75 commented 1 year ago

Replicated at https://github.com/pouryafard75/TestCases/commit/562c4447a566170ac28872a88b323669a82db5c9 to enhance the testability.