Search in sources :

Example 1 with DatasetRequestModel

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

the class DatasetRequestValidator method validate.

@Override
public void validate(@NotNull Object target, Errors errors) {
    if (target != null && target instanceof DatasetRequestModel) {
        DatasetRequestModel datasetRequest = (DatasetRequestModel) target;
        validateDatasetName(datasetRequest.getName(), errors);
        DatasetSpecificationModel schema = datasetRequest.getSchema();
        if (schema != null) {
            validateSchema(schema, errors);
        }
    }
}
Also used : DatasetSpecificationModel(bio.terra.model.DatasetSpecificationModel) DatasetRequestModel(bio.terra.model.DatasetRequestModel)

Example 2 with DatasetRequestModel

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

the class DatasetDaoTest method datasetTest.

@Test
public void datasetTest() throws IOException, SQLException {
    DatasetRequestModel request = jsonLoader.loadObject("dataset-create-test.json", DatasetRequestModel.class);
    String expectedName = request.getName() + UUID.randomUUID().toString();
    UUID datasetId = createDataset(request, expectedName);
    try {
        Dataset fromDB = datasetDao.retrieve(datasetId);
        assertThat("dataset name is set correctly", fromDB.getName(), equalTo(expectedName));
        // verify tables
        assertThat("correct number of tables created for dataset", fromDB.getTables().size(), equalTo(2));
        fromDB.getTables().forEach(this::assertDatasetTable);
        assertThat("correct number of relationships are created for dataset", fromDB.getRelationships().size(), equalTo(2));
        assertTablesInRelationship(fromDB);
        // verify assets
        assertThat("correct number of assets created for dataset", fromDB.getAssetSpecifications().size(), equalTo(2));
        fromDB.getAssetSpecifications().forEach(this::assertAssetSpecs);
    } finally {
        datasetDao.delete(datasetId);
    }
}
Also used : DatasetRequestModel(bio.terra.model.DatasetRequestModel) UUID(java.util.UUID) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with DatasetRequestModel

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

the class DatasetValidationsTest method testDuplicateAssetNames.

@Test
public void testDuplicateAssetNames() throws Exception {
    DatasetRequestModel req = buildDatasetRequest();
    req.getSchema().assets(Arrays.asList(buildAsset(), buildAsset()));
    ErrorModel errorModel = expectBadDatasetCreateRequest(req);
    checkValidationErrorModel(errorModel, new String[] { "DuplicateAssetNames" });
}
Also used : DatasetRequestModel(bio.terra.model.DatasetRequestModel) ErrorModel(bio.terra.model.ErrorModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with DatasetRequestModel

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

the class DatasetValidationsTest method testInvalidAssetTable.

@Test
public void testInvalidAssetTable() throws Exception {
    AssetTableModel invalidAssetTable = new AssetTableModel().name("mismatched_table_name").columns(Collections.emptyList());
    AssetModel asset = new AssetModel().name("bad_asset").rootTable("mismatched_table_name").tables(Collections.singletonList(invalidAssetTable)).follow(Collections.singletonList("participant_sample"));
    DatasetRequestModel req = buildDatasetRequest();
    req.getSchema().assets(Collections.singletonList(asset));
    ErrorModel errorModel = expectBadDatasetCreateRequest(req);
    checkValidationErrorModel(errorModel, new String[] { "NotNull", "InvalidAssetTable", "InvalidRootColumn" });
}
Also used : DatasetRequestModel(bio.terra.model.DatasetRequestModel) ErrorModel(bio.terra.model.ErrorModel) AssetModel(bio.terra.model.AssetModel) AssetTableModel(bio.terra.model.AssetTableModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with DatasetRequestModel

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

the class DatasetValidationsTest method testPartitionOptionsWithoutMode.

@Test
public void testPartitionOptionsWithoutMode() throws Exception {
    TableModel table = new TableModel().name("table").columns(Collections.emptyList()).datePartitionOptions(new DatePartitionOptionsModel().column("foo")).intPartitionOptions(new IntPartitionOptionsModel().column("bar").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[] { "InvalidDatePartitionOptions", "InvalidIntPartitionOptions" });
}
Also used : IntPartitionOptionsModel(bio.terra.model.IntPartitionOptionsModel) DatasetRequestModel(bio.terra.model.DatasetRequestModel) DatePartitionOptionsModel(bio.terra.model.DatePartitionOptionsModel) ErrorModel(bio.terra.model.ErrorModel) TableModel(bio.terra.model.TableModel) AssetTableModel(bio.terra.model.AssetTableModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

DatasetRequestModel (bio.terra.model.DatasetRequestModel)29 Test (org.junit.Test)23 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)23 ErrorModel (bio.terra.model.ErrorModel)21 AssetTableModel (bio.terra.model.AssetTableModel)16 TableModel (bio.terra.model.TableModel)13 ColumnModel (bio.terra.model.ColumnModel)8 IntPartitionOptionsModel (bio.terra.model.IntPartitionOptionsModel)6 AssetModel (bio.terra.model.AssetModel)5 DatePartitionOptionsModel (bio.terra.model.DatePartitionOptionsModel)4 UUID (java.util.UUID)3 RelationshipModel (bio.terra.model.RelationshipModel)2 BillingProfileModel (bio.terra.model.BillingProfileModel)1 DatasetSpecificationModel (bio.terra.model.DatasetSpecificationModel)1 RelationshipTermModel (bio.terra.model.RelationshipTermModel)1 Dataset (bio.terra.service.dataset.Dataset)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1