feat: Add S3 hook support for upload, download, and list operations#749
feat: Add S3 hook support for upload, download, and list operations#749therev2 wants to merge 4 commits intoauthorjapps:masterfrom
Conversation
|
@authorjapps i added the tests and they are present in the file S3integrationtest.java file where the tests are Mockito based which get mapped to .json format |
There was a problem hiding this comment.
Pull request overview
Adds first-class S3 step support to Zerocode’s multi-step runner via the s3-bucket: URL prefix, enabling scenario steps to UPLOAD, DOWNLOAD, and LIST S3 objects using AWS SDK v2.
Changes:
- Introduces
S3_CALLAPI type detection and routes S3 steps through the scenario runner + service executor. - Implements S3 client dispatcher (
BasicS3Client) and operation handlers (S3Uploader,S3Downloader,S3Lister) with request/response domain models. - Adds AWS SDK S3 dependency management and new unit tests for the S3 flow.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pom.xml | Adds AWS SDK version property and manages software.amazon.awssdk:s3 version. |
| core/pom.xml | Adds optional software.amazon.awssdk:s3 dependency to the core module. |
| core/src/main/java/org/jsmart/zerocode/core/constants/ZerocodeConstants.java | Adds S3_BUCKET prefix constant used for routing. |
| core/src/main/java/org/jsmart/zerocode/core/utils/ApiType.java | Adds new S3_CALL enum value. |
| core/src/main/java/org/jsmart/zerocode/core/utils/ApiTypeUtils.java | Detects s3-bucket: URLs as S3_CALL. |
| core/src/main/java/org/jsmart/zerocode/core/runner/ZeroCodeMultiStepsScenarioRunnerImpl.java | Routes S3 steps to the executor and normalizes S3.* operations. |
| core/src/main/java/org/jsmart/zerocode/core/engine/executor/ApiServiceExecutor.java | Adds the executeS3Service API. |
| core/src/main/java/org/jsmart/zerocode/core/engine/executor/ApiServiceExecutorImpl.java | Wires S3 execution via an injected BasicS3Client. |
| core/src/main/java/org/jsmart/zerocode/core/s3/client/BasicS3Client.java | Implements S3 client creation, credential resolution, and operation dispatch. |
| core/src/main/java/org/jsmart/zerocode/core/s3/upload/S3Uploader.java | Implements file upload to S3 using request JSON. |
| core/src/main/java/org/jsmart/zerocode/core/s3/download/S3Downloader.java | Implements object download to a local path using request JSON. |
| core/src/main/java/org/jsmart/zerocode/core/s3/list/S3Lister.java | Implements list operation with optional pagination behavior and metadata mapping. |
| core/src/main/java/org/jsmart/zerocode/core/s3/domain/S3Request.java | Adds request model with aliases (filePath, saveAs, folder) and pagination fields. |
| core/src/main/java/org/jsmart/zerocode/core/s3/domain/S3Response.java | Adds response model for upload/list/download outputs. |
| core/src/main/java/org/jsmart/zerocode/core/s3/domain/ObjectInfo.java | Adds list-item metadata model for S3 objects. |
| core/src/test/java/org/jsmart/zerocode/core/utils/ApiTypeUtilsTest.java | Adds unit tests for S3 URL detection and non-S3 regressions. |
| core/src/test/java/org/jsmart/zerocode/core/s3/client/BasicS3ClientTest.java | Adds unit tests verifying operation dispatch behavior. |
| core/src/test/java/org/jsmart/zerocode/core/s3/S3IntegrationTest.java | Adds mocked-S3Client tests for upload/download/list handlers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import java.io.File; | ||
| import java.io.FileWriter; | ||
| import java.lang.reflect.Field; | ||
| import java.nio.file.Files; |
| GetObjectResponse getObjectResponse = GetObjectResponse.builder().build(); | ||
| ResponseInputStream<GetObjectResponse> responseStream = | ||
| new ResponseInputStream<>(getObjectResponse, new ByteArrayInputStream("content".getBytes())); | ||
|
|
| @Inject | ||
| private BasicKafkaClient kafkaClient; | ||
|
|
||
| @Inject(optional = true) |
| String localFilePath = resolveFilePath(request.getFile()); | ||
|
|
||
| LOGGER.debug("Uploading file '{}' to s3://{}/{}", localFilePath, bucketName, request.getKey()); | ||
|
|
||
| PutObjectRequest putRequest = PutObjectRequest.builder() | ||
| .bucket(bucketName) | ||
| .key(request.getKey()) | ||
| .build(); | ||
|
|
||
| s3Client.putObject(putRequest, RequestBody.fromFile(Paths.get(localFilePath))); | ||
|
|
Adds S3 support via the s3-bucket: prefix.
Supports S3.UPLOAD, S3.DOWNLOAD, S3.LIST operations.
Uses AWS_ACCESS_KEY_ID > s3.accessKey > AWS Default profile.
AWS SDK is to avoid bloat.
100% Mockito-backed tests added
Fixes #742