use of com.bakdata.conquery.io.result.CsvLineStreamRenderer in project conquery by bakdata.
the class FormTest method checkResults.
private void checkResults(StandaloneSupport standaloneSupport, ManagedForm managedForm, User user) throws IOException {
Map<String, List<ManagedQuery>> managedMapping = managedForm.getSubQueries();
IdPrinter idPrinter = standaloneSupport.getConfig().getFrontend().getQueryUpload().getIdPrinter(user, managedForm, standaloneSupport.getNamespace());
final ConqueryConfig config = standaloneSupport.getConfig();
PrintSettings PRINT_SETTINGS = new PrintSettings(false, Locale.ENGLISH, standaloneSupport.getDatasetsProcessor().getDatasetRegistry(), config, idPrinter::createId);
CsvLineStreamRenderer renderer = new CsvLineStreamRenderer(config.getCsv().createWriter(), PRINT_SETTINGS);
for (Map.Entry<String, List<ManagedQuery>> managed : managedMapping.entrySet()) {
List<ResultInfo> resultInfos = managed.getValue().get(0).getResultInfos();
log.info("{} CSV TESTING: {}", getLabel(), managed.getKey());
List<String> actual = renderer.toStream(config.getFrontend().getQueryUpload().getIdResultInfos(), resultInfos, managed.getValue().stream().flatMap(ManagedQuery::streamResults)).collect(Collectors.toList());
assertThat(actual).as("Checking result " + managed.getKey()).containsExactlyInAnyOrderElementsOf(In.stream(expectedCsv.get(managed.getKey()).stream()).withUTF8().readLines());
}
}
Aggregations