Search in sources :

Example 21 with ManagedQuery

use of com.bakdata.conquery.models.query.ManagedQuery in project conquery by bakdata.

the class DefaultLabelTest method autoLabelConceptQueryFallback.

@ParameterizedTest
@CsvSource({ "de,Default-Concept", "en,Default-Concept" })
void autoLabelConceptQueryFallback(Locale locale, String autoLabel) {
    I18n.LOCALE.set(locale);
    CQConcept concept = new CQConcept();
    concept.setLabel(null);
    concept.setElements(List.of(CONCEPT));
    ConceptQuery cq = new ConceptQuery(concept);
    ManagedQuery mQuery = cq.toManagedExecution(user, DATASET);
    UUID uuid = UUID.randomUUID();
    mQuery.setQueryId(uuid);
    mQuery.setLabel(mQuery.makeAutoLabel(getPrintSettings(locale)));
    assertThat(mQuery.getLabel()).isEqualTo(autoLabel + AUTO_LABEL_SUFFIX);
    assertThat(mQuery.getLabelWithoutAutoLabelSuffix()).isEqualTo(autoLabel);
}
Also used : CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) UUID(java.util.UUID) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 22 with ManagedQuery

use of com.bakdata.conquery.models.query.ManagedQuery 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 23 with ManagedQuery

use of com.bakdata.conquery.models.query.ManagedQuery in project conquery by bakdata.

the class PermissionCleanupTaskTest method createManagedQuery.

private ManagedQuery createManagedQuery() {
    final CQAnd root = new CQAnd();
    root.setChildren(new ArrayList<>());
    ConceptQuery query = new ConceptQuery(root);
    final ManagedQuery managedQuery = new ManagedQuery(query, null, new Dataset("test"));
    managedQuery.setCreationTime(LocalDateTime.now().minusDays(1));
    STORAGE.addExecution(managedQuery);
    return managedQuery;
}
Also used : Dataset(com.bakdata.conquery.models.datasets.Dataset) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) CQAnd(com.bakdata.conquery.apiv1.query.concept.specific.CQAnd) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery)

Example 24 with ManagedQuery

use of com.bakdata.conquery.models.query.ManagedQuery in project conquery by bakdata.

the class PermissionCleanupTaskTest method doNotDeletePermissionValidReference.

@Test
void doNotDeletePermissionValidReference() {
    assertThat(STORAGE.getAllExecutions()).isEmpty();
    final ManagedQuery managedQuery = createManagedQuery();
    // Saving the Execution
    User user = new User("test", "test", STORAGE);
    STORAGE.updateUser(user);
    user.addPermission(ExecutionPermission.onInstance(AbilitySets.QUERY_CREATOR, managedQuery.getId()));
    deleteQueryPermissionsWithMissingRef(STORAGE, STORAGE.getAllUsers());
    assertThat(user.getPermissions()).containsOnly(ExecutionPermission.onInstance(AbilitySets.QUERY_CREATOR, managedQuery.getId()));
}
Also used : User(com.bakdata.conquery.models.auth.entities.User) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) Test(org.junit.jupiter.api.Test)

Example 25 with ManagedQuery

use of com.bakdata.conquery.models.query.ManagedQuery 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)

Aggregations

ManagedQuery (com.bakdata.conquery.models.query.ManagedQuery)37 ConceptQuery (com.bakdata.conquery.apiv1.query.ConceptQuery)18 Test (org.junit.jupiter.api.Test)18 CQReusedQuery (com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery)13 User (com.bakdata.conquery.models.auth.entities.User)12 CQConcept (com.bakdata.conquery.apiv1.query.concept.specific.CQConcept)8 Dataset (com.bakdata.conquery.models.datasets.Dataset)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 CsvSource (org.junit.jupiter.params.provider.CsvSource)6 CQAnd (com.bakdata.conquery.apiv1.query.concept.specific.CQAnd)5 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)5 List (java.util.List)5 Slf4j (lombok.extern.slf4j.Slf4j)5 CQExternal (com.bakdata.conquery.apiv1.query.concept.specific.external.CQExternal)4 ManagedExecutionId (com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId)4 PrintSettings (com.bakdata.conquery.models.query.PrintSettings)4 QueryDescription (com.bakdata.conquery.apiv1.query.QueryDescription)3 ConqueryConfig (com.bakdata.conquery.models.config.ConqueryConfig)3 I18n (com.bakdata.conquery.models.i18n.I18n)3 ResultInfo (com.bakdata.conquery.models.query.resultinfo.ResultInfo)3