Skip to content

Commit

Permalink
SCB-1597 Support checking the table without order
Browse files Browse the repository at this point in the history
  • Loading branch information
WillemJiang committed Nov 18, 2019
1 parent 6ae83b9 commit df9b46f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Expand Up @@ -90,7 +90,7 @@ public DubboDemoStepdefs() {
}
};

dataMatches(System.getProperty(ALPHA_REST_ADDRESS) + "/saga/events", dataTable, sortAndColumnStrippingConsumer);
dataMatches(System.getProperty(ALPHA_REST_ADDRESS) + "/saga/events", dataTable, sortAndColumnStrippingConsumer, false);
});

And("^(service[a-c]+) success update status$", (String serviceName, DataTable dataTable) -> {
Expand All @@ -101,7 +101,7 @@ public DubboDemoStepdefs() {
};

dataMatches(System.getProperty(SERVICEA_ADDRESS) + "/serviceInfo/" + serviceName, dataTable,
columnStrippingConsumer);
columnStrippingConsumer, false);
});
}

Expand Down
Expand Up @@ -50,6 +50,10 @@ public class StepDefSupport implements En {
};

protected void dataMatches(String address, DataTable dataTable, Consumer<Map<String, String>[]> dataProcessor) {
dataMatches(address, dataTable, dataProcessor, true);
}

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<>();

Expand All @@ -69,7 +73,11 @@ protected void dataMatches(String address, DataTable dataTable, Consumer<Map<Str
}

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

@SuppressWarnings("unchecked")
Expand Down

0 comments on commit df9b46f

Please sign in to comment.