Java Code Examples for io.cucumber.datatable.DataTable#asMap()
The following examples show how to use
io.cucumber.datatable.DataTable#asMap() .
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: CypressSpec.java From bdt with Apache License 2.0 | 6 votes |
@When("^I run on Cypress with testcase '(.+?)' with path '(.+?)'( and store video evidences with path '(.+?)')?( and with exit status '(\\d+)')?( and save the value in environment variable '(.+?)')?$") public void executeCypresswithURLwithVideo(String testcase, String path, String videopath, Integer sExitStatus, String envVar, DataTable table) throws Exception { Integer exitStatus = sExitStatus == null ? 0 : sExitStatus; Map<String, String> variables; String cypressVariables; try { variables = table.asMap(String.class, String.class); cypressVariables = variables.keySet().stream().map(k -> k + "=" + variables.get(k)) .collect(Collectors.joining(" ", "", "")); } catch (Exception e) { this.commonspec.getLogger().warn("Error parsing Datatable to map. Setting empty..."); cypressVariables = ""; } String videoVariable = videopath == null ? "" : " --config trashAssetsBeforeRuns=false,videoUploadOnPasses=true,videosFolder=" + videopath; String command = cypressVariables + " npx cypress run --spec cypress/integration" + path + "/" + testcase + ".spec.ts" + videoVariable; this.commonspec.getLogger().info("Executing cypress: " + command); commonspec.runLocalCommand(command); commonspec.runCommandLoggerAndEnvVar(exitStatus, envVar, Boolean.TRUE); Assertions.assertThat(commonspec.getCommandExitStatus()).isEqualTo(exitStatus); }
Example 2
Source File: JdbcSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^(?:D|d)atabase connection$") public void setConnection(DataTable properties) { Map<String, String> connectionProps = properties.asMap(String.class, String.class); String driver = connectionProps.getOrDefault("driver", "org.postgresql.Driver"); String url = connectionProps.getOrDefault("url", "jdbc:postgresql://localhost:5432/testdb"); String username = connectionProps.getOrDefault("username", "test"); String password = connectionProps.getOrDefault("password", "test"); boolean suppressClose = Boolean.parseBoolean(connectionProps.getOrDefault("suppressClose", Boolean.TRUE.toString())); SingleConnectionDataSource singleConnectionDataSource = new SingleConnectionDataSource(url, username, password, suppressClose); singleConnectionDataSource.setDriverClassName(driver); this.dataSource = singleConnectionDataSource; }
Example 3
Source File: KafkaSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^(?:K|k)afka connection$") public void setConnection(DataTable properties) { Map<String, String> connectionProps = properties.asMap(String.class, String.class); String url = connectionProps.getOrDefault("url", "localhost:9092"); String topic = connectionProps.getOrDefault("topic", "test"); String consumerGroup = connectionProps.getOrDefault("consumerGroup", KafkaMessageHeaders.KAFKA_PREFIX + "group"); KafkaEndpointBuilder builder = new KafkaEndpointBuilder() .server(url) .topic(topic) .consumerGroup(consumerGroup); kafka = builder.build(); }
Example 4
Source File: OpenApiSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^outbound dictionary$") public void createOutboundDictionary(DataTable dataTable) { Map<String, String> mappings = dataTable.asMap(String.class, String.class); for (Map.Entry<String, String> mapping : mappings.entrySet()) { outboundDictionary.getMappings().put(mapping.getKey(), mapping.getValue()); } }
Example 5
Source File: OpenApiSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^inbound dictionary$") public void createInboundDictionary(DataTable dataTable) { Map<String, String> mappings = dataTable.asMap(String.class, String.class); for (Map.Entry<String, String> mapping : mappings.entrySet()) { inboundDictionary.getMappings().put(mapping.getKey(), mapping.getValue()); } }
Example 6
Source File: HttpClientSteps.java From yaks with Apache License 2.0 | 4 votes |
@Then("^(?:expect|verify) HTTP response headers$") public void addResponseHeaders(DataTable headers) { Map<String, String> headerPairs = headers.asMap(String.class, String.class); headerPairs.forEach(this::addResponseHeader); }
Example 7
Source File: HttpClientSteps.java From yaks with Apache License 2.0 | 4 votes |
@Given("^HTTP request headers$") public void addRequestHeaders(DataTable headers) { Map<String, String> headerPairs = headers.asMap(String.class, String.class); headerPairs.forEach(this::addRequestHeader); }
Example 8
Source File: HttpClientSteps.java From yaks with Apache License 2.0 | 4 votes |
@Then("^(?:expect|verify) HTTP response expressions$") public void addBodyValidationExpressions(DataTable validationExpressions) { Map<String, String> expressions = validationExpressions.asMap(String.class, String.class); expressions.forEach(this::addBodyValidationExpression); }
Example 9
Source File: HttpServerSteps.java From yaks with Apache License 2.0 | 4 votes |
@Then("^(?:expect|verify) HTTP request headers$") public void addRequestHeaders(DataTable headers) { Map<String, String> headerPairs = headers.asMap(String.class, String.class); headerPairs.forEach(this::addRequestHeader); }
Example 10
Source File: HttpServerSteps.java From yaks with Apache License 2.0 | 4 votes |
@Given("^HTTP response headers$") public void addResponseHeaders(DataTable headers) { Map<String, String> headerPairs = headers.asMap(String.class, String.class); headerPairs.forEach(this::addResponseHeader); }
Example 11
Source File: HttpServerSteps.java From yaks with Apache License 2.0 | 4 votes |
@Then("^(?:expect|verify) HTTP request expressions$") public void addBodyValidationExpressions(DataTable validationExpressions) { Map<String, String> expressions = validationExpressions.asMap(String.class, String.class); expressions.forEach(this::addBodyValidationExpression); }