Search in sources :

Example 41 with DataTableRow

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

the class DataEntrySteps method I_enter_repeating_subform_values.

@And("^I enter \"([^\"]*)\" repeating subform values:$")
public void I_enter_repeating_subform_values(String repeatingSubformName, DataTable subformValues) throws Throwable {
    BsModal modal = currentOpenedForm();
    DataTableRow header = subformValues.getGherkinRows().get(0);
    addRepetitiveFormsIfNeeded(repeatingSubformName, modal, subformValues.getGherkinRows().size() - 2);
    for (int i = 2; i < subformValues.getGherkinRows().size(); i++) {
        DataTableRow row = subformValues.getGherkinRows().get(i);
        for (int j = 0; j < header.getCells().size(); j++) {
            String label = driver.getAliasTable().getAlias(header.getCells().get(j));
            String value = row.getCells().get(j);
            LOGGER.finest("entering repeating subform values: label: " + label + ", value:" + value);
            modal.form().findFieldsByLabel(label).get(i - 2).fill(value);
            Sleep.sleepMillis(100);
        }
    }
}
Also used : DataTableRow(gherkin.formatter.model.DataTableRow) And(cucumber.api.java.en.And)

Example 42 with DataTableRow

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

the class DataEntrySteps method subsetColumns.

private static DataTable subsetColumns(DataTable table, List<String> expectedColumns) {
    List<String> columns = table.getGherkinRows().get(0).getCells();
    List<Integer> columnIndexes = new ArrayList<>();
    List<String> missingColumns = new ArrayList<>();
    for (String expectedColumn : expectedColumns) {
        int index = columns.indexOf(expectedColumn);
        if (index == -1) {
            missingColumns.add(expectedColumn);
        } else {
            columnIndexes.add(index);
        }
    }
    if (!missingColumns.isEmpty()) {
        throw new AssertionError("Missing expected columns " + missingColumns + " in table:\n" + table.toString());
    }
    List<List<String>> rows = new ArrayList<>();
    for (DataTableRow dataTableRow : table.getGherkinRows()) {
        List<String> row = new ArrayList<>();
        for (Integer columnIndex : columnIndexes) {
            row.add(dataTableRow.getCells().get(columnIndex));
        }
        rows.add(row);
    }
    return DataTable.create(rows);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DataTableRow(gherkin.formatter.model.DataTableRow)

Example 43 with DataTableRow

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

the class DataEntrySteps method I_enter_subform_values.

@And("^I enter \"([^\"]*)\" subform values:$")
public void I_enter_subform_values(String subformName, DataTable subformValues) throws Throwable {
    BsModal modal = currentOpenedForm();
    DataTableRow header = subformValues.getGherkinRows().get(0);
    SubformContainer subform = modal.subform(subformName);
    for (int i = 2; i < subformValues.getGherkinRows().size(); i++) {
        DataTableRow row = subformValues.getGherkinRows().get(i);
        String keyLabel = row.getCells().get(0);
        subform.selectKey(keyLabel);
        for (int j = 1; j < header.getCells().size(); j++) {
            String label = driver.getAliasTable().getAlias(header.getCells().get(j));
            modal.form().findFieldByLabel(label).fill(row.getCells().get(j));
        }
    }
}
Also used : DataTableRow(gherkin.formatter.model.DataTableRow) And(cucumber.api.java.en.And)

Example 44 with DataTableRow

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

the class DesignSteps method choose_reference_for_field.

@And("^choose reference for field \"([^\"]*)\"$")
public void choose_reference_for_field(String fieldLabel, DataTable dataTable) throws Throwable {
    FormDesignerPage page = (FormDesignerPage) driver.getCurrentPage();
    page.selectFieldByLabel(driver.alias(fieldLabel));
    PropertiesPanel fieldProperties = page.fieldProperties();
    for (int i = 0; i < dataTable.getGherkinRows().size(); i++) {
        DataTableRow row = dataTable.getGherkinRows().get(i);
        fieldProperties.chooseFormDialog().set(row.getCells(), driver.getAliasTable());
    }
    page.save();
}
Also used : DataTableRow(gherkin.formatter.model.DataTableRow) And(cucumber.api.java.en.And)

Example 45 with DataTableRow

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

the class DesignSteps method drop_field_in.

// accepts table :
// | label        | type        | container  |
// | MySection    | Section     | root       |
// | MyText       | Text        | MySection  |
@And("^drop field in:$")
public void drop_field_in(DataTable dataTable) throws Throwable {
    FormDesignerPage page = (FormDesignerPage) driver.getCurrentPage();
    for (int i = 1; i < dataTable.getGherkinRows().size(); i++) {
        DataTableRow row = dataTable.getGherkinRows().get(i);
        List<String> cells = row.getCells();
        String label = cells.get(0);
        String fieldType = cells.get(1);
        String containerLabel = cells.get(2);
        try {
            DropLabel dropLabel = page.fields().dropLabel(fieldType);
            DropPanel dropPanel = page.dropPanel(containerLabel);
            dropPanel.dragAndDrop(dropLabel);
            Sleep.sleepMillis(100);
            if ("root".equalsIgnoreCase(containerLabel) && (fieldType.equalsIgnoreCase("Section") || fieldType.contains("Sub-Form"))) {
                DropPanel containerDropPanel = page.dropPanel(fieldType);
                containerDropPanel.getContainer().clickWhenReady();
                page.containerProperties().setLabel(label);
            } else {
                page.selectFieldByLabel(fieldType);
                page.fieldProperties().setLabel(driver.getAliasTable().createAlias(label));
            }
        } catch (Exception e) {
            throw new RuntimeException("Failed to add field '" + label + "' in form designer UI", e);
        }
    }
    page.save();
}
Also used : DataTableRow(gherkin.formatter.model.DataTableRow) And(cucumber.api.java.en.And)

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