use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class DatasetConnectedTest method testOverlappingDeletes.
@Test
public void testOverlappingDeletes() throws Exception {
// NO ASSERTS inside the block below where hang is enabled to reduce chance of failing before disabling the hang
// ====================================================
// enable hang in DeleteDatasetPrimaryDataStep
configService.setFault(ConfigEnum.DATASET_DELETE_LOCK_CONFLICT_STOP_FAULT.name(), true);
// try to delete the dataset
MvcResult result1 = mvc.perform(delete("/api/repository/v1/datasets/" + summaryModel.getId())).andReturn();
// give the flight time to launch
TimeUnit.SECONDS.sleep(5);
// try to delete the dataset again
MvcResult result2 = mvc.perform(delete("/api/repository/v1/datasets/" + summaryModel.getId())).andReturn();
// give the flight time to launch
TimeUnit.SECONDS.sleep(5);
// disable hang in DeleteDatasetPrimaryDataStep
configService.setFault(ConfigEnum.DATASET_DELETE_LOCK_CONFLICT_CONTINUE_FAULT.name(), true);
// ====================================================
// check the response from the first delete request
MockHttpServletResponse response1 = connectedOperations.validateJobModelAndWait(result1);
DeleteResponseModel deleteResponseModel = connectedOperations.handleSuccessCase(response1, DeleteResponseModel.class);
assertEquals("First delete returned successfully", DeleteResponseModel.ObjectStateEnum.DELETED, deleteResponseModel.getObjectState());
// check that the second delete failed with a lock exception
MockHttpServletResponse response2 = connectedOperations.validateJobModelAndWait(result2);
ErrorModel errorModel2 = connectedOperations.handleFailureCase(response2, HttpStatus.INTERNAL_SERVER_ERROR);
assertThat("delete failed on lock exception", errorModel2.getMessage(), startsWith("Failed to lock the dataset"));
// try to fetch the dataset again and confirm nothing is returned
connectedOperations.getDatasetExpectError(summaryModel.getId(), HttpStatus.NOT_FOUND);
}
use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class DatasetConnectedTest method testDuplicateName.
@Test
public void testDuplicateName() throws Exception {
assertNotNull("created dataset successfully the first time", summaryModel);
// fetch the dataset and confirm the metadata matches the request
DatasetModel datasetModel = connectedOperations.getDataset(summaryModel.getId());
assertNotNull("fetched dataset successfully after creation", datasetModel);
assertEquals("fetched dataset name matches request", datasetRequest.getName(), datasetModel.getName());
// check that the dataset metadata row is unlocked
String exclusiveLock = datasetDao.getExclusiveLock(UUID.fromString(summaryModel.getId()));
assertNull("dataset row is unlocked", exclusiveLock);
// try to create the same dataset again and check that it fails
ErrorModel errorModel = connectedOperations.createDatasetExpectError(datasetRequest, HttpStatus.BAD_REQUEST);
assertThat("error message includes name conflict", errorModel.getMessage(), containsString("Dataset name already exists"));
// delete the dataset and check that it succeeds
connectedOperations.deleteTestDataset(summaryModel.getId());
// try to fetch the dataset again and confirm nothing is returned
connectedOperations.getDatasetExpectError(summaryModel.getId(), HttpStatus.NOT_FOUND);
}
use of bio.terra.model.ErrorModel 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.ErrorModel 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.ErrorModel 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