<?xml version="1.0" encoding="UTF-8"?>
<test-data
    xmlns="http://pmd.sourceforge.net/rule-tests"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
    <test-code>
        <description><![CDATA[
failure case
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Bar {
 void foo() {
  Integer[] ints = new Integer(10); 
  List l= new ArrayList(10); 
  for (int i=0; i< 100; i++) { 
   l.add(ints[i]); 
  } 
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
adding first element repeatedly
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Bar {
 void foo() {
  Integer[] ints = new Integer(10); 
  List l= new ArrayList(10); 
  for (int i=0; i< 100; i++) { 
   l.add(ints[1]); 
  } 
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
inside conditional
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Bar {
 void foo() {
  Integer[] ints = new Integer(10); 
  List l= new ArrayList(10); 
  for (int i=0; i< 100; i++) { 
   if (y > 10) { l.add(ints[1]);} 
  } 
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
adding new object
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Bar {
 void foo() {
  Integer[] ints = new Integer(10); 
  List l= new ArrayList(10); 
  for (int i=0; i< 100; i++) { 
   l.add(new Integer(i+1)); 
  } 
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
calling method
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Bar {
 void foo() {
  Integer[] ints = new Integer(10); 
  List l= new ArrayList(10); 
  for (int i=0; i< 100; i++) { 
   l.add(String.valueOf(i)); 
  } 
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description>Integer array passed as argument</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Test {
  public void foo(Integer[] ints) {
     // could just use Arrays.asList(ints)
     List l = new ArrayList(10);
     for (int i=0; i< 100; i++) {
       l.add(ints[i]);
     }
     for (int i=0; i< 100; i++) {
       l.add(a[i].toString()); // won't trigger the rule
     }
  }
}
        ]]></code>
    </test-code>
    <test-code>
        <description>#1099 UseArraysAsList false positives</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Test {
  public void foo() {
      String [] result = new String[10000];
      // some code which populates result

      // copy n items from result to a List, such that resultList[i] = result[i+1]
      List<String> resultList = new ArrayList<String>();
      for (int i = 1; i <= n; i++) {
          resultList.add(result[i]);
      }
  }
}
        ]]></code>
    </test-code>
</test-data>
