Search in sources :

Example 31 with DataTable

use of cucumber.api.DataTable in project cucumber-jvm by cucumber.

the class ToDataTableTest method converts_list_of_beans_to_table.

@Test
public void converts_list_of_beans_to_table() {
    List<UserPojo> users = tc.toList(personTable(), UserPojo.class);
    DataTable table = tc.toTable(users);
    assertEquals("" + "      | credits | name        | birthDate  |\n" + "      | 1,000   | Sid Vicious | 10/05/1957 |\n" + "      | 3,000   | Frank Zappa | 21/12/1940 |\n" + "", table.toString());
}
Also used : DataTable(cucumber.api.DataTable) Test(org.junit.Test)

Example 32 with DataTable

use of cucumber.api.DataTable in project cucumber-jvm by cucumber.

the class DataTableTest method canCreateTableFromListOfListOfString.

@Test
public void canCreateTableFromListOfListOfString() {
    DataTable dataTable = createSimpleTable();
    List<List<String>> listOfListOfString = dataTable.raw();
    DataTable other = dataTable.toTable(listOfListOfString);
    assertEquals("" + "      | one  | four  | seven  |\n" + "      | 4444 | 55555 | 666666 |\n", other.toString());
}
Also used : DataTable(cucumber.api.DataTable) ArrayList(java.util.ArrayList) List(java.util.List) Arrays.asList(java.util.Arrays.asList) Test(org.junit.Test)

Example 33 with DataTable

use of cucumber.api.DataTable in project cucumber-jvm by cucumber.

the class DataTableTest method createTable.

private DataTable createTable(List<String>... rows) {
    List<DataTableRow> simpleRows = new ArrayList<DataTableRow>();
    for (int i = 0; i < rows.length; i++) {
        simpleRows.add(new DataTableRow(new ArrayList<Comment>(), rows[i], i + 1));
    }
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    LocalizedXStreams.LocalizedXStream xStream = new LocalizedXStreams(classLoader).get(Locale.US);
    return new DataTable(simpleRows, new TableConverter(xStream, null));
}
Also used : DataTable(cucumber.api.DataTable) ArrayList(java.util.ArrayList) LocalizedXStreams(cucumber.runtime.xstream.LocalizedXStreams) DataTableRow(gherkin.formatter.model.DataTableRow)

Example 34 with DataTable

use of cucumber.api.DataTable in project syndesis-qe by syndesisio.

the class CommonSteps method validateCredentials.

@And("^.*validate credentials$")
public void validateCredentials() {
    Map<String, Account> accounts = AccountsDirectory.getInstance().getAccounts();
    List<List<String>> oneAccountList = new ArrayList<>();
    List<String> tmpList = Arrays.asList("a", "s", "d", "f");
    accounts.keySet().forEach(key -> {
        Optional<Account> currentAccount = AccountsDirectory.getInstance().getAccount(key);
        if (currentAccount.isPresent()) {
            String service = currentAccount.get().getService();
            Credentials current = Credentials.valueOf(service.toUpperCase());
            switch(current) {
                case DROPBOX:
                    service = "DropBox";
                    break;
                case SALESFORCE:
                    service = "Salesforce";
                    break;
                case TWITTER:
                    service = "Twitter";
                    break;
                case S3:
                    // TODO: skip for now
                    return;
                default:
                    // skip for other cred
                    return;
            }
            // type
            tmpList.set(0, service);
            // name
            tmpList.set(1, key);
            // connection name
            tmpList.set(2, "my " + key + " connection");
            // description
            tmpList.set(3, "some description");
            log.trace("Inserting: " + tmpList.toString());
            oneAccountList.add(new ArrayList<>(tmpList));
            log.trace("Current values in list list: " + oneAccountList.toString());
        }
    });
    log.debug("Final status of list: " + oneAccountList.toString());
    DataTable accountsTalbe = DataTable.create(oneAccountList);
    createConnections(accountsTalbe);
}
Also used : Account(io.syndesis.qe.accounts.Account) DataTable(cucumber.api.DataTable) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) And(cucumber.api.java.en.And)

Aggregations

DataTable (cucumber.api.DataTable)34 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)10 List (java.util.List)7 DataTableRow (gherkin.formatter.model.DataTableRow)4 Arrays.asList (java.util.Arrays.asList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)3 LocalizedXStreams (cucumber.runtime.xstream.LocalizedXStreams)2 Type (java.lang.reflect.Type)2 And (cucumber.api.java.en.And)1 SingleValueConverter (cucumber.deps.com.thoughtworks.xstream.converters.SingleValueConverter)1 Delta (cucumber.deps.difflib.Delta)1 CucumberException (cucumber.runtime.CucumberException)1 Utils.listItemType (cucumber.runtime.Utils.listItemType)1 Utils.mapKeyType (cucumber.runtime.Utils.mapKeyType)1 Utils.mapValueType (cucumber.runtime.Utils.mapValueType)1 TableConverter (cucumber.runtime.table.TableConverter)1 En (gherkin.lexer.En)1 Lexer (gherkin.lexer.Lexer)1