Java Code Examples for io.cucumber.datatable.DataTable#asList()
The following examples show how to use
io.cucumber.datatable.DataTable#asList() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CartesianProductStepDefs.java From demo with MIT License | 6 votes |
@Given("lists as follows:") public void listsAsFollows(DataTable randomLists) { final List<String> oldLists = randomLists.asList(); setOfSets = new HashSet<>(); for (int i = 0; i < oldLists.size(); i++) { StringTokenizer defaultTokenizer = new StringTokenizer(oldLists.get(i)); final Set<String> tempSet = new HashSet<>(); while (defaultTokenizer.hasMoreTokens()) { tempSet.add(defaultTokenizer.nextToken()); } setOfSets.add(tempSet); } }
Example 2
Source File: DatabaseSpec.java From bdt with Apache License 2.0 | 6 votes |
@Then("^I check that result is:$") public void comparetable(DataTable dataTable) throws Exception { //from Cucumber Datatable, the pattern to verify List<String> tablePattern = new ArrayList<String>(); tablePattern = dataTable.asList(String.class); //the result from select List<String> sqlTable = new ArrayList<String>(); //the result is taken from previous step for (int i = 0; ThreadProperty.get("queryresponse" + i) != null; i++) { String ip_value = ThreadProperty.get("queryresponse" + i); sqlTable.add(i, ip_value); } for (int i = 0; ThreadProperty.get("queryresponse" + i) != null; i++) { ThreadProperty.remove("queryresponse" + i); } assertThat(tablePattern).as("response is not equal to the expected").isEqualTo(sqlTable); }
Example 3
Source File: SaveProperties.java From hesperides with GNU General Public License v3.0 | 5 votes |
/** * Cette méthode transforme une matrice à deux dimensions * contenant les colonnes "iterable", "bloc", "name", "value" * en une liste de IterableValuedPropertyIO. */ static List<IterableValuedPropertyIO> dataTableToIterableProperties(DataTable dataTable) { List<IterableProperty> iterablePropertiesData = dataTable.asList(IterableProperty.class); // Première étape : transformer la datatable en map // pour mutualiser les données Map<String, Map<String, Map<String, String>>> iterableMap = new HashMap<>(); iterablePropertiesData.forEach(iterableProperty -> { Map<String, Map<String, String>> itemMap = iterableMap.getOrDefault(iterableProperty.getIterable(), new HashMap<>()); Map<String, String> propertyMap = itemMap.getOrDefault(iterableProperty.getBloc(), new HashMap<>()); propertyMap.put(iterableProperty.getName(), iterableProperty.getValue()); itemMap.put(iterableProperty.getBloc(), propertyMap); iterableMap.put(iterableProperty.getIterable(), itemMap); }); // Deuxième étape : recréer l'arbre des données // attendues en input à l'aide des maps List<IterableValuedPropertyIO> iterableProperties = new ArrayList<>(); iterableMap.forEach((iterableName, iterableItems) -> { List<IterablePropertyItemIO> items = new ArrayList<>(); iterableItems.forEach((itemTitle, itemProperties) -> { List<AbstractValuedPropertyIO> properties = new ArrayList<>(); itemProperties.forEach((propertyName, propertyValue) -> properties.add(new ValuedPropertyIO(propertyName, propertyValue))); items.add(new IterablePropertyItemIO(itemTitle, new ArrayList<>(properties))); }); iterableProperties.add(new IterableValuedPropertyIO(iterableName, items)); }); return iterableProperties; }
Example 4
Source File: DatabaseSpec.java From bdt with Apache License 2.0 | 4 votes |
@Then("^I check that table '(.+?)' is iqual to$") public void comparetable(String tableName, DataTable dataTable) throws Exception { Statement myStatement = null; java.sql.ResultSet rs = null; //from postgres table List<String> sqlTable = new ArrayList<String>(); List<String> sqlTableAux = new ArrayList<String>(); //from Cucumber Datatable List<String> tablePattern = new ArrayList<String>(); //comparison is by lists of string tablePattern = dataTable.asList(String.class); Connection myConnection = this.commonspec.getConnection(); String query = "SELECT * FROM " + tableName + " order by " + "id" + ";"; try { myStatement = myConnection.createStatement(); rs = myStatement.executeQuery(query); //takes column names and culumn count ResultSetMetaData resultSetMetaData = rs.getMetaData(); int count = resultSetMetaData.getColumnCount(); for (int i = 1; i <= count; i++) { sqlTable.add(resultSetMetaData.getColumnName(i).toString()); } //takes column names and culumn count while (rs.next()) { for (int i = 1; i <= count; i++) { //aux list without column names sqlTableAux.add(rs.getObject(i).toString()); } } sqlTable.addAll(sqlTableAux); assertThat(sqlTable).as("Not equal elements!").isEqualTo(tablePattern); rs.close(); myStatement.close(); } catch (Exception e) { e.printStackTrace(); assertThat(rs).as("There are no table " + tableName).isNotNull(); } }