use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class DatasetValidationsTest method testArrayPrimaryKeyColumn.
@Test
public void testArrayPrimaryKeyColumn() throws Exception {
ColumnModel column = new ColumnModel().name("array_column").datatype("string").arrayOf(true);
TableModel table = new TableModel().name("table").columns(Collections.singletonList(column)).primaryKey(Collections.singletonList(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[] { "PrimaryKeyArrayColumn" });
}
use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class DatasetValidationsTest method testMissingPrimaryKeyColumn.
@Test
public void testMissingPrimaryKeyColumn() throws Exception {
TableModel table = new TableModel().name("table").columns(Collections.emptyList()).primaryKey(Collections.singletonList("not_a_column"));
DatasetRequestModel req = buildDatasetRequest();
req.getSchema().tables(Collections.singletonList(table)).relationships(Collections.emptyList()).assets(Collections.emptyList());
ErrorModel errorModel = expectBadDatasetCreateRequest(req);
checkValidationErrorModel(errorModel, new String[] { "MissingPrimaryKeyColumn" });
}
use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class DatasetValidationsTest method expectBadDatasetCreateRequest.
private ErrorModel expectBadDatasetCreateRequest(DatasetRequestModel datasetRequest) throws Exception {
MvcResult result = mvc.perform(post("/api/repository/v1/datasets").contentType(MediaType.APPLICATION_JSON).content(TestUtils.mapToJson(datasetRequest))).andExpect(status().is4xxClientError()).andReturn();
MockHttpServletResponse response = result.getResponse();
String responseBody = response.getContentAsString();
assertTrue("Error model was returned on failure", StringUtils.contains(responseBody, "message"));
ErrorModel errorModel = TestUtils.mapFromJson(responseBody, ErrorModel.class);
return errorModel;
}
use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class DatasetValidationsTest method testDuplicateTableNames.
@Test
public void testDuplicateTableNames() throws Exception {
ColumnModel column = new ColumnModel().name("id").datatype("string");
TableModel table = new TableModel().name("duplicate").columns(Collections.singletonList(column));
DatasetRequestModel req = buildDatasetRequest();
req.getSchema().tables(Arrays.asList(table, table));
ErrorModel errorModel = expectBadDatasetCreateRequest(req);
checkValidationErrorModel(errorModel, new String[] { "DuplicateTableNames", "InvalidRelationshipTermTableColumn", "InvalidRelationshipTermTableColumn", "InvalidAssetTable", "InvalidAssetTableColumn", "InvalidAssetTableColumn", "InvalidRootColumn" });
}
use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class DatasetValidationsTest method testNoRootTable.
@Test
public void testNoRootTable() throws Exception {
AssetModel noRoot = new AssetModel().name("bad").tables(Collections.singletonList(buildAssetParticipantTable())).follow(Collections.singletonList("participant_sample"));
DatasetRequestModel req = buildDatasetRequest();
req.getSchema().assets(Collections.singletonList(noRoot));
ErrorModel errorModel = expectBadDatasetCreateRequest(req);
checkValidationErrorModel(errorModel, new String[] { "NotNull", "NotNull", "NoRootTable" });
}
Aggregations