Java Code Examples for cucumber.api.DataTable#diff()

The following examples show how to use cucumber.api.DataTable#diff() . 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: StepDefSupport.java    From servicecomb-pack with Apache License 2.0 6 votes vote down vote up
protected void dataMatches(String address, DataTable dataTable, Consumer<Map<String, String>[]> dataProcessor, boolean checkOrder) {
  List<Map<String, String>> expectedMaps = dataTable.asMaps(String.class, String.class);
  List<Map<String, String>> actualMaps = new ArrayList<>();

  await().atMost(10, SECONDS).until(() -> {
    actualMaps.clear();
    Collections.addAll(actualMaps, retrieveDataMaps(address, dataProcessor));
    // write the log if the Map size is not same
    boolean result = expectedMaps.size() == actualMaps.size();
    if (!result) {
      LOG.warn("The response message size is not we expected. ExpectedMap size is {},  ActualMap size is {}", expectedMaps.size(), actualMaps.size());
    }
    return expectedMaps.size() == actualMaps.size();
  });

  if (expectedMaps.isEmpty() && actualMaps.isEmpty()) {
    return;
  }

  LOG.info("Retrieved data {} from service", actualMaps);
  if (checkOrder) {
    dataTable.diff(DataTable.create(actualMaps));
  } else {
    dataTable.unorderedDiff(DataTable.create(actualMaps));
  }
}
 
Example 2
Source File: PackStepdefs.java    From servicecomb-pack with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void dataMatches(String address, DataTable dataTable, Consumer<Map<String, String>[]> dataProcessor) {
  List<Map<String, String>> expectedMaps = dataTable.asMaps(String.class, String.class);
  List<Map<String, String>> actualMaps = new ArrayList<>();

  await().atMost(5, SECONDS).until(() -> {
    actualMaps.clear();
    Collections.addAll(actualMaps, retrieveDataMaps(address, dataProcessor));
    // write the log if the Map size is not same
    boolean result = expectedMaps.size() == actualMaps.size();
    if (!result) {
      LOG.warn("The response message size is not we expected. ExpectedMap size is {},  ActualMap size is {}", expectedMaps.size(), actualMaps.size());
    }
    return expectedMaps.size() == actualMaps.size();
  });

  if (expectedMaps.isEmpty() && actualMaps.isEmpty()) {
    return;
  }

  LOG.info("Retrieved data {} from service", actualMaps);
  dataTable.diff(DataTable.create(actualMaps));
}