当前位置: 首页>>代码示例>>Java>>正文


Java PickleTable类代码示例

本文整理汇总了Java中gherkin.pickles.PickleTable的典型用法代码示例。如果您正苦于以下问题:Java PickleTable类的具体用法?Java PickleTable怎么用?Java PickleTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PickleTable类属于gherkin.pickles包,在下文中一共展示了PickleTable类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDataTableAttachment

import gherkin.pickles.PickleTable; //导入依赖的package包/类
private void createDataTableAttachment(final PickleTable pickleTable) {
    final List<PickleRow> rows = pickleTable.getRows();

    final StringBuilder dataTableCsv = new StringBuilder();
    if (!rows.isEmpty()) {
        rows.forEach(dataTableRow -> {
            dataTableCsv.append(
                    dataTableRow.getCells().stream()
                            .map(PickleCell::getValue)
                            .collect(Collectors.joining("\t"))
            );
            dataTableCsv.append('\n');
        });

        final String attachmentSource = lifecycle
                .prepareAttachment("Data table", "text/tab-separated-values", "csv");
        lifecycle.writeAttachment(attachmentSource,
                new ByteArrayInputStream(dataTableCsv.toString().getBytes(Charset.forName("UTF-8"))));
    }
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:21,代码来源:AllureCucumber2Jvm.java

示例2: createArgumentsForErrorMessage

import gherkin.pickles.PickleTable; //导入依赖的package包/类
private List<Argument> createArgumentsForErrorMessage(PickleStep step) {
    List<Argument> arguments = new ArrayList<>(getArguments());
    if (!step.getArgument().isEmpty()) {
        gherkin.pickles.Argument stepArgument = step.getArgument().get(0);
        if (stepArgument instanceof PickleString) {
            arguments.add(new Argument(-1, "DocString:" + ((PickleString) stepArgument).getContent()));
        } else if (stepArgument instanceof PickleTable) {
            List<List<String>> rows = map(((PickleTable) stepArgument).getRows(), new Mapper<PickleRow, List<String>>() {
                @Override
                public List<String> map(PickleRow row) {
                    List<String> raw = new ArrayList<>(row.getCells().size());
                    for (PickleCell pickleCell : row.getCells()) {
                        raw.add(pickleCell.getValue());
                    }
                    return raw;
                }
            });
            arguments.add(new Argument(-1, "Table:" + rows.toString()));
        }
    }
    return arguments;
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:23,代码来源:StepDefinitionMatch.java

示例3: toList

import gherkin.pickles.PickleTable; //导入依赖的package包/类
static <T> List<T> toList(PickleTable dataTable, Type itemType, JsonElement testData) {
    List<T> result = new ArrayList<T>();
    List<String> keys = convertTopCellsToFieldNames(raw(dataTable.getRows().get(0)));
    int count = dataTable.getRows().size();
    for (int i = 1; i < count; i++) {
        List<String> valueRow = raw(dataTable.getRows().get(i));
        T item = (T) SuperReflect.on((Class) itemType).create().get();
        int j = 0;
        for (String cell : valueRow) {
            SuperReflect.on(item).set(keys.get(j), cell);
            j++;
        }
        result.add(item);
    }
    return Collections.unmodifiableList(result);
}
 
开发者ID:andrewjc,项目名称:kheera-testrunner-android,代码行数:17,代码来源:TableConverter.java

示例4: toMaps

import gherkin.pickles.PickleTable; //导入依赖的package包/类
static List<Map<String, String>> toMaps(PickleTable dataTable) {
    List<Map<String, String>> result = new ArrayList<Map<String, String>>();
    List<String> keys = raw(dataTable.getRows().get(0));
    int count = dataTable.getRows().size();
    for (int i = 1; i < count; i++) {
        List<String> valueRow = raw(dataTable.getRows().get(i));
        Map<String, String> map = new LinkedHashMap<String, String>();
        int j = 0;
        for (String cell : valueRow) {
            map.put(keys.get(j), cell);
            j++;
        }
        result.add(Collections.unmodifiableMap(map));
    }
    return Collections.unmodifiableList(result);
}
 
开发者ID:andrewjc,项目名称:kheera-testrunner-android,代码行数:17,代码来源:TableConverter.java

示例5: tableArgument

import gherkin.pickles.PickleTable; //导入依赖的package包/类
private Object tableArgument(PickleTable stepArgument, int argIndex, LocalizedXStreams.LocalizedXStream xStream) {
    ParameterInfo parameterInfo = getParameterType(argIndex, DataTable.class);
    TableConverter tableConverter = new TableConverter(xStream, parameterInfo);
    DataTable table = new DataTable(stepArgument, tableConverter);
    Type type = parameterInfo.getType();
    return tableConverter.convert(table, type, parameterInfo.isTransposed());
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:8,代码来源:StepDefinitionMatch.java

示例6: convert

import gherkin.pickles.PickleTable; //导入依赖的package包/类
public static <T> T convert(PickleTable dataTable, Type type, JsonElement testData) {

        if (type == null || (type instanceof Class && ((Class) type).isAssignableFrom(PickleTable.class))) {
            return (T) dataTable;
        }

        Type itemType = listItemType(type);
        if (itemType == null) {
            throw new ParserException("Not a List type: " + type);
        }

        Type mapKeyType = mapKeyType(itemType);
        if (mapKeyType != null) {
            Type mapValueType = mapValueType(itemType);
            return (T) toMaps(dataTable);
        }

        Type listitemType = listItemType(itemType);
        if (listitemType != null && ((Class)listitemType).isAssignableFrom(String.class)) {
            return (T) raw(dataTable);
        } else {
            if (((Class)itemType).isAssignableFrom(String.class)) {
                return (T) toStringList(dataTable, testData);
            } else {
                return (T) toList(dataTable, itemType, testData);
            }
        }
    }
 
开发者ID:andrewjc,项目名称:kheera-testrunner-android,代码行数:29,代码来源:TableConverter.java

示例7: toStringList

import gherkin.pickles.PickleTable; //导入依赖的package包/类
static List<String> toStringList(PickleTable dataTable, JsonElement testData) {
    List<String> result = new ArrayList<String>();
    int count = dataTable.getRows().size();
    if (count == 1) {
        for (PickleCell cell : dataTable.getRows().get(0).getCells()) {
            result.add(replaceWithTestData(testData, cell.getValue()));
        }
    } else {
        for (PickleRow row : dataTable.getRows()) {
            result.add(replaceWithTestData(testData, row.getCells().get(0).getValue()));
        }
    }
    return Collections.unmodifiableList(result);
}
 
开发者ID:andrewjc,项目名称:kheera-testrunner-android,代码行数:15,代码来源:TableConverter.java


注:本文中的gherkin.pickles.PickleTable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。