Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ public ResponseEntity<InlineResponse200> execute(
String collectionTitle = DatasetDownloadEnums.Parameter.COLLECTION_TITLE.getStringInput(body);
String fullMetadataLink = DatasetDownloadEnums.Parameter.FULL_METADATA_LINK.getStringInput(body);
String suggestedCitation = DatasetDownloadEnums.Parameter.SUGGESTED_CITATION.getStringInput(body);
String outputFormat = DatasetDownloadEnums.Parameter.OUTPUT_FORMAT.getStringInput(body);
Object multiPolygon = DatasetDownloadEnums.Parameter.MULTI_POLYGON.getObjectInput(body);

// move the notify user email from data-access-service to here to make the first email faster
restServices.notifyUser(recipient, uuid, startDate, endDate, multiPolygon, collectionTitle, fullMetadataLink, suggestedCitation);

var response = restServices.downloadData(uuid, key, startDate, endDate, multiPolygon, recipient, collectionTitle, fullMetadataLink, suggestedCitation);
var response = restServices.downloadData(uuid, key, startDate, endDate, multiPolygon, recipient, collectionTitle, fullMetadataLink, suggestedCitation, outputFormat);

var value = new InlineValue(response.getBody());
var status = new InlineValue(Integer.toString(HttpStatus.OK.value()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public ResponseEntity<String> downloadData(
String recipient,
String collectionTitle,
String fullMetadataLink,
String suggestedCitation
String suggestedCitation,
String outputFormat
) throws JsonProcessingException {

Map<String, String> parameters = new HashMap<>();
Expand All @@ -92,6 +93,9 @@ public ResponseEntity<String> downloadData(
parameters.put(DatasetDownloadEnums.Parameter.COLLECTION_TITLE.getValue(), collectionTitle);
parameters.put(DatasetDownloadEnums.Parameter.FULL_METADATA_LINK.getValue(), fullMetadataLink);
parameters.put(DatasetDownloadEnums.Parameter.SUGGESTED_CITATION.getValue(), suggestedCitation);
if (outputFormat != null) {
parameters.put(DatasetDownloadEnums.Parameter.OUTPUT_FORMAT.getValue(), outputFormat);
}
if (polygons == null || polygons.toString().isEmpty()) {
throw new IllegalArgumentException("Polygons parameter should now be null. If users didn't specify polygons, a 'non-specified' should be sent.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setUp() {

@Test
public void testExecuteDownloadDatasetSuccess() throws JsonProcessingException {
when(restServices.downloadData(any(), any(), any(), any(), any(), any(), any(), any(), any()))
when(restServices.downloadData(any(), any(), any(), any(), any(), any(), any(), any(), any(), any()))
.thenReturn(ResponseEntity.ok("Job submitted with ID: test-job-id"));

ResponseEntity<InlineResponse200> response = restApi.execute(ProcessIdEnum.DOWNLOAD_DATASET.getValue(), executeRequest);
Expand All @@ -65,7 +65,7 @@ public void testExecuteDownloadDatasetSuccess() throws JsonProcessingException {

@Test
public void testExecuteDownloadDatasetError() throws JsonProcessingException {
when(restServices.downloadData(any(), any(), any(), any(), any(), any(), any(), any(), any()))
when(restServices.downloadData(any(), any(), any(), any(), any(), any(), any(), any(), any(), any()))
.thenThrow(new RuntimeException("Error while getting dataset"));

ResponseEntity<InlineResponse200> response = restApi.execute(ProcessIdEnum.DOWNLOAD_DATASET.getValue(), executeRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void testDownloadDataSuccess() throws JsonProcessingException {

// Act
ResponseEntity<String> response = restServices.downloadData(
"test-uuid", "test-dname", "2023-01-01", "2023-01-31", "test-multipolygon", "test@example.com", "Test Ocean Data Collection", "https://metadata.imas.utas.edu.au/.../test-uuid-123", "Cite data as: Mazor, T., Watermeyer, K., Hobley, T., Grinter, V., Holden, R., MacDonald, K. and Ferns, L. (2023).");
"test-uuid", "test-dname", "2023-01-01", "2023-01-31", "test-multipolygon", "test@example.com", "Test Ocean Data Collection", "https://metadata.imas.utas.edu.au/.../test-uuid-123", "Cite data as: Mazor, T., Watermeyer, K., Hobley, T., Grinter, V., Holden, R., MacDonald, K. and Ferns, L. (2023).", "geotiff");

// Assert
assertEquals(ResponseEntity.ok("Job submitted with ID: " + jobId), response);
Expand All @@ -64,7 +64,7 @@ public void testDownloadDataJsonProcessingException() throws JsonProcessingExcep

// Act & Assert
try {
restServices.downloadData("test-uuid", "test-dname", "2023-01-01", "2023-01-31", "test-multipolygon", "test@example.com","Test Ocean Data Collection", "https://metadata.imas.utas.edu.au/.../test-uuid-123", "Cite data as: Mazor, T., Watermeyer, K., Hobley, T., Grinter, V., Holden, R., MacDonald, K. and Ferns, L. (2023).");
restServices.downloadData("test-uuid", "test-dname", "2023-01-01", "2023-01-31", "test-multipolygon", "test@example.com","Test Ocean Data Collection", "https://metadata.imas.utas.edu.au/.../test-uuid-123", "Cite data as: Mazor, T., Watermeyer, K., Hobley, T., Grinter, V., Holden, R., MacDonald, K. and Ferns, L. (2023).", "geotiff");
} catch (JsonProcessingException e) {
assertEquals("Error", e.getMessage());
}
Expand All @@ -80,7 +80,7 @@ public void testDownloadDataCapturesSubmitJobRequest() throws JsonProcessingExce

// Act
ResponseEntity<String> response = restServices.downloadData(
"test-uuid", "test-dname","2023-01-01", "2023-01-31", "non-specified", "test@example.com", "Test Ocean Data Collection", "https://metadata.imas.utas.edu.au/.../test-uuid-123", "Cite data as: Mazor, T., Watermeyer, K., Hobley, T., Grinter, V., Holden, R., MacDonald, K. and Ferns, L. (2023).");
"test-uuid", "test-dname","2023-01-01", "2023-01-31", "non-specified", "test@example.com", "Test Ocean Data Collection", "https://metadata.imas.utas.edu.au/.../test-uuid-123", "Cite data as: Mazor, T., Watermeyer, K., Hobley, T., Grinter, V., Holden, R., MacDonald, K. and Ferns, L. (2023).", "geotiff");

// Capture the submitted request
ArgumentCaptor<SubmitJobRequest> captor =
Expand Down
Loading