package ie.lero.evoting.test.data;

import election.tally.AbstractBallotCounting;
import election.tally.AbstractCountStatus;
import election.tally.Ballot;
import election.tally.BallotBox;
import election.tally.BallotCounting;
import election.tally.Candidate;
import election.tally.Constituency;
import election.tally.Decision;

public class TestDataGenerator {
 
  // Singletons
  private static final BallotCounting BALLOT_COUNTING = new BallotCounting();
  private static final BallotBox BALLOT_BOX = new BallotBox();

  public static AbstractBallotCounting getAbstractBallotCounting(int n) {
    return BALLOT_COUNTING;
  }

  public static byte[] getByteArray() {
    return new byte[0];
  }

  public static Constituency getConstituency(int n) {
    return new Constituency();
  }

  public static Ballot getBallot(int preferenceID) {
    int[] list = new int[1];
    list[0] = preferenceID;
    return new Ballot(list);
  }

  public static Candidate getCandidate(int n) {
    return new Candidate();
  }

  public static BallotBox getBallotBox(int n) {
    return BALLOT_BOX;
  }

  public static int[] getIntArray() {
    return new int[0];
  }

  public static long[] getLongArray() {
    return new long[0];
  }

  public static Decision getDecision(int n) {
    return new Decision();
  }

  public static BallotCounting getBallotCounting(int n) {
    return BALLOT_COUNTING;
  }

  public static Object[] getIntArrayAsObject() {
    return new Object[0];
  }

  public static AbstractCountStatus getAbstractCountStatus(int n) {
    BallotCounting ballotCounting = BALLOT_COUNTING;
    return ballotCounting.getCountStatus();
  }
}

@@ -29,16 +29,45 @@
 .data;%0A%0A
+import java.util.ArrayList;%0A%0A
 import e
@@ -96,32 +96,32 @@
 BallotCounting;%0A
-
 import election.
@@ -541,16 +541,113 @@
 otBox();
+%0A  %0A  // Dynamic Arrays%0A  static ArrayList%3CCandidate%3E candidateList = new ArrayList%3CCandidate%3E();
 %0A%0A  publ
@@ -1106,29 +1106,121 @@
     
-return new Candidate(
+while (candidateList.size() %3C n) %7B%0A      candidateList.add(new Candidate());%0A    %7D%0A    return candidateList.get(n
 );%0A 
@@ -1263,32 +1263,47 @@
 lotBox(int n) %7B%0A
+    // default%0A
     return BALLO
@@ -1503,29 +1503,377 @@
     
-return new Decision()
+final Decision decision = new Decision();%0A    switch (n) %7B%0A      case 1: decision.setDecisionType(Decision.DEEM_ELECTED); %0A      case 2: decision.setDecisionType(Decision.EXCLUDE); break;%0A      default: decision.setDecisionType(Decision.NO_DECISION);%0A    %7D%0A    decision.setCountNumber(n);%0A    decision.setCandidate(getCandidate(n).getCandidateID());%0A    return decision
 ;%0A  
@@ -1925,32 +1925,47 @@
 unting(int n) %7B%0A
+    // default%0A
     return BALLO
@@ -2038,28 +2038,68 @@
     
-return new Object%5B0%5D
+final Object%5B%5D intArray = new Object%5B0%5D;%0A    return intArray
 ;%0A  
@@ -2177,82 +2177,45 @@
     
-BallotCounting ballotCounting = BALLOT_COUNTING;%0A    return ballotCounting
+// default%0A    return BALLOT_COUNTING
 .get

Use dynamic array to manage list of test candidates and avoid duplication of test objects in memory.