[
https://issues.apache.org/jira/browse/COLLECTIONS-862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17890989#comment-17890989
]
Gary D. Gregory commented on COLLECTIONS-862:
---------------------------------------------
[~ferra]
The first does not compile.
The second test just shows you've misinterpreted the Java which says: "@throws
NullPointerException if the output collection is null and both, input Iterator
and transformer are not null"
Is is AI or machine generated GIGO?
See my comments in your other tickets on the proper way to assert exceptions in
tests.
> Bug CollectionUtils.collect(Iterable<? extends ?>, Transformer<? super ?, ?
> extends ? extends TransformerClosure<Object>>, LinkedList<Object>) and
> CollectionUtils.collect(Iterator<? extends ?>, Transformer<? super ?, ?
> extends ?>, Collection<Object>)
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: COLLECTIONS-862
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-862
> Project: Commons Collections
> Issue Type: Bug
> Reporter: Daniele
> Priority: Minor
>
> *CollectionUtils.collect(Iterable<? extends ?>, Transformer<? super ?, ?
> extends ? extends TransformerClosure<Object>>, LinkedList<Object>):*
> If args[2] is null and both, args[0] and args[1] are not null, the method
> does not throw any NullPointerException, although the specification says it
> does.
> *Test Used:*
> {code:java}
> public class CollectionUtils_16_failure_Test{
>
> public void
> testCollect_NullPointerException_OutputCollectionIsNullAndInputCollectionAndTransformerAreNotNull()
> throws Throwable {
> Stack<Predicate<Object>> stack0 = new Stack<Predicate<Object>>();
> Transformer<Object, TransformerClosure<Object>> transformer0 =
> InvokerTransformer.invokerTransformer("", (Class<?>[]) classArray0,
> (Object[]) classArray0);
> try {
> LinkedList<Object> linkedList0 =
> CollectionUtils.collect((Iterable<?>) stack0, (Transformer<? super Object, ?
> extends TransformerClosure<Object>>) transformer0, (LinkedList<Object>) null);
> org.junit.Assert.fail();
> } catch (java.lang.NullPointerException _e__) {
> }
> }
> }
> {code}
>
> *CollectionUtils.collect(Iterator<? extends ?>, Transformer<? super ?, ?
> extends ?>, Collection<Object>):*
> If args[2] is null and both, args[0] and args[1] are not null, the method
> does not throw any NullPointerException, although the specification says it
> does.
> *Test Used:*
> {code:java}
> public class CollectionUtils_17_failure_Test{
>
> public void
> testCollect_NullPointerException_OutputCollectionIsNullAndInputIteratorAndTransformerAreNotNull()
> throws Throwable {
> Transformer<Object, Object> transformer0 =
> InvokerTransformer.invokerTransformer("4s4F;4u$", (Class<?>[]) null,
> (Object[]) null);
> TreeSet<Object> treeSet0 = new TreeSet<Object>();
> Iterator<Object> iterator0 = treeSet0.iterator();
> try {
> Collection<Object> collection0 =
> CollectionUtils.collect((Iterator<?>) iterator0, (Transformer<? super Object,
> ?>) transformer0, (Collection<Object>) null);
> org.junit.Assert.fail();
> } catch (java.lang.NullPointerException _e__) {
> }
> }
> } {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)