@Test public void testCalculateParameterArrayWhenInputArrayIsNotNullAndContainsRealDatas() throws IOException { String[] firstRow = new String[]{"first"}; String[] secondRow = new String[]{"second"}; Whitebox.setInternalState(underTest, "multiplier", 2); Whitebox.setInternalState(underTest, "arrayLoader", arrayLoader); Whitebox.setInternalState(underTest, "environment", environment); environment.setProperty(Environment.GEPARD_DATA_DRIVEN_PATH_BASE, new File("src/test/resources").getAbsolutePath()); given(arrayLoader.loadFile(Mockito.any(ConfigFileInfo.class), eq(2))).willReturn(parameterArray); given(parameterArray.isEmpty()).willReturn(false); given(parameterArray.size()).willReturn(2); given(parameterArray.get(0)).willReturn(firstRow); given(parameterArray.get(1)).willReturn(secondRow); given(parameterArray.getParameterNames()).willReturn(secondRow); DataDrivenParameterArray inputArray = new DataDrivenParameterArray(); inputArray.setParameterNames(firstRow); inputArray.put(1, firstRow); inputArray.put(2, secondRow); DataDrivenParameterArray actual = underTest.calculateParameterArray("TestClass", inputArray); Object[] actualValues = actual.values().toArray(); Object[] expectedValues = new Object[]{new String[]{"first", "first"}, new String[]{"second", "first"}, new String[]{"first", "second"}, new String[]{"second", "second"}}; Assert.assertEquals(firstRow[0], actual.getParameterNames()[0]); Assert.assertEquals(secondRow[0], actual.getParameterNames()[1]); for (int i = 0; i < actualValues.length; i++) { Assert.assertArrayEquals(expectedValues, actualValues); } }
@Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray myArray = null; FileProvider fileProvider = new FileProvider(); try { myArray = loadTestParameters(className, fileProvider, arrayLoader); } catch (IOException | IllegalArgumentException e) { String error = "ERROR: During the load of: " + className + ", param file caused EX.\nReason:" + e.getMessage() + "\nCheck both testlist.txt and class.txt/csv file, Now exiting...\n"; DataFeederLoader.reportException(error, e); myArray = null; } catch (DataFeederException e) { myArray = null; } DataDrivenParameterArray newArray = null; if (myArray != null) { newArray = recalculateTheParentArray(inputParameterArray, myArray); } return newArray; }
SimpleMultiplierDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray myArray = null; FileProvider fileProvider = new FileProvider(); try { myArray = loadTestParameters(className, fileProvider, arrayLoader); } catch (IOException | IllegalArgumentException e) { String error = "ERROR: During the load of: " + className + ", param file caused EX.\nReason:" + e.getMessage() + "\nCheck both testlist.txt and class.txt/csv file, Now exiting...\n"; DataFeederLoader.reportException(error, e); myArray = null; } catch (DataFeederException e) { myArray = null; } DataDrivenParameterArray newArray = null; if (myArray != null) { newArray = recalculateTheParentArray(inputParameterArray, myArray); } return newArray; } }
SimpleMultiplierDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray myArray = null; FileProvider fileProvider = new FileProvider(); try { myArray = loadTestParameters(className, fileProvider, arrayLoader); } catch (IOException | IllegalArgumentException e) { String error = "ERROR: During the load of: " + className + ", param file caused EX.\nReason:" + e.getMessage() + "\nCheck both testlist.txt and class.txt/csv file, Now exiting...\n"; DataFeederLoader.reportException(error, e); myArray = null; } catch (DataFeederException e) { myArray = null; } DataDrivenParameterArray newArray = null; if (myArray != null) { newArray = recalculateTheParentArray(inputParameterArray, myArray); } return newArray; }  }
SimpleMultiplierDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray myArray = null; FileProvider fileProvider = new FileProvider(); try { myArray = loadTestParameters(className, fileProvider, arrayLoader); } catch (IOException | IllegalArgumentException e) { String error = "ERROR: During the load of: " + className + ", param file caused EX.\nReason:" + e.getMessage() + "\nCheck both testlist.txt and class.txt/csv file, Now exiting...\n"; DataFeederLoader.reportException(error, e); myArray = null; } catch (DataFeederException e) { myArray = null; } DataDrivenParameterArray newArray = null; if (myArray != null) { newArray = recalculateTheParentArray(inputParameterArray, myArray); } 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); }
SimpleMultiplierDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray myArray = null; FileProvider fileProvider = new FileProvider(); try { myArray = loadTestParameters(className, fileProvider, arrayLoader); } catch (IOException | IllegalArgumentException e) { String error = "ERROR: During the load of: " + className + ", param file caused EX.\nReason:" + e.getMessage() + "\nCheck both testlist.txt and class.txt/csv file, Now exiting...\n"; DataFeederLoader.reportException(error, e); myArray = null; } catch (DataFeederException e) { myArray = null; } DataDrivenParameterArray newArray = null; if (myArray != null) { newArray = recalculateTheParentArray(inputParameterArray, myArray); } 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);  }