@Test public void testCalculateParameterArrayWhenSelectedRowIsGreaterThenInputArraySize() { Whitebox.setInternalState(underTest, "selectedRow", 5); DataDrivenParameterArray testArray = new DataDrivenParameterArray(); String[] parameterNames = new String[1]; parameterNames[0] = "something"; testArray.setParameterNames(parameterNames); String[] firstRow = new String[1]; firstRow[0] = "oneRow"; testArray.put(0, firstRow); DataDrivenParameterArray actual = underTest.calculateParameterArray("com.epam.test.TestClass", testArray); Assert.assertNull(actual); }
@Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray myArray = new DataDrivenParameterArray(); if (inputParameterArray == null) { String error = "PARAMETER ERROR: During the load of: " + className + " no input received to SingleRowSelectorDataFeeder class." + "\nCheck both testlist.txt and class.txt/csv file, Now exiting..."; DataFeederLoader.reportError(error); myArray = null; } if ((myArray != null) && (selectedRow > inputParameterArray.size())) { String error = "PARAMETER ERROR: During the load of: " + className + " cannot select the requested row." + "\nRequested: " + selectedRow + ", available: " + inputParameterArray.size() + "\nCheck both testlist.txt and class.txt/csv file, Now exiting..."; DataFeederLoader.reportError(error); myArray = null; } if (myArray != null) { String[] selectedRowArray = inputParameterArray.get(Integer.valueOf(selectedRow - 1)); myArray.put(0, selectedRowArray); myArray.setParameterNames(inputParameterArray.getParameterNames()); } return myArray; }
SingleRowSelectorDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray myArray = new DataDrivenParameterArray(); if (inputParameterArray == null) { String error = "PARAMETER ERROR: During the load of: " + className + " no input received to SingleRowSelectorDataFeeder class." + "\nCheck both testlist.txt and class.txt/csv file, Now exiting..."; DataFeederLoader.reportError(error); myArray = null; } if ((myArray != null) && (selectedRow > inputParameterArray.size())) { String error = "PARAMETER ERROR: During the load of: " + className + " cannot select the requested row." + "\nRequested: " + selectedRow + ", available: " + inputParameterArray.size() + "\nCheck both testlist.txt and class.txt/csv file, Now exiting..."; DataFeederLoader.reportError(error); myArray = null; } if (myArray != null) { String[] selectedRowArray = inputParameterArray.get(Integer.valueOf(selectedRow - 1)); myArray.put(0, selectedRowArray); myArray.setParameterNames(inputParameterArray.getParameterNames()); } return myArray; } }
SingleRowSelectorDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray myArray = new DataDrivenParameterArray(); if (inputParameterArray == null) { String error = "PARAMETER ERROR: During the load of: " + className + " no input received to SingleRowSelectorDataFeeder class." + "\nCheck both testlist.txt and class.txt/csv file, Now exiting..."; DataFeederLoader.reportError(error); myArray = null; } if ((myArray != null) && (selectedRow > inputParameterArray.size())) { String error = "PARAMETER ERROR: During the load of: " + className + " cannot select the requested row." + "\nRequested: " + selectedRow + ", available: " + inputParameterArray.size() + "\nCheck both testlist.txt and class.txt/csv file, Now exiting..."; DataFeederLoader.reportError(error); myArray = null; } if (myArray != null) { String[] selectedRowArray = inputParameterArray.get(Integer.valueOf(selectedRow - 1)); myArray.put(0, selectedRowArray); myArray.setParameterNames(inputParameterArray.getParameterNames()); } return myArray; }  }
SingleRowSelectorDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray myArray = new DataDrivenParameterArray(); if (inputParameterArray == null) { String error = "PARAMETER ERROR: During the load of: " + className + " no input received to SingleRowSelectorDataFeeder class." + "\nCheck both testlist.txt and class.txt/csv file, Now exiting..."; DataFeederLoader.reportError(error); myArray = null; } if ((myArray != null) && (selectedRow > inputParameterArray.size())) { String error = "PARAMETER ERROR: During the load of: " + className + " cannot select the requested row." + "\nRequested: " + selectedRow + ", available: " + inputParameterArray.size() + "\nCheck both testlist.txt and class.txt/csv file, Now exiting..."; DataFeederLoader.reportError(error); myArray = null; } if (myArray != null) { String[] selectedRowArray = inputParameterArray.get(Integer.valueOf(selectedRow - 1)); myArray.put(0, selectedRowArray); myArray.setParameterNames(inputParameterArray.getParameterNames()); } return myArray; }  @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); }
SingleRowSelectorDataFeeder implements GepardDataFeeder { @Override public DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray) { DataDrivenParameterArray myArray = new DataDrivenParameterArray(); if (inputParameterArray == null) { String error = "PARAMETER ERROR: During the load of: " + className + " no input received to SingleRowSelectorDataFeeder class." + "\nCheck both testlist.txt and class.txt/csv file, Now exiting..."; DataFeederLoader.reportError(error); myArray = null; } if ((myArray != null) && (selectedRow > inputParameterArray.size())) { String error = "PARAMETER ERROR: During the load of: " + className + " cannot select the requested row." + "\nRequested: " + selectedRow + ", available: " + inputParameterArray.size() + "\nCheck both testlist.txt and class.txt/csv file, Now exiting..."; DataFeederLoader.reportError(error); myArray = null; } if (myArray != null) { String[] selectedRowArray = inputParameterArray.get(Integer.valueOf(selectedRow - 1)); myArray.put(0, selectedRowArray); myArray.setParameterNames(inputParameterArray.getParameterNames()); } return myArray; }  @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);  }