Search in sources :

Example 1 with ValidityDate

use of com.bakdata.conquery.models.datasets.concepts.ValidityDate 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);
}
Also used : Injectable(com.bakdata.conquery.io.jackson.Injectable) ValidityDate(com.bakdata.conquery.models.datasets.concepts.ValidityDate) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) Table(com.bakdata.conquery.models.datasets.Table) Column(com.bakdata.conquery.models.datasets.Column) Dataset(com.bakdata.conquery.models.datasets.Dataset) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) Validator(javax.validation.Validator) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 2 with ValidityDate

use of com.bakdata.conquery.models.datasets.concepts.ValidityDate in project conquery by bakdata.

the class FEValueTest method sortedValidityDates.

@Test
public void sortedValidityDates() {
    Dataset dataset = new Dataset();
    dataset.setName("testDataset");
    Table table = new Table();
    table.setDataset(dataset);
    table.setName("testTable");
    Column column = new Column();
    column.setName("testColumn");
    column.setTable(table);
    ConceptTreeConnector connector = new ConceptTreeConnector();
    connector.setName("testConnector");
    TreeConcept concept = new TreeConcept();
    concept.setDataset(dataset);
    concept.setName("testConcept");
    ValidityDate val0 = new ValidityDate();
    val0.setName("val0");
    val0.setConnector(connector);
    ValidityDate val1 = new ValidityDate();
    val1.setName("val1");
    val1.setConnector(connector);
    ValidityDate val2 = new ValidityDate();
    val2.setName("val2");
    val2.setConnector(connector);
    List<ValidityDate> validityDates = List.of(val0, val1, val2);
    connector.setColumn(column);
    connector.setConcept(concept);
    connector.setValidityDates(validityDates);
    FETable feTable = FrontEndConceptBuilder.createTable(connector);
    assertThat(feTable.getDateColumn().getOptions()).containsExactly(new FEValue("val0", val0.getId().toString()), new FEValue("val1", val1.getId().toString()), new FEValue("val2", val2.getId().toString()));
}
Also used : FETable(com.bakdata.conquery.apiv1.frontend.FETable) ValidityDate(com.bakdata.conquery.models.datasets.concepts.ValidityDate) FETable(com.bakdata.conquery.apiv1.frontend.FETable) Table(com.bakdata.conquery.models.datasets.Table) Column(com.bakdata.conquery.models.datasets.Column) Dataset(com.bakdata.conquery.models.datasets.Dataset) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) FEValue(com.bakdata.conquery.apiv1.frontend.FEValue) Test(org.junit.jupiter.api.Test)

Aggregations

Column (com.bakdata.conquery.models.datasets.Column)2 Dataset (com.bakdata.conquery.models.datasets.Dataset)2 Table (com.bakdata.conquery.models.datasets.Table)2 ValidityDate (com.bakdata.conquery.models.datasets.concepts.ValidityDate)2 ConceptTreeConnector (com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector)2 TreeConcept (com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)2 Test (org.junit.jupiter.api.Test)2 FETable (com.bakdata.conquery.apiv1.frontend.FETable)1 FEValue (com.bakdata.conquery.apiv1.frontend.FEValue)1 CQTable (com.bakdata.conquery.apiv1.query.concept.filter.CQTable)1 Injectable (com.bakdata.conquery.io.jackson.Injectable)1 MutableInjectableValues (com.bakdata.conquery.io.jackson.MutableInjectableValues)1 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)1 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)1 Validator (javax.validation.Validator)1