use of com.bakdata.conquery.apiv1.query.concept.specific.CQConcept in project conquery by bakdata.
the class SerializationTests method cqConcept.
@Test
public void cqConcept() throws JSONException, IOException {
final Dataset dataset = new Dataset();
dataset.setName("dataset");
final TreeConcept concept = new TreeConcept();
concept.setName("concept");
concept.setDataset(dataset);
final ConceptTreeConnector connector = new ConceptTreeConnector();
connector.setConcept(concept);
concept.setConnectors(List.of(connector));
final CQConcept cqConcept = new CQConcept();
cqConcept.setElements(List.of(concept));
cqConcept.setLabel("Label");
final CQTable cqTable = new CQTable();
cqTable.setConnector(connector);
cqTable.setFilters(List.of());
cqTable.setConcept(cqConcept);
cqConcept.setTables(List.of(cqTable));
final CentralRegistry registry = new CentralRegistry();
registry.register(dataset);
registry.register(concept);
registry.register(connector);
SerializationTestUtil.forType(CQConcept.class).registry(registry).test(cqConcept);
}
use of com.bakdata.conquery.apiv1.query.concept.specific.CQConcept in project conquery by bakdata.
the class DefaultLabelTest method makeCQConcept.
private static CQConcept makeCQConcept(String label) {
CQConcept concept = new CQConcept();
concept.setLabel(label);
concept.setElements(List.of(CONCEPT));
return concept;
}
use of com.bakdata.conquery.apiv1.query.concept.specific.CQConcept in project conquery by bakdata.
the class DefaultLabelTest method autoLabelComplexQuery.
@ParameterizedTest
@CsvSource({ "de,Hochgeladene-Liste Anfrage Concept1 Concept2 und weitere", "en,Uploaded-List Query Concept1 Concept2 and further" })
void autoLabelComplexQuery(Locale locale, String autoLabel) {
I18n.LOCALE.set(locale);
final ManagedQuery managedQuery = new ManagedQuery(null, null, DATASET);
managedQuery.setQueryId(UUID.randomUUID());
CQAnd and = new CQAnd();
CQConcept concept1 = makeCQConcept("Concept1");
CQConcept concept2 = makeCQConcept("Concept2");
CQConcept concept3 = makeCQConcept("Concept3veryveryveryveryveryveryveryverylooooooooooooooooooooonglabel");
and.setChildren(List.of(new CQExternal(List.of(), new String[0][0]), new CQReusedQuery(managedQuery.getId()), concept1, concept2, concept3));
ConceptQuery cq = new ConceptQuery(and);
ManagedQuery mQuery = cq.toManagedExecution(user, DATASET);
mQuery.setLabel(mQuery.makeAutoLabel(getPrintSettings(locale)));
assertThat(mQuery.getLabel()).isEqualTo(autoLabel + AUTO_LABEL_SUFFIX);
assertThat(mQuery.getLabelWithoutAutoLabelSuffix()).isEqualTo(autoLabel);
}
use of com.bakdata.conquery.apiv1.query.concept.specific.CQConcept in project conquery by bakdata.
the class DefaultColumnNameTest method checkCombinations.
@ParameterizedTest
@MethodSource("provideCombinations")
void checkCombinations(TestConcept concept, boolean hasCQConceptLabel, String expectedColumnName) {
doAnswer(invocation -> {
final ConceptId id = invocation.getArgument(0);
if (!concept.getId().equals(id)) {
throw new IllegalStateException("Expected the id " + concept.getId() + " but got " + id);
}
return concept;
}).when(DATASET_REGISTRY).resolve(any());
final CQConcept cqConcept = concept.createCQConcept(hasCQConceptLabel);
final UniqueNamer uniqNamer = new UniqueNamer(SETTINGS);
SelectResultInfo info = new SelectResultInfo(concept.extractSelect(cqConcept), cqConcept);
assertThat(uniqNamer.getUniqueName(info)).isEqualTo(expectedColumnName);
}
use of com.bakdata.conquery.apiv1.query.concept.specific.CQConcept 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