use of com.bakdata.conquery.models.identifiable.CentralRegistry in project conquery by bakdata.
the class SerializationTests method user.
/*
* Only way to add permission without a storage.
*/
@Test
public void user() throws IOException, JSONException {
User user = new User("user", "user", STORAGE);
user.addPermission(DatasetPermission.onInstance(Ability.READ, new DatasetId("test")));
user.addPermission(ExecutionPermission.onInstance(Ability.READ, new ManagedExecutionId(new DatasetId("dataset"), UUID.randomUUID())));
Role role = new Role("company", "company", STORAGE);
user.addRole(role);
CentralRegistry registry = new CentralRegistry();
registry.register(role);
SerializationTestUtil.forType(User.class).registry(registry).injectables(STORAGE).test(user);
}
use of com.bakdata.conquery.models.identifiable.CentralRegistry in project conquery by bakdata.
the class SerializationTests method treeConcept.
@Test
public void treeConcept() throws IOException, JSONException {
Dataset dataset = new Dataset();
dataset.setName("datasetName");
TreeConcept concept = new TreeConcept();
concept.setDataset(dataset);
concept.setLabel("conceptLabel");
concept.setName("conceptName");
Table table = new Table();
Column column = new Column();
column.setLabel("colLabel");
column.setName("colName");
column.setType(MajorTypeId.STRING);
column.setTable(table);
Column dateColumn = new Column();
dateColumn.setLabel("colLabel2");
dateColumn.setName("colName2");
dateColumn.setType(MajorTypeId.DATE);
dateColumn.setTable(table);
table.setColumns(new Column[] { column, dateColumn });
table.setDataset(dataset);
table.setLabel("tableLabel");
table.setName("tableName");
column.setTable(table);
ConceptTreeConnector connector = new ConceptTreeConnector();
connector.setConcept(concept);
connector.setLabel("connLabel");
connector.setName("connName");
connector.setColumn(column);
concept.setConnectors(List.of(connector));
ValidityDate valDate = new ValidityDate();
valDate.setColumn(dateColumn);
valDate.setConnector(connector);
valDate.setLabel("valLabel");
valDate.setName("valName");
connector.setValidityDates(List.of(valDate));
CentralRegistry registry = new CentralRegistry();
registry.register(dataset);
registry.register(concept);
registry.register(column);
registry.register(dateColumn);
registry.register(table);
registry.register(connector);
registry.register(valDate);
final Validator validator = Validators.newValidator();
concept.setValidator(validator);
SerializationTestUtil.forType(TreeConcept.class).registry(registry).injectables(new Injectable() {
@Override
public MutableInjectableValues inject(MutableInjectableValues values) {
return values.add(Validator.class, validator);
}
}).test(concept);
}
use of com.bakdata.conquery.models.identifiable.CentralRegistry in project conquery by bakdata.
the class SerializationTests method formConfig.
@Test
public void formConfig() throws JSONException, IOException {
final CentralRegistry registry = new CentralRegistry();
final Dataset dataset = new Dataset("test-dataset");
registry.register(dataset);
ExportForm form = new ExportForm();
AbsoluteMode mode = new AbsoluteMode();
form.setTimeMode(mode);
mode.setForm(form);
mode.setFeatures(List.of(new CQConcept()));
ObjectMapper mapper = FormConfigProcessor.getMAPPER();
JsonNode values = mapper.valueToTree(form);
FormConfig formConfig = new FormConfig(form.getClass().getAnnotation(CPSType.class).id(), values);
formConfig.setDataset(dataset);
SerializationTestUtil.forType(FormConfig.class).registry(registry).test(formConfig);
}
use of com.bakdata.conquery.models.identifiable.CentralRegistry in project conquery by bakdata.
the class SerializationTests method testFormQuery.
@Test
public void testFormQuery() throws IOException, JSONException {
CQConcept concept = new CQConcept();
final TreeConcept testConcept = new TreeConcept();
Dataset dataset = new Dataset();
dataset.setName("testDataset");
testConcept.setDataset(dataset);
testConcept.setName("concept");
final ConceptTreeConnector connector = new ConceptTreeConnector();
connector.setConcept(testConcept);
connector.setName("connector1");
testConcept.setConnectors(List.of(connector));
concept.setElements(Collections.singletonList(testConcept));
CQTable[] tables = { new CQTable() };
connector.setTable(new Table());
tables[0].setConnector(connector);
tables[0].setConcept(concept);
concept.setTables(Arrays.asList(tables));
ConceptQuery subQuery = new ConceptQuery(concept);
CQOr features = new CQOr();
features.setChildren(Collections.singletonList(concept));
AbsoluteFormQuery query = new AbsoluteFormQuery(subQuery, CDateRange.exactly(LocalDate.now()).toSimpleRange(), ArrayConceptQuery.createFromFeatures(Collections.singletonList(features)), List.of(ExportForm.ResolutionAndAlignment.of(Resolution.COMPLETE, Alignment.NO_ALIGN), ExportForm.ResolutionAndAlignment.of(Resolution.QUARTERS, Alignment.QUARTER)));
CentralRegistry centralRegistry = new CentralRegistry();
centralRegistry.register(dataset);
centralRegistry.register(testConcept);
centralRegistry.register(connector);
SerializationTestUtil.forType(AbsoluteFormQuery.class).registry(centralRegistry).test(query);
}
use of com.bakdata.conquery.models.identifiable.CentralRegistry in project conquery by bakdata.
the class SerializationTests method table.
@Test
public void table() throws JSONException, IOException {
Dataset dataset = new Dataset();
dataset.setName("datasetName");
Table table = new Table();
Column column = new Column();
column.setLabel("colLabel");
column.setName("colName");
column.setType(MajorTypeId.STRING);
column.setTable(table);
table.setColumns(new Column[] { column });
table.setDataset(dataset);
table.setLabel("tableLabel");
table.setName("tableName");
CentralRegistry registry = new CentralRegistry();
registry.register(dataset);
registry.register(table);
registry.register(column);
final Validator validator = Validators.newValidator();
SerializationTestUtil.forType(Table.class).registry(registry).injectables(new Injectable() {
@Override
public MutableInjectableValues inject(MutableInjectableValues values) {
return values.add(Validator.class, validator);
}
}).test(table);
}
Aggregations