@Test public void testCalculateParameterArray() { Whitebox.setInternalState(underTest, "multiplier", 2); String[] expectedParameterNames = new String[]{"MULTIPLIER"}; DataDrivenParameterArray testArray = new DataDrivenParameterArray(); String[] parameterNames = new String[1]; parameterNames[0] = "MULTIPLIER"; testArray.setParameterNames(parameterNames); String[] firstRow = new String[1]; firstRow[0] = "something"; testArray.put(0, firstRow); DataDrivenParameterArray actual = underTest.calculateParameterArray("com.epam.test.TestClass", testArray); String[] actualParameterNames = actual.getParameterNames(); for (int i = 0; i < actualParameterNames.length; i++) { Assert.assertEquals(expectedParameterNames[i], actualParameterNames[i]); } int i = 1; for (String[] original : actual.values()) { String[] expectedRow = new String[original.length]; expectedRow[0] = firstRow[0] + " - #" + i; Assert.assertEquals(expectedRow[0], original[0]); i++; } }
@Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray transferArray = inputParameterArray; if (transferArray == null) { transferArray = new DataDrivenParameterArray(); String[] parameterNames = new String[1]; parameterNames[0] = "MULTIPLIER"; transferArray.setParameterNames(parameterNames); String[] newRow = new String[1]; newRow[0] = ""; transferArray.put(0, newRow); } DataDrivenParameterArray newArray = new DataDrivenParameterArray(); Integer arrayKey = 0; for (int i = 1; i <= multiplier; i++) { for (String[] original : transferArray.values()) { String[] newRow = new String[original.length]; System.arraycopy(original, 0, newRow, 0, original.length); newRow[0] = original[0] + " - #" + i; newArray.put(arrayKey, newRow); arrayKey++; } } newArray.setParameterNames(transferArray.getParameterNames()); return newArray; }
BruteMultiplierDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray transferArray = inputParameterArray; if (transferArray == null) { transferArray = new DataDrivenParameterArray(); String[] parameterNames = new String[1]; parameterNames[0] = "MULTIPLIER"; transferArray.setParameterNames(parameterNames); String[] newRow = new String[1]; newRow[0] = ""; transferArray.put(0, newRow); } DataDrivenParameterArray newArray = new DataDrivenParameterArray(); Integer arrayKey = 0; for (int i = 1; i <= multiplier; i++) { for (String[] original : transferArray.values()) { String[] newRow = new String[original.length]; System.arraycopy(original, 0, newRow, 0, original.length); newRow[0] = original[0] + " - #" + i; newArray.put(arrayKey, newRow); arrayKey++; } } newArray.setParameterNames(transferArray.getParameterNames()); return newArray; } }
BruteMultiplierDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray transferArray = inputParameterArray; if (transferArray == null) { transferArray = new DataDrivenParameterArray(); String[] parameterNames = new String[1]; parameterNames[0] = "MULTIPLIER"; transferArray.setParameterNames(parameterNames); String[] newRow = new String[1]; newRow[0] = ""; transferArray.put(0, newRow); } DataDrivenParameterArray newArray = new DataDrivenParameterArray(); Integer arrayKey = 0; for (int i = 1; i <= multiplier; i++) { for (String[] original : transferArray.values()) { String[] newRow = new String[original.length]; System.arraycopy(original, 0, newRow, 0, original.length); newRow[0] = original[0] + " - #" + i; newArray.put(arrayKey, newRow); arrayKey++; } } newArray.setParameterNames(transferArray.getParameterNames()); return newArray; }  }
BruteMultiplierDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray transferArray = inputParameterArray; if (transferArray == null) { transferArray = new DataDrivenParameterArray(); String[] parameterNames = new String[1]; parameterNames[0] = "MULTIPLIER"; transferArray.setParameterNames(parameterNames); String[] newRow = new String[1]; newRow[0] = ""; transferArray.put(0, newRow); } DataDrivenParameterArray newArray = new DataDrivenParameterArray(); Integer arrayKey = 0; for (int i = 1; i <= multiplier; i++) { for (String[] original : transferArray.values()) { String[] newRow = new String[original.length]; System.arraycopy(original, 0, newRow, 0, original.length); newRow[0] = original[0] + " - #" + i; newArray.put(arrayKey, newRow); arrayKey++; } } newArray.setParameterNames(transferArray.getParameterNames()); return newArray; }  @Override int init(final String testClassName, final String parameter, final Environment environment); @Override int calculateRuns(final String className, final int inputRows); @Override DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray); }
BruteMultiplierDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray transferArray = inputParameterArray; if (transferArray == null) { transferArray = new DataDrivenParameterArray(); String[] parameterNames = new String[1]; parameterNames[0] = "MULTIPLIER"; transferArray.setParameterNames(parameterNames); String[] newRow = new String[1]; newRow[0] = ""; transferArray.put(0, newRow); } DataDrivenParameterArray newArray = new DataDrivenParameterArray(); Integer arrayKey = 0; for (int i = 1; i <= multiplier; i++) { for (String[] original : transferArray.values()) { String[] newRow = new String[original.length]; System.arraycopy(original, 0, newRow, 0, original.length); newRow[0] = original[0] + " - #" + i; newArray.put(arrayKey, newRow); arrayKey++; } } newArray.setParameterNames(transferArray.getParameterNames()); return newArray; }  @Override int init(final String testClassName, final String parameter, final Environment environment); @Override int calculateRuns(final String className, final int inputRows); @Override DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray);  }