Search in sources :

Example 6 with CQReusedQuery

use of com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery in project conquery by bakdata.

the class DefaultLabelTest method autoLabelComplexQueryNullLabels.

@ParameterizedTest
@CsvSource({ "de,Hochgeladene-Liste Anfrage Default-Concept Concept2 Concept3", "en,Uploaded-List Query Default-Concept Concept2 Concept3" })
void autoLabelComplexQueryNullLabels(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 = new CQConcept();
    concept1.setLabel(null);
    concept1.setElements(List.of(CONCEPT));
    CQConcept concept2 = makeCQConcept("Concept2");
    CQConcept concept3 = makeCQConcept("Concept3");
    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);
}
Also used : CQReusedQuery(com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) CQExternal(com.bakdata.conquery.apiv1.query.concept.specific.external.CQExternal) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) CQAnd(com.bakdata.conquery.apiv1.query.concept.specific.CQAnd) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with CQReusedQuery

use of com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery in project conquery by bakdata.

the class QueryCleanupTaskTest method reusedNames.

@Test
void reusedNames() throws Exception {
    assertThat(STORAGE.getAllExecutions()).isEmpty();
    final ManagedQuery managedQuery = createManagedQuery();
    final ManagedQuery managedQueryReused = createManagedQuery();
    managedQueryReused.setLabel("test2");
    managedQuery.setQuery(new ConceptQuery(new CQReusedQuery(managedQueryReused.getId())));
    new QueryCleanupTask(STORAGE, queryExpiration).execute(Map.of(), null);
    assertThat(STORAGE.getAllExecutions()).containsExactlyInAnyOrder(managedQueryReused);
}
Also used : CQReusedQuery(com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) Test(org.junit.jupiter.api.Test)

Example 8 with CQReusedQuery

use of com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery in project conquery by bakdata.

the class QueryCleanupTaskTest method reusedTagged.

@Test
void reusedTagged() throws Exception {
    assertThat(STORAGE.getAllExecutions()).isEmpty();
    final ManagedQuery managedQuery = createManagedQuery();
    final ManagedQuery managedQueryReused = createManagedQuery();
    managedQueryReused.setTags(new String[] { "tag" });
    managedQuery.setQuery(new ConceptQuery(new CQReusedQuery(managedQueryReused.getId())));
    new QueryCleanupTask(STORAGE, queryExpiration).execute(Map.of(), null);
    assertThat(STORAGE.getAllExecutions()).containsExactlyInAnyOrder(managedQueryReused);
}
Also used : CQReusedQuery(com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) Test(org.junit.jupiter.api.Test)

Example 9 with CQReusedQuery

use of com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery in project conquery by bakdata.

the class QueryCleanupTaskTest method reusedOtherName.

@Test
void reusedOtherName() throws Exception {
    assertThat(STORAGE.getAllExecutions()).isEmpty();
    final ManagedQuery managedQuery = createManagedQuery();
    managedQuery.setLabel("test2");
    final ManagedQuery managedQueryReused = createManagedQuery();
    managedQuery.setQuery(new ConceptQuery(new CQReusedQuery(managedQueryReused.getId())));
    new QueryCleanupTask(STORAGE, queryExpiration).execute(Map.of(), null);
    assertThat(STORAGE.getAllExecutions()).containsExactlyInAnyOrder(managedQueryReused, managedQuery);
}
Also used : CQReusedQuery(com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) Test(org.junit.jupiter.api.Test)

Example 10 with CQReusedQuery

use of com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery in project conquery by bakdata.

the class QueryCleanupTaskTest method reusedBothNames.

@Test
void reusedBothNames() throws Exception {
    assertThat(STORAGE.getAllExecutions()).isEmpty();
    final ManagedQuery managedQuery = createManagedQuery();
    managedQuery.setLabel("test1");
    final ManagedQuery managedQueryReused = createManagedQuery();
    managedQueryReused.setLabel("test2");
    managedQuery.setQuery(new ConceptQuery(new CQReusedQuery(managedQueryReused.getId())));
    new QueryCleanupTask(STORAGE, queryExpiration).execute(Map.of(), null);
    assertThat(STORAGE.getAllExecutions()).containsExactlyInAnyOrder(managedQuery, managedQueryReused);
}
Also used : CQReusedQuery(com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) Test(org.junit.jupiter.api.Test)

Aggregations

CQReusedQuery (com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery)12 ManagedQuery (com.bakdata.conquery.models.query.ManagedQuery)11 ConceptQuery (com.bakdata.conquery.apiv1.query.ConceptQuery)10 Test (org.junit.jupiter.api.Test)5 CQConcept (com.bakdata.conquery.apiv1.query.concept.specific.CQConcept)4 CQAnd (com.bakdata.conquery.apiv1.query.concept.specific.CQAnd)3 CQExternal (com.bakdata.conquery.apiv1.query.concept.specific.external.CQExternal)3 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)3 FullExecutionStatus (com.bakdata.conquery.apiv1.FullExecutionStatus)2 SecondaryIdQuery (com.bakdata.conquery.apiv1.query.SecondaryIdQuery)2 User (com.bakdata.conquery.models.auth.entities.User)2 Dataset (com.bakdata.conquery.models.datasets.Dataset)2 ManagedExecution (com.bakdata.conquery.models.execution.ManagedExecution)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Predicate (java.util.function.Predicate)2 Collectors (java.util.stream.Collectors)2 Slf4j (lombok.extern.slf4j.Slf4j)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2