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