Search in sources :

Example 11 with ErrorModel

use of bio.terra.model.ErrorModel 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" });
}
Also used : DatasetRequestModel(bio.terra.model.DatasetRequestModel) DatePartitionOptionsModel(bio.terra.model.DatePartitionOptionsModel) 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 12 with ErrorModel

use of bio.terra.model.ErrorModel 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" });
}
Also used : IntPartitionOptionsModel(bio.terra.model.IntPartitionOptionsModel) DatasetRequestModel(bio.terra.model.DatasetRequestModel) 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)

Example 13 with ErrorModel

use of bio.terra.model.ErrorModel 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" });
}
Also used : IntPartitionOptionsModel(bio.terra.model.IntPartitionOptionsModel) DatasetRequestModel(bio.terra.model.DatasetRequestModel) 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)

Example 14 with ErrorModel

use of bio.terra.model.ErrorModel 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" });
}
Also used : 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 15 with ErrorModel

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

the class ProfileTest method testBadAccount.

@Test
public void testBadAccount() throws Exception {
    String accountId = "blah";
    billingProfileRequest.billingAccountId(accountId);
    String responseJson = mvc.perform(post("/api/resources/v1/profiles").contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer: faketoken").content(TestUtils.mapToJson(billingProfileRequest))).andExpect(status().is4xxClientError()).andReturn().getResponse().getContentAsString();
    ErrorModel errors = objectMapper.readerFor(ErrorModel.class).readValue(responseJson);
    assertThat("invalid billing account", errors.getErrorDetail().get(0), startsWith("billingAccountId"));
}
Also used : ErrorModel(bio.terra.model.ErrorModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ErrorModel (bio.terra.model.ErrorModel)48 Test (org.junit.Test)38 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)38 DatasetRequestModel (bio.terra.model.DatasetRequestModel)21 AssetTableModel (bio.terra.model.AssetTableModel)16 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)16 MvcResult (org.springframework.test.web.servlet.MvcResult)14 TableModel (bio.terra.model.TableModel)13 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)13 ColumnModel (bio.terra.model.ColumnModel)8 IntPartitionOptionsModel (bio.terra.model.IntPartitionOptionsModel)6 AssetModel (bio.terra.model.AssetModel)5 FileModel (bio.terra.model.FileModel)5 DatePartitionOptionsModel (bio.terra.model.DatePartitionOptionsModel)4 IngestRequestModel (bio.terra.model.IngestRequestModel)4 DatasetSummaryModel (bio.terra.model.DatasetSummaryModel)3 DeleteResponseModel (bio.terra.model.DeleteResponseModel)3 FileLoadModel (bio.terra.model.FileLoadModel)3 SnapshotSummaryModel (bio.terra.model.SnapshotSummaryModel)3 Blob (com.google.cloud.storage.Blob)3