com.zebrunner.carina.dataprovider.parser.csv.CSVTable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of carina-dataprovider Show documentation
Show all versions of carina-dataprovider Show documentation
Set of dataprovider utilities.
The newest version!
package com.zebrunner.carina.dataprovider.parser.csv;
import java.lang.invoke.MethodHandles;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.zebrunner.carina.utils.parser.xls.AbstractTable;
public class CSVTable extends AbstractTable {
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public CSVTable() {
super();
}
public CSVTable(String executeColumn, String executeValue) {
super(executeColumn, executeValue);
}
@Override
public void addDataRow(List row) {
if (row.size() == headers.size()) {
Map rowMap = new HashMap<>();
for (int i = 0; i < headers.size(); i++) {
rowMap.put(headers.get(i), row.get(i));
}
if (!rowMap.isEmpty()) {
dataRows.add(rowMap);
}
} else {
LOGGER.error("Headers size and row size didn't match, can't add data to table");
}
}
public void excludeEntriesForNonExecution() {
for (int i = 0; i < dataRows.size(); i++) {
Map row = dataRows.get(i);
if (!row.get(executeColumn).equalsIgnoreCase(executeValue)) {
dataRows.remove(i);
i--;
}
}
}
}