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);
}
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);
}
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;
}
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()));
}
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);
}
Aggregations