[ https://issues.apache.org/jira/browse/COLLECTIONS-861?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniele updated COLLECTIONS-861: -------------------------------- Description: *CollectionUtils.select(Iterable, Predicate, Collection, Collection):* A ConcurrentModificationException can be thrown, but not signed in the specification, also "return the outputCollection" is ambiguous because outputCollection is a parameter and it seems like the method should return that parameter as it is, but in is modified inside the method. *Test used (generated by EvoSuite):* {code:java} /* * This file was automatically generated by EvoSuite * Sun May 05 21:09:14 GMT 2024 */ package org.apache.commons.collections4;import org.junit.Test; import static org.junit.Assert.*; import static shaded.org.evosuite.shaded.org.mockito.Mockito.*; import static shaded.org.evosuite.runtime.EvoAssertions.*; import java.util.Collection; import java.util.Comparator; import java.util.ConcurrentModificationException; import java.util.LinkedList; import java.util.PriorityQueue; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.UniquePredicate; import org.junit.runner.RunWith; import shaded.org.evosuite.runtime.EvoRunner; import shaded.org.evosuite.runtime.EvoRunnerParameters; import shaded.org.evosuite.runtime.ViolatedAssumptionAnswer;@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVNET = true, separateClassLoader = true) public class CollectionUtils_12_failure_Test extends CollectionUtils_12_failure_Test_scaffolding { @Test(timeout = 4000) public void testSelect_OutputCollection() throws Throwable { Comparator<? super Object> comparator0 = (Comparator<? super Object>) mock(Comparator.class, new ViolatedAssumptionAnswer()); doReturn(89).when(comparator0).compare(any(), any()); PriorityQueue<Object> priorityQueue0 = new PriorityQueue<Object>(comparator0); LinkedList<Object> linkedList0 = new LinkedList<Object>(); boolean boolean0 = priorityQueue0.add(linkedList0); UniquePredicate<Object> uniquePredicate0 = new UniquePredicate<Object>(); try { //** Guard on which the oracle of method select depends: true org.junit.Assume.assumeTrue(true); //** Precondition on which method select depends: (args[0]==null) == false && (args[1]==null) == false || (args[2]==null) == false org.junit.Assume.assumeTrue((((Iterable<?>) priorityQueue0) == null) == false && (((Predicate<? super Object>) uniquePredicate0) == null) == false || (((Collection<Object>) priorityQueue0) == null) == false); //** Precondition on which method select depends: (args[0]==null) == false || (args[1]==null) == false || (args[3]==null) == false org.junit.Assume.assumeTrue((((Iterable<?>) priorityQueue0) == null) == false || (((Predicate<? super Object>) uniquePredicate0) == null) == false || (((Collection<Object>) priorityQueue0) == null) == false); //** Automatically generated test oracle is: the outputCollection., with guard: { description: the outputCollection., conditionText: true } java.util.Collection<?> //** Automatically generated test oracle is: the outputCollection., with guard: { description: the outputCollection., conditionText: true } _methodResult__ = CollectionUtils.select((Iterable<?>) priorityQueue0, (Predicate<? super Object>) uniquePredicate0, (Collection<Object>) priorityQueue0, (Collection<Object>) priorityQueue0); //** Postcondition on which the oracle of method select depends: methodResultID.equals(args[2]) org.junit.Assert.assertTrue(_methodResult__.equals(((Collection<Object>) priorityQueue0))); } catch (ConcurrentModificationException e) { // // no message in exception (getMessage() returned null) // verifyException("java.util.PriorityQueue$Itr", e); org.junit.Assert.fail(); } if (true) throw new RuntimeException("Failure-driven test case completed without pinpointing any failure. This should not happen. Please check"); } } {code} *CollectionUtils.selectRejected(Iterable, Predicate, Collection):* A RuntimeException can be thrown, but not signed in the specification, also "return outputCollection" is ambiguous because outputCollection is a parameter and it seems like the method should return that parameter as it is, but in is modified inside the method. *Test used (generated by EvoSuite):* {code:java} /* * This file was automatically generated by EvoSuite * Sun May 05 21:09:36 GMT 2024 */package org.apache.commons.collections4; import org.junit.Test;import static org.junit.Assert.*;import static shaded.org.evosuite.shaded.org.mockito.Mockito.*;import static shaded.org.evosuite.runtime.EvoAssertions.*;import java.util.Collection;import java.util.LinkedList;import java.util.Vector;import org.apache.commons.collections4.CollectionUtils;import org.apache.commons.collections4.Predicate;import org.apache.commons.collections4.functors.ExceptionPredicate;import org.apache.commons.collections4.functors.NullIsExceptionPredicate;import org.junit.runner.RunWith;import shaded.org.evosuite.runtime.EvoRunner;import shaded.org.evosuite.runtime.EvoRunnerParameters;import shaded.org.evosuite.runtime.ViolatedAssumptionAnswer; @RunWith(EvoRunner.class)@EvoRunnerParameters(mockJVMNonDeterminism = true, useVNET = true, separateClassLoader = true)public class CollectionUtils_14_failure_Test extends CollectionUtils_14_failure_Test_scaffolding { //Covered goal: org.apache.commons.collections4.CollectionUtils.selectRejected(Ljava/lang/Iterable;Lorg/apache/commons/collections4/Predicate;Ljava/util/Collection;)Ljava/util/Collection;: true ---> methodResultID.equals(args[2]) -- path condition org.apache.commons.collections4.EvoSuiteEvaluator_14_failure (id = 7) @Test(timeout = 4000) public void testSelectRejected_OutputCollection() throws Throwable { Predicate<Object> predicate0 = ExceptionPredicate.exceptionPredicate(); NullIsExceptionPredicate<Object> nullIsExceptionPredicate0 = new NullIsExceptionPredicate<Object>(predicate0); LinkedList<Object> linkedList0 = new LinkedList<Object>(); Vector<Comparable<Object>> vector0 = new Vector<Comparable<Object>>(6935, 6935); Comparable<Object> comparable0 = (Comparable<Object>) mock(Comparable.class, new ViolatedAssumptionAnswer()); boolean boolean0 = vector0.add(comparable0); // Undeclared exception! try { //** Guard on which the oracle of method selectRejected depends: true org.junit.Assume.assumeTrue(true); //** Precondition on which method selectRejected depends: (args[2]==null) == false org.junit.Assume.assumeTrue((((Collection<Object>) linkedList0) == null) == false); //** Automatically generated test oracle is: outputCollection., with guard: { description: outputCollection., conditionText: true } java.util.Collection<?> //** Automatically generated test oracle is: outputCollection., with guard: { description: outputCollection., conditionText: true } _methodResult__ = CollectionUtils.selectRejected((Iterable<? extends Comparable<Object>>) vector0, (Predicate<? super Comparable<Object>>) nullIsExceptionPredicate0, (Collection<Object>) linkedList0); //** Postcondition on which the oracle of method selectRejected depends: methodResultID.equals(args[2]) org.junit.Assert.assertTrue(_methodResult__.equals(((Collection<Object>) linkedList0))); } catch (RuntimeException e) { // // ExceptionPredicate invoked // verifyException("org.apache.commons.collections4.functors.ExceptionPredicate", e); org.junit.Assert.fail(); } if (true) throw new RuntimeException("Failure-driven test case completed without pinpointing any failure. This should not happen. Please check"); }} {code} was: *CollectionUtils.select(Iterable, Predicate, Collection, Collection):* A ConcurrentModificationException can be thrown, but not signed in the specification, also "return the outputCollection" is ambiguous because outputCollection is a parameter and it seems like the method should return that parameter as it is, but in is modified inside the method. *Test used (generated by EvoSuite):* {code:java} /* * This file was automatically generated by EvoSuite * Sun May 05 21:09:14 GMT 2024 */ package org.apache.commons.collections4;import org.junit.Test; import static org.junit.Assert.*; import static shaded.org.evosuite.shaded.org.mockito.Mockito.*; import static shaded.org.evosuite.runtime.EvoAssertions.*; import java.util.Collection; import java.util.Comparator; import java.util.ConcurrentModificationException; import java.util.LinkedList; import java.util.PriorityQueue; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.functors.UniquePredicate; import org.junit.runner.RunWith; import shaded.org.evosuite.runtime.EvoRunner; import shaded.org.evosuite.runtime.EvoRunnerParameters; import shaded.org.evosuite.runtime.ViolatedAssumptionAnswer;@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVNET = true, separateClassLoader = true) public class CollectionUtils_12_failure_Test extends CollectionUtils_12_failure_Test_scaffolding { @Test(timeout = 4000) public void testSelect_OutputCollection() throws Throwable { Comparator<? super Object> comparator0 = (Comparator<? super Object>) mock(Comparator.class, new ViolatedAssumptionAnswer()); doReturn(89).when(comparator0).compare(any(), any()); PriorityQueue<Object> priorityQueue0 = new PriorityQueue<Object>(comparator0); LinkedList<Object> linkedList0 = new LinkedList<Object>(); boolean boolean0 = priorityQueue0.add(linkedList0); UniquePredicate<Object> uniquePredicate0 = new UniquePredicate<Object>(); // Undeclared exception! try { //** Guard on which the oracle of method select depends: true org.junit.Assume.assumeTrue(true); //** Precondition on which method select depends: (args[0]==null) == false && (args[1]==null) == false || (args[2]==null) == false org.junit.Assume.assumeTrue((((Iterable<?>) priorityQueue0) == null) == false && (((Predicate<? super Object>) uniquePredicate0) == null) == false || (((Collection<Object>) priorityQueue0) == null) == false); //** Precondition on which method select depends: (args[0]==null) == false || (args[1]==null) == false || (args[3]==null) == false org.junit.Assume.assumeTrue((((Iterable<?>) priorityQueue0) == null) == false || (((Predicate<? super Object>) uniquePredicate0) == null) == false || (((Collection<Object>) priorityQueue0) == null) == false); //** Automatically generated test oracle is: the outputCollection., with guard: { description: the outputCollection., conditionText: true } java.util.Collection<?> //** Automatically generated test oracle is: the outputCollection., with guard: { description: the outputCollection., conditionText: true } _methodResult__ = CollectionUtils.select((Iterable<?>) priorityQueue0, (Predicate<? super Object>) uniquePredicate0, (Collection<Object>) priorityQueue0, (Collection<Object>) priorityQueue0); //** Postcondition on which the oracle of method select depends: methodResultID.equals(args[2]) org.junit.Assert.assertTrue(_methodResult__.equals(((Collection<Object>) priorityQueue0))); } catch (ConcurrentModificationException e) { // // no message in exception (getMessage() returned null) // verifyException("java.util.PriorityQueue$Itr", e); org.junit.Assert.fail(); } if (true) throw new RuntimeException("Failure-driven test case completed without pinpointing any failure. This should not happen. Please check"); } } {code} *CollectionUtils.selectRejected(Iterable, Predicate, Collection):* A RuntimeException can be thrown, but not signed in the specification, also "return outputCollection" is ambiguous because outputCollection is a parameter and it seems like the method should return that parameter as it is, but in is modified inside the method. *Test used (generated by EvoSuite):* {code:java} /* * This file was automatically generated by EvoSuite * Sun May 05 21:09:36 GMT 2024 */package org.apache.commons.collections4; import org.junit.Test;import static org.junit.Assert.*;import static shaded.org.evosuite.shaded.org.mockito.Mockito.*;import static shaded.org.evosuite.runtime.EvoAssertions.*;import java.util.Collection;import java.util.LinkedList;import java.util.Vector;import org.apache.commons.collections4.CollectionUtils;import org.apache.commons.collections4.Predicate;import org.apache.commons.collections4.functors.ExceptionPredicate;import org.apache.commons.collections4.functors.NullIsExceptionPredicate;import org.junit.runner.RunWith;import shaded.org.evosuite.runtime.EvoRunner;import shaded.org.evosuite.runtime.EvoRunnerParameters;import shaded.org.evosuite.runtime.ViolatedAssumptionAnswer; @RunWith(EvoRunner.class)@EvoRunnerParameters(mockJVMNonDeterminism = true, useVNET = true, separateClassLoader = true)public class CollectionUtils_14_failure_Test extends CollectionUtils_14_failure_Test_scaffolding { //Covered goal: org.apache.commons.collections4.CollectionUtils.selectRejected(Ljava/lang/Iterable;Lorg/apache/commons/collections4/Predicate;Ljava/util/Collection;)Ljava/util/Collection;: true ---> methodResultID.equals(args[2]) -- path condition org.apache.commons.collections4.EvoSuiteEvaluator_14_failure (id = 7) @Test(timeout = 4000) public void testSelectRejected_OutputCollection() throws Throwable { Predicate<Object> predicate0 = ExceptionPredicate.exceptionPredicate(); NullIsExceptionPredicate<Object> nullIsExceptionPredicate0 = new NullIsExceptionPredicate<Object>(predicate0); LinkedList<Object> linkedList0 = new LinkedList<Object>(); Vector<Comparable<Object>> vector0 = new Vector<Comparable<Object>>(6935, 6935); Comparable<Object> comparable0 = (Comparable<Object>) mock(Comparable.class, new ViolatedAssumptionAnswer()); boolean boolean0 = vector0.add(comparable0); // Undeclared exception! try { //** Guard on which the oracle of method selectRejected depends: true org.junit.Assume.assumeTrue(true); //** Precondition on which method selectRejected depends: (args[2]==null) == false org.junit.Assume.assumeTrue((((Collection<Object>) linkedList0) == null) == false); //** Automatically generated test oracle is: outputCollection., with guard: { description: outputCollection., conditionText: true } java.util.Collection<?> //** Automatically generated test oracle is: outputCollection., with guard: { description: outputCollection., conditionText: true } _methodResult__ = CollectionUtils.selectRejected((Iterable<? extends Comparable<Object>>) vector0, (Predicate<? super Comparable<Object>>) nullIsExceptionPredicate0, (Collection<Object>) linkedList0); //** Postcondition on which the oracle of method selectRejected depends: methodResultID.equals(args[2]) org.junit.Assert.assertTrue(_methodResult__.equals(((Collection<Object>) linkedList0))); } catch (RuntimeException e) { // // ExceptionPredicate invoked // verifyException("org.apache.commons.collections4.functors.ExceptionPredicate", e); org.junit.Assert.fail(); } if (true) throw new RuntimeException("Failure-driven test case completed without pinpointing any failure. This should not happen. Please check"); }} {code} > Documentation Bug: CollectionUtils.select(Iterable, Predicate, Collection, > Collection), CollectionUtils.selectRejected(Iterable, Predicate, Collection) > ------------------------------------------------------------------------------------------------------------------------------------------------------- > > Key: COLLECTIONS-861 > URL: https://issues.apache.org/jira/browse/COLLECTIONS-861 > Project: Commons Collections > Issue Type: Bug > Reporter: Daniele > Priority: Minor > > *CollectionUtils.select(Iterable, Predicate, Collection, Collection):* > A ConcurrentModificationException can be thrown, but not signed in the > specification, also "return the outputCollection" is ambiguous because > outputCollection is a parameter and it seems like the method should return > that parameter as it is, but in is modified inside the method. > *Test used (generated by EvoSuite):* > {code:java} > /* * This file was automatically generated by EvoSuite * Sun May 05 > 21:09:14 GMT 2024 */ package org.apache.commons.collections4;import > org.junit.Test; import static org.junit.Assert.*; import static > shaded.org.evosuite.shaded.org.mockito.Mockito.*; import static > shaded.org.evosuite.runtime.EvoAssertions.*; import java.util.Collection; > import java.util.Comparator; import > java.util.ConcurrentModificationException; import java.util.LinkedList; > import java.util.PriorityQueue; import > org.apache.commons.collections4.CollectionUtils; import > org.apache.commons.collections4.Predicate; import > org.apache.commons.collections4.functors.UniquePredicate; import > org.junit.runner.RunWith; import shaded.org.evosuite.runtime.EvoRunner; > import shaded.org.evosuite.runtime.EvoRunnerParameters; import > shaded.org.evosuite.runtime.ViolatedAssumptionAnswer;@RunWith(EvoRunner.class) > @EvoRunnerParameters(mockJVMNonDeterminism = true, useVNET = true, > separateClassLoader = true) public class CollectionUtils_12_failure_Test > extends CollectionUtils_12_failure_Test_scaffolding { > @Test(timeout = 4000) public void testSelect_OutputCollection() throws > Throwable { Comparator<? super Object> comparator0 = (Comparator<? > super Object>) mock(Comparator.class, new ViolatedAssumptionAnswer()); > doReturn(89).when(comparator0).compare(any(), any()); > PriorityQueue<Object> priorityQueue0 = new > PriorityQueue<Object>(comparator0); LinkedList<Object> linkedList0 = > new LinkedList<Object>(); boolean boolean0 = > priorityQueue0.add(linkedList0); UniquePredicate<Object> > uniquePredicate0 = new UniquePredicate<Object>(); > try { //** Guard on which the oracle of method select depends: > true org.junit.Assume.assumeTrue(true); //** > Precondition on which method select depends: (args[0]==null) == false && > (args[1]==null) == false || (args[2]==null) == false > org.junit.Assume.assumeTrue((((Iterable<?>) priorityQueue0) == null) == false > && (((Predicate<? super Object>) uniquePredicate0) == null) == false || > (((Collection<Object>) priorityQueue0) == null) == false); //** > Precondition on which method select depends: (args[0]==null) == false || > (args[1]==null) == false || (args[3]==null) == false > org.junit.Assume.assumeTrue((((Iterable<?>) priorityQueue0) == null) == false > || (((Predicate<? super Object>) uniquePredicate0) == null) == false || > (((Collection<Object>) priorityQueue0) == null) == false); //** > Automatically generated test oracle is: the outputCollection., with guard: { > description: the outputCollection., conditionText: true } > java.util.Collection<?> //** Automatically generated test oracle is: the > outputCollection., with guard: { description: the outputCollection., > conditionText: true } _methodResult__ = > CollectionUtils.select((Iterable<?>) priorityQueue0, (Predicate<? super > Object>) uniquePredicate0, (Collection<Object>) priorityQueue0, > (Collection<Object>) priorityQueue0); //** Postcondition on which > the oracle of method select depends: methodResultID.equals(args[2]) > org.junit.Assert.assertTrue(_methodResult__.equals(((Collection<Object>) > priorityQueue0))); } catch (ConcurrentModificationException e) { > // // no message in exception (getMessage() returned null) > // verifyException("java.util.PriorityQueue$Itr", e); > org.junit.Assert.fail(); } if (true) > throw new RuntimeException("Failure-driven test case completed without > pinpointing any failure. This should not happen. Please check"); } } > {code} > *CollectionUtils.selectRejected(Iterable, Predicate, Collection):* > A RuntimeException can be thrown, but not signed in the specification, also > "return outputCollection" is ambiguous because outputCollection is a > parameter and it seems like the method should return that parameter as it is, > but in is modified inside the method. > *Test used (generated by EvoSuite):* > {code:java} > /* * This file was automatically generated by EvoSuite * Sun May 05 21:09:36 > GMT 2024 */package org.apache.commons.collections4; > import org.junit.Test;import static org.junit.Assert.*;import static > shaded.org.evosuite.shaded.org.mockito.Mockito.*;import static > shaded.org.evosuite.runtime.EvoAssertions.*;import > java.util.Collection;import java.util.LinkedList;import > java.util.Vector;import > org.apache.commons.collections4.CollectionUtils;import > org.apache.commons.collections4.Predicate;import > org.apache.commons.collections4.functors.ExceptionPredicate;import > org.apache.commons.collections4.functors.NullIsExceptionPredicate;import > org.junit.runner.RunWith;import shaded.org.evosuite.runtime.EvoRunner;import > shaded.org.evosuite.runtime.EvoRunnerParameters;import > shaded.org.evosuite.runtime.ViolatedAssumptionAnswer; > @RunWith(EvoRunner.class)@EvoRunnerParameters(mockJVMNonDeterminism = true, > useVNET = true, separateClassLoader = true)public class > CollectionUtils_14_failure_Test extends > CollectionUtils_14_failure_Test_scaffolding { > //Covered goal: > org.apache.commons.collections4.CollectionUtils.selectRejected(Ljava/lang/Iterable;Lorg/apache/commons/collections4/Predicate;Ljava/util/Collection;)Ljava/util/Collection;: > true ---> methodResultID.equals(args[2]) -- path condition > org.apache.commons.collections4.EvoSuiteEvaluator_14_failure (id = 7) > @Test(timeout = 4000) public void testSelectRejected_OutputCollection() > throws Throwable { Predicate<Object> predicate0 = > ExceptionPredicate.exceptionPredicate(); > NullIsExceptionPredicate<Object> nullIsExceptionPredicate0 = new > NullIsExceptionPredicate<Object>(predicate0); LinkedList<Object> > linkedList0 = new LinkedList<Object>(); Vector<Comparable<Object>> > vector0 = new Vector<Comparable<Object>>(6935, 6935); > Comparable<Object> comparable0 = (Comparable<Object>) mock(Comparable.class, > new ViolatedAssumptionAnswer()); boolean boolean0 = > vector0.add(comparable0); // Undeclared exception! try { > //** Guard on which the oracle of method selectRejected depends: true > org.junit.Assume.assumeTrue(true); //** Precondition on > which method selectRejected depends: (args[2]==null) == false > org.junit.Assume.assumeTrue((((Collection<Object>) linkedList0) == null) == > false); //** Automatically generated test oracle is: > outputCollection., with guard: { description: outputCollection., > conditionText: true } java.util.Collection<?> //** Automatically > generated test oracle is: outputCollection., with guard: { description: > outputCollection., conditionText: true } _methodResult__ = > CollectionUtils.selectRejected((Iterable<? extends Comparable<Object>>) > vector0, (Predicate<? super Comparable<Object>>) nullIsExceptionPredicate0, > (Collection<Object>) linkedList0); //** Postcondition on which the > oracle of method selectRejected depends: methodResultID.equals(args[2]) > org.junit.Assert.assertTrue(_methodResult__.equals(((Collection<Object>) > linkedList0))); } catch (RuntimeException e) { // > // ExceptionPredicate invoked // > verifyException("org.apache.commons.collections4.functors.ExceptionPredicate", > e); org.junit.Assert.fail(); } if (true) > throw new RuntimeException("Failure-driven test case completed without > pinpointing any failure. This should not happen. Please check"); }} {code} > -- This message was sent by Atlassian Jira (v8.20.10#820010)