Genericise test util functions

This commit is contained in:
Chris Smowton
2021-06-29 12:27:03 +01:00
parent 60126b406f
commit 71f6d59646

View File

@@ -45,11 +45,11 @@ import org.springframework.util.SystemPropertyUtils;
// Test case generated by GenerateFlowTestCase.ql
public class Test {
Object getArrayElement(Object[] container) { return container[0]; }
Object getElement(Collection container) { return container.iterator().next(); }
Object getElement(Iterator container) { return container.next(); }
Object getMapKey(Map container) { return container.keySet().iterator().next(); }
Object getMapValue(Map container) { return container.get(null); }
<E> E getArrayElement(E[] container) { return container[0]; }
<E> E getElement(Collection<E> container) { return container.iterator().next(); }
<E> E getElement(Iterator<E> container) { return container.next(); }
<K, V> K getMapKey(Map<K, V> container) { return container.keySet().iterator().next(); }
<K, V> V getMapValue(Map<K, V> container) { return container.get(null); }
Object[] newWithArrayElement(Object element) { return new Object[] {element}; }
Properties newPropertiesWithMapKey(Object element) { Properties p = new Properties(); p.put(element, null); return p; }
Properties newPropertiesWithMapValue(Object element) { Properties p = new Properties(); p.put(null, element); return p; }
@@ -192,7 +192,7 @@ public class Test {
{
// "org.springframework.util;CollectionUtils;false;arrayToList;;;ArrayElement of Argument[0];Element of ReturnValue;value"
List out = null;
Object in = (Object)newWithArrayElement(source());
Object[] in = newWithArrayElement(source());
out = CollectionUtils.arrayToList(in);
sink(getElement(out)); // $hasValueFlow
}
@@ -248,7 +248,7 @@ public class Test {
{
// "org.springframework.util;CollectionUtils;false;mergeArrayIntoCollection;;;ArrayElement of Argument[0];Element of Argument[1];value"
Collection out = null;
Object in = (Object)newWithArrayElement(source());
Object[] in = newWithArrayElement(source());
CollectionUtils.mergeArrayIntoCollection(in, out);
sink(getElement(out)); // $hasValueFlow
}
@@ -721,7 +721,7 @@ public class Test {
{
// "org.springframework.util;ObjectUtils;false;toObjectArray;;;ArrayElement of Argument[0];ArrayElement of ReturnValue;value"
Object[] out = null;
Object in = (Object)newWithArrayElement(source());
Object[] in = newWithArrayElement(source());
out = ObjectUtils.toObjectArray(in);
sink(getArrayElement(out)); // $hasValueFlow
}