use of com.bakdata.conquery.models.config.ExcelConfig in project conquery by bakdata.
the class ExcelResultRenderTest method writeAndRead.
@Test
void writeAndRead() throws IOException {
// Prepare every input data
PrintSettings printSettings = new PrintSettings(true, Locale.GERMAN, null, CONFIG, (cer) -> EntityPrintId.from(Integer.toString(cer.getEntityId()), Integer.toString(cer.getEntityId())), (selectInfo) -> selectInfo.getSelect().getLabel());
// The Shard nodes send Object[] but since Jackson is used for deserialization, nested collections are always a list because they are not further specialized
List<EntityResult> results = getTestEntityResults();
ManagedQuery mquery = new ManagedQuery(null, null, null) {
public List<ResultInfo> getResultInfos() {
return getResultTypes().stream().map(ResultTestUtil.TypedSelectDummy::new).map(select -> new SelectResultInfo(select, new CQConcept())).collect(Collectors.toList());
}
@Override
public Stream<EntityResult> streamResults() {
return results.stream();
}
};
// First we write to the buffer, than we read from it and parse it as TSV
ByteArrayOutputStream output = new ByteArrayOutputStream();
ExcelRenderer renderer = new ExcelRenderer(new ExcelConfig(), printSettings);
renderer.renderToStream(ResultTestUtil.ID_FIELDS, mquery, output);
InputStream inputStream = new ByteArrayInputStream(output.toByteArray());
List<String> computed = readComputed(inputStream, printSettings);
List<String> expected = generateExpectedTSV(results, mquery.getResultInfos(), printSettings);
log.info("Wrote and than read this excel data: {}", computed);
assertThat(computed).isNotEmpty();
assertThat(computed).isEqualTo(expected);
}
Aggregations