cucumber.api.DataTable.getGherkinRows()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中cucumber.api.DataTable.getGherkinRows()方法的一些代码示例,展示了DataTable.getGherkinRows()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataTable.getGherkinRows()方法的具体详情如下:
包路径:cucumber.api.DataTable
类名称:DataTable
方法名:getGherkinRows

DataTable.getGherkinRows介绍

暂无

代码示例

代码示例来源:origin: viltgroup/minium

public DataTableDTO(DataTable dataTable) {
  List<DataTableRow> gherkinRows = dataTable.getGherkinRows();
  for (DataTableRow gherkinRow : gherkinRows) {
    rows.add(new DataTableRowDTO(gherkinRow));
  }
}

代码示例来源:origin: alien4cloud/alien4cloud

/**
   * Allow to parse a table of key value to a map and it supports the key being an environment variable
   * @param table a data table
   * @return  a map
   */
  public static Map<String, Object> dataTableToMap(DataTable table) {
    Map<String, Object> configuration = new HashMap<>();
    table.getGherkinRows().forEach(dataTableRow -> {
      String key = dataTableRow.getCells().get(0);
      String value = dataTableRow.getCells().get(1);
      Object processedValue = System.getenv(value);
      if (processedValue == null || ((String) processedValue).isEmpty()) {
        processedValue = value;
      }
      // Convert to raw boolean or integer if possible.
      if (processedValue.equals("true")) {
        processedValue = true;
      } else if (processedValue.equals("false")) {
        processedValue = false;
      } else {
        try {
          processedValue = Integer.valueOf((String) processedValue);
        } catch (NumberFormatException e) {
        }
      }
      configuration.put(key, processedValue);
    });
    return configuration;
  }
}

代码示例来源:origin: alien4cloud/alien4cloud

@Given("^I execute the operation$")
public void i_execute_the_operation(DataTable operationDT) throws Throwable {
  Map<String, String> operationMap = Maps.newLinkedHashMap();
  for (DataTableRow row : operationDT.getGherkinRows()) {
    operationMap.put(row.getCells().get(0), row.getCells().get(1));
  }
  do_i_execute_the_operation(operationMap);
}

代码示例来源:origin: alien4cloud/alien4cloud

@Then("^I should have a latest audit trace with a query defined below and whose secret \"([^\"]*)\" defined in requestBody should be hidden:$")
  public void iShouldHaveAuditTracesInAlienAndWhoseSecretDefinedInRequestBodyShouldBeHidden(String secretFieldName, DataTable table) throws Throwable {
    LinkedHashMap<String, String[]> queryMap = new LinkedHashMap<>();
    table.getGherkinRows().forEach(dataTableRow -> {
      queryMap.put(dataTableRow.getCells().get(0), new String[] { dataTableRow.getCells().get(1) });
    });
    List<AuditTrace> auditTraces = searchAuditLogs("", 0, 1, queryMap, false);
    Map<String, Object> bodyMap = JsonUtil.toMap(auditTraces.get(0).getRequestBody());
    Assert.assertEquals(true, ((String) bodyMap.get(secretFieldName)).contains("**********"));
  }
}

代码示例来源:origin: alien4cloud/alien4cloud

@And("^I update configuration for orchestrator with name \"([^\"]*)\"$")
public void updateOrchestratorConfiguration(String orchestratorName, DataTable table) throws Throwable {
  String orchestratorId = Context.getInstance().getOrchestratorId(orchestratorName);
  Map<String, Object> config = Context.getInstance().getOrchestratorConfiguration();
  table.getGherkinRows().stream().forEach(dataTableRow -> {
    String key = dataTableRow.getCells().get(0);
    String value = dataTableRow.getCells().get(1);
    Object processedValue = System.getenv(value);
    if (processedValue == null || ((String) processedValue).isEmpty()) {
      processedValue = value;
    }
    // Convert to raw boolean or integer if possible.
    if (processedValue.equals("true")) {
      processedValue = true;
    } else if (processedValue.equals("false")) {
      processedValue = false;
    } else {
      try {
        processedValue = Integer.valueOf((String) processedValue);
      } catch (NumberFormatException e) {
      }
    }
    config.put(key, processedValue);
  });
  Context.getInstance().setOrchestratorConfiguration(config);
  String restResponse = Context.getRestClientInstance().putJSon("/rest/v1/orchestrators/" + orchestratorId + "/configuration", JsonUtil.toString(config));
  Context.getInstance().registerRestResponse(restResponse);
}

代码示例来源:origin: alien4cloud/alien4cloud

@Then("^The delete csar response should contains the following related resources$")
public void I_should_have_a_delete_csar_response_with_related_resources(DataTable usageDT) throws Throwable {
  RestResponse<?> restResponse = JsonUtil.read(Context.getInstance().getRestResponse());
  Assert.assertNotNull(restResponse);
  List<Usage> resultData = JsonUtil.toList(JsonUtil.toString(restResponse.getData()), Usage.class);
  boolean isPresent;
  for (Usage usage : resultData) {
    isPresent = false;
    for (DataTableRow row : usageDT.getGherkinRows()) {
      if (usage.getResourceName().equals(row.getCells().get(0)) && usage.getResourceType().equals(row.getCells().get(1))) {
        isPresent = true;
        break;
      }
    }
    if (!isPresent) {
      Assert.assertFalse("Test failed : one of expected usage is not found : " + usage.getResourceName() + " : " + usage.getResourceType(), true);
    }
  }
}

相关文章