use of bio.terra.model.TableModel in project jade-data-repo by DataBiosphere.
the class DatasetValidationsTest method testDatePartitionWithMismatchedType.
@Test
public void testDatePartitionWithMismatchedType() throws Exception {
ColumnModel column = new ColumnModel().name("column").datatype("int64");
TableModel table = new TableModel().name("table").columns(Collections.singletonList(column)).partitionMode(TableModel.PartitionModeEnum.DATE).datePartitionOptions(new DatePartitionOptionsModel().column(column.getName()));
DatasetRequestModel req = buildDatasetRequest();
req.getSchema().tables(Collections.singletonList(table)).relationships(Collections.emptyList()).assets(Collections.emptyList());
ErrorModel errorModel = expectBadDatasetCreateRequest(req);
checkValidationErrorModel(errorModel, new String[] { "InvalidDatePartitionColumnType" });
}
use of bio.terra.model.TableModel in project jade-data-repo by DataBiosphere.
the class DatasetValidationsTest method testIntPartitionWithMissingColumn.
@Test
public void testIntPartitionWithMissingColumn() throws Exception {
TableModel table = new TableModel().name("table").columns(Collections.emptyList()).partitionMode(TableModel.PartitionModeEnum.INT).intPartitionOptions(new IntPartitionOptionsModel().column("not_a_column").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[] { "InvalidIntPartitionColumnName" });
}
use of bio.terra.model.TableModel in project jade-data-repo by DataBiosphere.
the class DatasetValidationsTest method testDatePartitionWithBadOptions.
@Test
public void testDatePartitionWithBadOptions() throws Exception {
TableModel table = new TableModel().name("table").columns(Collections.emptyList()).partitionMode(TableModel.PartitionModeEnum.DATE).intPartitionOptions(new IntPartitionOptionsModel().column("foo").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[] { "MissingDatePartitionOptions", "InvalidIntPartitionOptions" });
}
use of bio.terra.model.TableModel in project jade-data-repo by DataBiosphere.
the class DatasetValidationsTest method testDuplicateColumnNames.
@Test
public void testDuplicateColumnNames() throws Exception {
ColumnModel column = new ColumnModel().name("id").datatype("string");
TableModel table = new TableModel().name("table").columns(Arrays.asList(column, column));
DatasetRequestModel req = buildDatasetRequest();
req.getSchema().tables(Collections.singletonList(table));
ErrorModel errorModel = expectBadDatasetCreateRequest(req);
checkValidationErrorModel(errorModel, new String[] { "DuplicateColumnNames", "InvalidRelationshipTermTableColumn", "InvalidRelationshipTermTableColumn", "InvalidAssetTable", "InvalidAssetTableColumn", "InvalidAssetTableColumn", "InvalidRootColumn" });
}
use of bio.terra.model.TableModel in project jade-data-repo by DataBiosphere.
the class SnapshotConnectedTest method testMinimal.
@Test
public void testMinimal() throws Exception {
DatasetSummaryModel datasetMinimalSummary = setupMinimalDataset();
String datasetName = PDAO_PREFIX + datasetMinimalSummary.getName();
BigQueryProject bigQueryProject = TestUtils.bigQueryProjectForDatasetName(datasetDao, dataLocationService, datasetMinimalSummary.getName());
long datasetParticipants = queryForCount(datasetName, "participant", bigQueryProject);
assertThat("dataset participants loaded properly", datasetParticipants, equalTo(2L));
long datasetSamples = queryForCount(datasetName, "sample", bigQueryProject);
assertThat("dataset samples loaded properly", datasetSamples, equalTo(5L));
SnapshotRequestModel snapshotRequest = makeSnapshotTestRequest(datasetMinimalSummary, "dataset-minimal-snapshot.json");
MockHttpServletResponse response = performCreateSnapshot(snapshotRequest, "");
SnapshotSummaryModel summaryModel = validateSnapshotCreated(snapshotRequest, response);
SnapshotModel snapshotModel = getTestSnapshot(summaryModel.getId(), snapshotRequest, datasetMinimalSummary);
List<TableModel> tables = snapshotModel.getTables();
Optional<TableModel> participantTable = tables.stream().filter(t -> t.getName().equals("participant")).findFirst();
Optional<TableModel> sampleTable = tables.stream().filter(t -> t.getName().equals("sample")).findFirst();
assertThat("participant table exists", participantTable.isPresent(), equalTo(true));
assertThat("sample table exists", sampleTable.isPresent(), equalTo(true));
long snapshotParticipants = queryForCount(summaryModel.getName(), "participant", bigQueryProject);
assertThat("dataset participants loaded properly", snapshotParticipants, equalTo(1L));
assertThat("participant row count matches expectation", participantTable.get().getRowCount(), equalTo(1));
long snapshotSamples = queryForCount(summaryModel.getName(), "sample", bigQueryProject);
assertThat("dataset samples loaded properly", snapshotSamples, equalTo(2L));
assertThat("sample row count matches expectation", sampleTable.get().getRowCount(), equalTo(2));
List<RelationshipModel> relationships = snapshotModel.getRelationships();
assertThat("a relationship comes back", relationships.size(), equalTo(1));
RelationshipModel relationshipModel = relationships.get(0);
assertThat("relationship name is right", relationshipModel.getName(), equalTo("participant_sample"));
assertThat("from table is right", relationshipModel.getFrom().getTable(), equalTo("participant"));
assertThat("from column is right", relationshipModel.getFrom().getColumn(), equalTo("id"));
assertThat("to table is right", relationshipModel.getTo().getTable(), equalTo("sample"));
assertThat("to column is right", relationshipModel.getTo().getColumn(), equalTo("participant_id"));
}
Aggregations