Skip to content

Commit

Permalink
fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
candreac committed Oct 31, 2023
1 parent 41154d0 commit cd5ef79
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
import io.vertx.core.buffer.Buffer;
import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersionPK;
import it.gov.pagopa.atmlayer.service.model.model.BpmnIdDto;
import it.gov.pagopa.atmlayer.service.model.model.filestorage.FileObject;
import it.gov.pagopa.atmlayer.service.model.model.filestorage.FormData;
import it.gov.pagopa.atmlayer.service.model.properties.ObjectStoreProperties;
import it.gov.pagopa.atmlayer.service.model.resource.filestorage.FileStorageCommonResource;
import it.gov.pagopa.atmlayer.service.model.service.BpmnFileStorageService;
import jakarta.inject.Inject;
Expand Down Expand Up @@ -38,6 +38,8 @@
public class FileStorageResource extends FileStorageCommonResource {
@Inject
S3AsyncClient s3;
@Inject
ObjectStoreProperties objectStoreProperties;

@Inject
BpmnFileStorageService bpmnFileStorageService;
Expand Down Expand Up @@ -77,7 +79,7 @@ public RestMulti<Buffer> downloadFile(String objectKey) {
@GET
public Uni<List<FileObject>> listFiles() {
ListObjectsRequest listRequest = ListObjectsRequest.builder()
.bucket(bucketName)
.bucket(objectStoreProperties.bucket().name())
.build();

return Uni.createFrom().completionStage(() -> s3.listObjects(listRequest))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
package it.gov.pagopa.atmlayer.service.model.resource.filestorage;

import it.gov.pagopa.atmlayer.service.model.model.filestorage.FormData;
import it.gov.pagopa.atmlayer.service.model.properties.ObjectStoreProperties;
import jakarta.inject.Inject;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
import software.amazon.awssdk.services.s3.model.PutObjectRequest;

abstract public class FileStorageCommonResource {

@ConfigProperty(name = "bucket.name")
public String bucketName;
@Inject
ObjectStoreProperties objectStoreProperties;

protected PutObjectRequest buildPutRequest(FormData formData) {
return PutObjectRequest.builder()
.bucket(bucketName)
.bucket(objectStoreProperties.bucket().name())
.key(formData.filename)
.contentType(formData.mimetype)
.build();
}

protected GetObjectRequest buildGetRequest(String objectKey) {
return GetObjectRequest.builder()
.bucket(bucketName)
.bucket(objectStoreProperties.bucket().name())
.key(objectKey)
.build();
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ quarkus.s3.aws.region=${MODEL_OBJECT_STORE_REGION:eu-south-1}
###################
# OBJECT STORE
###################
bucket.name=${MODEL_OBJECT_STORE_BUCKET_NAME:pagopa-dev-atm-layer-s3-model}
object-store.type=${MODEL_OBJECT_STORE_TYPE:AWS_S3}
object-store.bucket.name=${MODEL_OBJECT_STORE_BUCKET_NAME:pagopa-dev-atm-layer-s3-model}
object-store.bpmn.path-template=${MODEL_OBJECT_STORE_BPMN_TEMPLATE_PATH:/BPMN/files/UUID/[uuid]/VERSION/[version]}



Expand Down
5 changes: 4 additions & 1 deletion src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
quarkus.devservices.enabled=false
quarkus.devservices.enabled=false
object-store.type=${MODEL_OBJECT_STORE_TYPE:AWS_S3}
object-store.bucket.name=${MODEL_OBJECT_STORE_BUCKET_NAME:pagopa-dev-atm-layer-s3-model}
object-store.bpmn.path-template=${MODEL_OBJECT_STORE_BPMN_TEMPLATE_PATH:/BPMN/files/UUID/[uuid]/VERSION/[version]}

0 comments on commit cd5ef79

Please sign in to comment.