All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cookercucumber_parser.featureParserFactory.ExamplesUtils Maven / Gradle / Ivy

Go to download

Derives smallest Feature File, Allows Data from Excel(xls and xlsx) and Also provides a clear and concise reporting

There is a newer version: 3.1.0
Show newest version
package cookercucumber_parser.featureParserFactory;

import gherkin.ast.Examples;
import gherkin.ast.TableCell;
import gherkin.ast.TableRow;

import java.util.List;

public class ExamplesUtils implements ExampleI {

    private final String EXAMPLES_KEYWORD = "Examples:";
    private Examples examples = null;
    private StringBuilder result = new StringBuilder();

    public ExamplesUtils(Examples pExamples) {
        this.examples = pExamples;
    }

    /**
     * Read the Examples Object and Parse it and get it's Content in as String
     * 
Author : Manjunath Prabhakar ([email protected])
* * @return String Content of Examples Object */ public String getExamplesData() { try { // //Examples Tags // for (Tag tag : examples.getTags()) { // TagUtils tagUtils = new TagUtils(tag); // String tagData = tagUtils.getTagsData(); // this.result.append(tagData); // } this.result.append(EXAMPLES_KEYWORD); this.result.append(System.getProperty("line.separator")); //Map> exampleMap = new LinkedHashMap>(); List headerCells = this.examples.getTableHeader().getCells(); this.result.append("|"); for (TableCell headerCell : headerCells) { //exampleMap.put("<" + headerCell.getValue() + ">", new ArrayList()); this.result.append(headerCell.getValue()).append("|"); } //Object[] columnKeys = exampleMap.keySet().toArray(); this.result.append(System.getProperty("line.separator")); List tableBody = this.examples.getTableBody(); for (TableRow tableRow : tableBody) { List cells = tableRow.getCells(); this.result.append("|"); for (TableCell tableCell : cells) { // String columnKey = (String) columnKeys[i]; // List values = exampleMap.get(columnKey); //values.add(cells.get(i).getValue()); String cell = tableCell.getValue(); this.result.append(cell).append("|"); } this.result.append(System.getProperty("line.separator")); } //sb.append(exampleMap); //System.out.println(exampleMap); } catch (Exception e) { e.printStackTrace(); } return String.valueOf(this.result); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy