Search in sources :

Example 1 with CsvLineStreamRenderer

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());
    }
}
Also used : IdPrinter(com.bakdata.conquery.models.identifiable.mapping.IdPrinter) CsvLineStreamRenderer(com.bakdata.conquery.io.result.CsvLineStreamRenderer) ConqueryConfig(com.bakdata.conquery.models.config.ConqueryConfig) PrintSettings(com.bakdata.conquery.models.query.PrintSettings) List(java.util.List) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ResultInfo(com.bakdata.conquery.models.query.resultinfo.ResultInfo) Map(java.util.Map)

Aggregations

CsvLineStreamRenderer (com.bakdata.conquery.io.result.CsvLineStreamRenderer)1 ConqueryConfig (com.bakdata.conquery.models.config.ConqueryConfig)1 IdPrinter (com.bakdata.conquery.models.identifiable.mapping.IdPrinter)1 ManagedQuery (com.bakdata.conquery.models.query.ManagedQuery)1 PrintSettings (com.bakdata.conquery.models.query.PrintSettings)1 ResultInfo (com.bakdata.conquery.models.query.resultinfo.ResultInfo)1 List (java.util.List)1 Map (java.util.Map)1