use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.
the class AliasTable method alias.
public DataTable alias(DataTable dataTable) {
Set<Integer> columnsToAlias = Sets.newHashSet();
Map<Pair<Integer, Integer>, String> aliasMatrix = Maps.newHashMap();
for (int i = 0; i < dataTable.getGherkinRows().size(); i++) {
DataTableRow row = dataTable.getGherkinRows().get(i);
for (int j = 0; j < row.getCells().size(); j++) {
String cell = row.getCells().get(j);
if (i != 0 && columnsToAlias.contains(j) && !isNumber(cell) && !isBoolean(cell)) {
// not header
aliasMatrix.put(Pair.newPair(i, j), getAlias(cell));
}
if (i == 0) {
// only for header
boolean isPartnerField = cell.equalsIgnoreCase(I18N.CONSTANTS.partner() + " " + I18N.CONSTANTS.name());
if (!ChooseColumnsDialog.BUILT_IN_COLUMNS.contains(cell) || isPartnerField) {
columnsToAlias.add(j);
}
if (!ChooseColumnsDialog.BUILT_IN_COLUMNS.contains(cell)) {
aliasMatrix.put(Pair.newPair(i, j), getAlias(cell));
}
}
}
}
for (Map.Entry<Pair<Integer, Integer>, String> entry : aliasMatrix.entrySet()) {
Integer row = entry.getKey().getFirst();
Integer column = entry.getKey().getSecond();
dataTable.getGherkinRows().get(row).getCells().set(column, entry.getValue());
}
return dataTable;
}
use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.
the class BsTable method assertRowsPresent.
public BsTable assertRowsPresent(DataTable dataTable) {
List<DataTableRow> matched = Lists.newArrayList();
List<DataTableRow> notMatched = Lists.newArrayList();
List<Row> rows = rows();
int expectedRows = dataTable.getGherkinRows().size() - 2;
if (rows.size() != expectedRows) {
throw new AssertionError("Number of rows do not match, found on UI: " + rows.size() + ", expected: " + expectedRows);
}
for (Row row : rows) {
for (int i = 2; i < dataTable.getGherkinRows().size(); i++) {
DataTableRow gherkinRow = dataTable.getGherkinRows().get(i);
if (matched(row.getCells(), gherkinRow)) {
matched.add(gherkinRow);
} else {
notMatched.add(gherkinRow);
}
}
}
if (matched.size() == expectedRows) {
// all are matched
return this;
}
throw new AssertionError("Unable to find match for field values: " + notMatched);
}
use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.
the class RelevanceDialog method set.
public RelevanceDialog set(DataTable dataTable, AliasTable alias) {
for (int i = 0; i < dataTable.getGherkinRows().size(); i++) {
DataTableRow row = dataTable.getGherkinRows().get(i);
List<String> cells = row.getCells();
Preconditions.checkState(cells.size() == 4);
String fieldLabel = alias.getAlias(cells.get(0));
String operation = cells.get(1);
String value = cells.get(2);
String controlType = cells.get(3);
if ("radio".equals(controlType)) {
value = alias.getAlias(value);
}
FluentElement lastRow = lastRow();
List<FluentElement> select = lastRow.find().select().waitForList().list();
Select fieldSelector = new Select(select.get(1).element());
fieldSelector.selectByVisibleText(fieldLabel);
Select operationSelector = new Select(select.get(2).element());
operationSelector.selectByVisibleText(operation);
switch(controlType) {
case "radio":
FluentElement radioLabel = lastRow().find().label(XPathBuilder.withText(value)).first();
radioLabel.clickWhenReady();
break;
}
}
return save();
}
use of gherkin.formatter.model.DataTableRow in project alien4cloud by alien4cloud.
the class EditorStepDefinitions method i_execute_the_operation.
@Given("^I execute the operation$")
public void i_execute_the_operation(DataTable operationDT) throws Throwable {
Map<String, String> operationMap = Maps.newLinkedHashMap();
for (DataTableRow row : operationDT.getGherkinRows()) {
operationMap.put(row.getCells().get(0), row.getCells().get(1));
}
do_i_execute_the_operation(operationMap);
}
use of gherkin.formatter.model.DataTableRow in project alien4cloud by alien4cloud.
the class CrudCSARSStepDefinition method I_should_have_a_delete_csar_response_with_related_resources.
@Then("^The delete csar response should contains the following related resources$")
public void I_should_have_a_delete_csar_response_with_related_resources(DataTable usageDT) throws Throwable {
RestResponse<?> restResponse = JsonUtil.read(Context.getInstance().getRestResponse());
Assert.assertNotNull(restResponse);
List<Usage> resultData = JsonUtil.toList(JsonUtil.toString(restResponse.getData()), Usage.class);
boolean isPresent;
for (Usage usage : resultData) {
isPresent = false;
for (DataTableRow row : usageDT.getGherkinRows()) {
if (usage.getResourceName().equals(row.getCells().get(0)) && usage.getResourceType().equals(row.getCells().get(1))) {
isPresent = true;
break;
}
}
if (!isPresent) {
Assert.assertFalse("Test failed : one of expected usage is not found : " + usage.getResourceName() + " : " + usage.getResourceType(), true);
}
}
}
Aggregations