Search in sources :

Example 36 with DataTableRow

use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.

the class DataEntryTab method createMapping.

private List<Pair<String, String>> createMapping(DataTable dataTable) {
    List<Pair<String, String>> mapping = Lists.newArrayList();
    DataTableRow headerRow = dataTable.getGherkinRows().get(0);
    for (String cell : headerRow.getCells()) {
        mapping.add(Pair.newPair(cell, cell));
    }
    return mapping;
}
Also used : DataTableRow(gherkin.formatter.model.DataTableRow) Pair(org.activityinfo.model.util.Pair)

Example 37 with DataTableRow

use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.

the class BsModal method fill.

public void fill(DataTable dataTable, AliasTable aliasTable) {
    BsFormPanel form = form();
    DataTableRow labelRow = dataTable.getGherkinRows().get(0);
    DataTableRow typeRow = dataTable.getGherkinRows().get(1);
    for (int i = 2; i < dataTable.getGherkinRows().size(); i++) {
        DataTableRow row = dataTable.getGherkinRows().get(i);
        for (int j = 0; j < row.getCells().size(); j++) {
            String value = row.getCells().get(j);
            String label = labelRow.getCells().get(j);
            String type = typeRow.getCells().get(j);
            label = isBuiltinLabel(label) ? label : aliasTable.getAlias(label);
            BsFormPanel.BsField field = form.findFieldByLabel(label);
            if (type.equalsIgnoreCase("text") || type.equalsIgnoreCase("quantity")) {
                field.fill(value);
            } else if (type.equalsIgnoreCase("enum")) {
                field.select(aliasTable.getAlias(value));
            } else if (type.equalsIgnoreCase("date")) {
                field.fill(org.joda.time.LocalDate.parse(value));
            } else {
                throw new RuntimeException("Unsupported type: " + type);
            }
        }
    }
}
Also used : DataTableRow(gherkin.formatter.model.DataTableRow)

Example 38 with DataTableRow

use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.

the class ExcelConvertor method asExcelData.

public static String asExcelData(DataTable dataTable) {
    String s = "";
    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);
            s = s + cell;
            boolean isLastCell = j == (row.getCells().size() - 1);
            if (!isLastCell) {
                s += ";";
            }
        }
        boolean isLastRow = i == (dataTable.getGherkinRows().size() - 1);
        if (!isLastRow) {
            s = s + "\n";
        }
    }
    return s;
}
Also used : DataTableRow(gherkin.formatter.model.DataTableRow)

Example 39 with DataTableRow

use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.

the class DataEntrySteps method I_enter_values.

@And("^I enter values:$")
public void I_enter_values(DataTable table) throws Throwable {
    BsModal modal = currentOpenedForm();
    DataTableRow header = table.getGherkinRows().get(0);
    DataTableRow type = table.getGherkinRows().get(1);
    for (int i = 2; i < table.getGherkinRows().size(); i++) {
        DataTableRow row = table.getGherkinRows().get(i);
        for (int j = 0; j < row.getCells().size(); j++) {
            String label = header.getCells().get(j);
            if (!BsModal.isBuiltinLabel(label)) {
                label = driver.getAliasTable().getAlias(label);
            }
            String value = row.getCells().get(j);
            if (label.equalsIgnoreCase(I18N.CONSTANTS.partner())) {
                value = driver.getAliasTable().getAlias(value);
            }
            modal.form().findFieldByLabel(label).fill(value, type.getCells().get(j));
            Sleep.sleepMillis(100);
        }
    }
}
Also used : DataTableRow(gherkin.formatter.model.DataTableRow) And(cucumber.api.java.en.And)

Example 40 with DataTableRow

use of gherkin.formatter.model.DataTableRow in project activityinfo by bedatadriven.

the class DataEntrySteps method opened_form_has_repeating_subform_values.

@Then("^opened form has repeating subform values:$")
public void opened_form_has_repeating_subform_values(DataTable expectedSubformValues) throws Throwable {
    BsModal modal = currentOpenedForm();
    DataTableRow header = expectedSubformValues.getGherkinRows().get(0);
    DataTableRow type = expectedSubformValues.getGherkinRows().get(1);
    for (int i = 2; i < expectedSubformValues.getGherkinRows().size(); i++) {
        DataTableRow row = expectedSubformValues.getGherkinRows().get(i);
        for (int j = 0; j < header.getCells().size(); j++) {
            String label = driver.getAliasTable().getAlias(header.getCells().get(j));
            String currentValue = modal.form().findFieldsByLabel(label).get(i - 2).getValue(ControlType.fromValue(type.getCells().get(j)));
            assertEquals(row.getCells().get(j), currentValue);
        }
    }
}
Also used : DataTableRow(gherkin.formatter.model.DataTableRow) Then(cucumber.api.java.en.Then)

Aggregations

DataTableRow (gherkin.formatter.model.DataTableRow)46 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)9 List (java.util.List)6 And (cucumber.api.java.en.And)5 DataTable (cucumber.api.DataTable)4 DocString (gherkin.formatter.model.DocString)4 Step (gherkin.formatter.model.Step)4 Given (cucumber.api.java.en.Given)3 Then (cucumber.api.java.en.Then)3 LocalizedXStreams (cucumber.runtime.xstream.LocalizedXStreams)3 ExamplesTableRow (gherkin.formatter.model.ExamplesTableRow)3 Argument (gherkin.formatter.Argument)2 Arrays.asList (java.util.Arrays.asList)2 Map (java.util.Map)2 Pair (org.activityinfo.model.util.Pair)2 Usage (alien4cloud.model.common.Usage)1 Delta (cucumber.deps.difflib.Delta)1 I18n (gherkin.I18n)1 Row (gherkin.formatter.model.Row)1