Search in sources :

Example 6 with ColumnModel

use of bio.terra.model.ColumnModel in project jade-data-repo by DataBiosphere.

the class DatasetValidationsTest method testIntPartitionWithBadRange.

@Test
public void testIntPartitionWithBadRange() throws Exception {
    ColumnModel column = new ColumnModel().name("column").datatype("int64");
    TableModel table = new TableModel().name("table").columns(Collections.singletonList(column)).partitionMode(TableModel.PartitionModeEnum.INT).intPartitionOptions(new IntPartitionOptionsModel().column(column.getName()).min(5L).max(2L).interval(-1L));
    DatasetRequestModel req = buildDatasetRequest();
    req.getSchema().tables(Collections.singletonList(table)).relationships(Collections.emptyList()).assets(Collections.emptyList());
    ErrorModel errorModel = expectBadDatasetCreateRequest(req);
    checkValidationErrorModel(errorModel, new String[] { "InvalidIntPartitionRange", "InvalidIntPartitionInterval" });
}
Also used : IntPartitionOptionsModel(bio.terra.model.IntPartitionOptionsModel) DatasetRequestModel(bio.terra.model.DatasetRequestModel) ErrorModel(bio.terra.model.ErrorModel) ColumnModel(bio.terra.model.ColumnModel) TableModel(bio.terra.model.TableModel) AssetTableModel(bio.terra.model.AssetTableModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with ColumnModel

use of bio.terra.model.ColumnModel in project jade-data-repo by DataBiosphere.

the class DatasetValidationsTest method testIntPartitionWithMismatchedType.

@Test
public void testIntPartitionWithMismatchedType() throws Exception {
    ColumnModel column = new ColumnModel().name("column").datatype("timestamp");
    TableModel table = new TableModel().name("table").columns(Collections.singletonList(column)).partitionMode(TableModel.PartitionModeEnum.INT).intPartitionOptions(new IntPartitionOptionsModel().column(column.getName()).min(1L).max(2L).interval(1L));
    DatasetRequestModel req = buildDatasetRequest();
    req.getSchema().tables(Collections.singletonList(table)).relationships(Collections.emptyList()).assets(Collections.emptyList());
    ErrorModel errorModel = expectBadDatasetCreateRequest(req);
    checkValidationErrorModel(errorModel, new String[] { "InvalidIntPartitionColumnType" });
}
Also used : IntPartitionOptionsModel(bio.terra.model.IntPartitionOptionsModel) DatasetRequestModel(bio.terra.model.DatasetRequestModel) ErrorModel(bio.terra.model.ErrorModel) ColumnModel(bio.terra.model.ColumnModel) TableModel(bio.terra.model.TableModel) AssetTableModel(bio.terra.model.AssetTableModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with ColumnModel

use of bio.terra.model.ColumnModel in project jade-data-repo by DataBiosphere.

the class DatasetValidationsTest method testArrayAssetRootColumn.

@Test
public void testArrayAssetRootColumn() throws Exception {
    ColumnModel arrayColumn = new ColumnModel().name("array_data").arrayOf(true).datatype("string");
    DatasetRequestModel req = buildDatasetRequest();
    req.getSchema().getTables().stream().filter(table -> table.getName().equals("sample")).findFirst().ifPresent(sampleTable -> {
        ArrayList<ColumnModel> columns = new ArrayList<>(sampleTable.getColumns());
        columns.add(arrayColumn);
        sampleTable.setColumns(columns);
    });
    AssetTableModel assetTable = new AssetTableModel().name("sample").columns(Collections.emptyList());
    AssetModel asset = new AssetModel().name("bad_root").rootTable("sample").rootColumn(arrayColumn.getName()).tables(Collections.singletonList(assetTable)).follow(Collections.singletonList("participant_sample"));
    req.getSchema().setAssets(Collections.singletonList(asset));
    ErrorModel errorModel = expectBadDatasetCreateRequest(req);
    checkValidationErrorModel(errorModel, new String[] { "InvalidArrayRootColumn" });
}
Also used : DatasetRequestModel(bio.terra.model.DatasetRequestModel) ArrayList(java.util.ArrayList) ErrorModel(bio.terra.model.ErrorModel) AssetModel(bio.terra.model.AssetModel) ColumnModel(bio.terra.model.ColumnModel) AssetTableModel(bio.terra.model.AssetTableModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with ColumnModel

use of bio.terra.model.ColumnModel in project jade-data-repo by DataBiosphere.

the class DatasetValidationsTest method testIntPartitionTooManyPartitions.

@Test
public void testIntPartitionTooManyPartitions() throws Exception {
    ColumnModel column = new ColumnModel().name("column").datatype("int64");
    TableModel table = new TableModel().name("table").columns(Collections.singletonList(column)).partitionMode(TableModel.PartitionModeEnum.INT).intPartitionOptions(new IntPartitionOptionsModel().column(column.getName()).min(0L).max(4001L).interval(1L));
    DatasetRequestModel req = buildDatasetRequest();
    req.getSchema().tables(Collections.singletonList(table)).relationships(Collections.emptyList()).assets(Collections.emptyList());
    ErrorModel errorModel = expectBadDatasetCreateRequest(req);
    checkValidationErrorModel(errorModel, new String[] { "TooManyIntPartitions" });
}
Also used : IntPartitionOptionsModel(bio.terra.model.IntPartitionOptionsModel) DatasetRequestModel(bio.terra.model.DatasetRequestModel) ErrorModel(bio.terra.model.ErrorModel) ColumnModel(bio.terra.model.ColumnModel) TableModel(bio.terra.model.TableModel) AssetTableModel(bio.terra.model.AssetTableModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

AssetTableModel (bio.terra.model.AssetTableModel)9 ColumnModel (bio.terra.model.ColumnModel)9 DatasetRequestModel (bio.terra.model.DatasetRequestModel)8 ErrorModel (bio.terra.model.ErrorModel)8 TableModel (bio.terra.model.TableModel)8 Test (org.junit.Test)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 IntPartitionOptionsModel (bio.terra.model.IntPartitionOptionsModel)4 DatePartitionOptionsModel (bio.terra.model.DatePartitionOptionsModel)2 AssetModel (bio.terra.model.AssetModel)1 ArrayList (java.util.ArrayList)1