Skip to content
Closed
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 @@ -17,6 +17,7 @@ public enum Parameter {
TYPE("type"),
FIELDS("fields"),
LAYER_NAME("layer_name"),
KEY("key")
COLLECTION_TITLE("collection_title"),
FULL_METADATA_LINK("full_metadata_link"),
SUGGESTED_CITATION("suggested_citation"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public ResponseEntity<InlineResponse200> execute(
try {

var uuid = (String) body.getInputs().get(DatasetDownloadEnums.Parameter.UUID.getValue());
var key = (String) body.getInputs().get(DatasetDownloadEnums.Parameter.KEY.getValue());
var startDate = (String) body.getInputs().get(DatasetDownloadEnums.Parameter.START_DATE.getValue());
var endDate = (String) body.getInputs().get(DatasetDownloadEnums.Parameter.END_DATE.getValue());
var multiPolygon = body.getInputs().get(DatasetDownloadEnums.Parameter.MULTI_POLYGON.getValue());
Expand All @@ -63,7 +64,7 @@ public ResponseEntity<InlineResponse200> execute(
// 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, startDate, endDate, multiPolygon, recipient, collectionTitle, fullMetadataLink, suggestedCitation);
var response = restServices.downloadData(uuid, key, startDate, endDate, multiPolygon, recipient, collectionTitle, fullMetadataLink, suggestedCitation);

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 @@ -73,6 +73,7 @@ public void notifyUser(String recipient, String uuid, String startDate, String e

public ResponseEntity<String> downloadData(
String id,
String key,
String startDate,
String endDate,
Object polygons,
Expand All @@ -84,6 +85,7 @@ public ResponseEntity<String> downloadData(

Map<String, String> parameters = new HashMap<>();
parameters.put(DatasetDownloadEnums.Parameter.UUID.getValue(), id);
parameters.put(DatasetDownloadEnums.Parameter.KEY.getValue(), key);
parameters.put(DatasetDownloadEnums.Parameter.START_DATE.getValue(), startDate);
parameters.put(DatasetDownloadEnums.Parameter.END_DATE.getValue(), endDate);
parameters.put(DatasetDownloadEnums.Parameter.RECIPIENT.getValue(), recipient);
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()))
when(restServices.downloadData(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()))
when(restServices.downloadData(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", "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).");

// 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", "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).");
} 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", "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).");

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