Skip to content

Commit

Permalink
merging dev into uat (#181)
Browse files Browse the repository at this point in the history
Co-authored-by: adrrossi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: adrrss <[email protected]>
Co-authored-by: SMANUM <[email protected]>
Co-authored-by: GiacomoB <[email protected]>
Co-authored-by: Simone Munao <[email protected]>
Co-authored-by: ElisKina-dev <[email protected]>
Co-authored-by: EmVal <[email protected]>
Co-authored-by: ElisKina-dev <[email protected]>
Co-authored-by: Gabriele Maiocchi <[email protected]>
Co-authored-by: Giacomo Brancazi <[email protected]>
  • Loading branch information
12 people authored Sep 20, 2024
1 parent ab19dac commit 6a6d325
Show file tree
Hide file tree
Showing 19 changed files with 17,267 additions and 17,325 deletions.
12 changes: 6 additions & 6 deletions _TMP/coverage-results.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

# Coverage Report: JaCoCo

* IntegrationTest (QuarkusTest)
* S3PreSignerLocalTest (QuarkusTest)


| Outcome | Value |
|-------------------------|---------------------------------------------------------------------|
| Code Coverage % | 92.04% |
| :heavy_check_mark: Number of Lines Covered | 2266 |
| :x: Number of Lines Missed | 196 |
| Total Number of Lines | 2462 |
| Code Coverage % | 92.08% |
| :heavy_check_mark: Number of Lines Covered | 2268 |
| :x: Number of Lines Missed | 195 |
| Total Number of Lines | 2463 |


## Details:
Expand Down Expand Up @@ -902,7 +902,7 @@
#### Lines Missed:
- Line #107
- Line #109
```
} catch (IOException e) {
```
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: v1.24.0
version: v1.25.0-dev.3
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>it.gov.pagopa</groupId>
<artifactId>atm-layer-model</artifactId>
<version>1.24.0</version>
<version>1.25.0-dev.3</version>
<name>atm-layer-model</name>
<properties>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public List<ResourceCreationDto> convertToResourceCreationDtoList(ResourceMultip
for (int i = 0; i < multipleDto.getFilenameList().size(); i++) {
ResourceCreationDto resourceCreationDto = new ResourceCreationDto();

resourceCreationDto.setFile(fromStringToFile(multipleDto.getFileList().get(i), multipleDto.getPath()));
resourceCreationDto.setFile(fromStringToFile(multipleDto.getFileList().get(i)));
resourceCreationDto.setFilename(multipleDto.getFilenameList().get(i));
resourceCreationDto.setResourceType(multipleDto.getResourceType());
resourceCreationDto.setPath(multipleDto.getPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,6 @@ public BpmnResource(BpmnVersionService bpmnVersionService, BpmnBankConfigService
this.tracer = tracer;
}

// @GET
// @Produces(MediaType.APPLICATION_JSON)
// public Uni<List<BpmnDTO>> getAllBpmn() {
// return this.bpmnVersionService.getAll()
// .onItem()
// .transform(Unchecked.function(list -> {
// if (list.isEmpty()) {
// log.info("No BPMN files saved in database");
// }
// return bpmnVersionMapper.toDTOList(list);
// }));
// }

@GET
@Path("/{bpmnId}/version/{version}")
@Consumes(MediaType.APPLICATION_JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,6 @@ public Uni<ResourceDTO> updateResource(@RequestBody(required = true) @FormParam(
.transformToUni(updatedResource -> Uni.createFrom().item(resourceEntityMapper.toDTO(updatedResource)));
}

// @GET
// @Produces(MediaType.APPLICATION_JSON)
// public Uni<List<ResourceDTO>> getAll() {
// return this.resourceEntityService.getAll()
// .onItem()
// .transform(Unchecked.function(list -> {
// if (list.isEmpty()) {
// log.info("No Resource files saved in database");
// }
// return resourceEntityMapper.toDTOList(list);
// }));
// }

@GET
@Path("/{uuid}")
@Produces(MediaType.APPLICATION_JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ public WorkflowResourceResource(WorkflowResourceService workflowResourceService,
this.tracer = tracer;
}

// @GET
// @Produces(MediaType.APPLICATION_JSON)
// public Uni<List<WorkflowResourceDTO>> getAll() {
// return this.workflowResourceService.getAll()
// .onItem()
// .transform(Unchecked.function(list -> {
// if (list.isEmpty()) {
// log.info("No Workflow Resource files saved in database");
// }
// return workflowResourceMapper.toDTOList(list);
// }));
// }

@GET
@Path("/filter")
@Produces(MediaType.APPLICATION_JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,39 +152,37 @@ public Uni<List<String>> createResourceMultiple(List<ResourceEntity> resourceEnt
return findBySHA256(resourceEntity.getSha256())
.onItem().transformToUni(x -> {
if (x.isPresent()) {
errors.add(String.format("File %s: Esiste già una risorsa con lo stesso contenuto", filename));
errors.add(String.format("%s-Esiste già una risorsa con lo stesso contenuto", filename));
return Uni.createFrom().nullItem();
}
return resourceFileService.findByStorageKey(resourceEntity.getStorageKey())
.onItem()
.transformToUni(resource -> {
if (resource.isPresent()) {
errors.add(String.format("File %s: Impossibile caricare: la risorsa con lo stesso nome file e percorso esiste già", filename));
errors.add(String.format("%s-Impossibile caricare: la risorsa con lo stesso nome file e percorso esiste già", filename));
return Uni.createFrom().nullItem();
}
return saveAndUpload(resourceEntity, file, filename, resourceCreationDtoList.get(index).getPath())
.onItem().transformToUni(bpmn -> this.findByUUID(resourceEntity.getResourceId())
.onItem().transformToUni(optionalResource -> {
if (optionalResource.isEmpty()) {
errors.add(String.format("File %s: Problema di sincronizzazione sulla creazione della risorsa", filename));
errors.add(String.format("%s-Problema di sincronizzazione sulla creazione della risorsa", filename));
return Uni.createFrom().nullItem();
}
return Uni.createFrom().item(optionalResource.get());
}));
});
})
.onFailure().recoverWithItem(throwable -> {
errors.add(String.format("File %s: %s", filename, throwable.getMessage()));
errors.add(String.format("%s: %s", filename, throwable.getMessage()));
return null;
});
})
.collect().asList()
.onItem().transform(resourceDTOList -> {
if (!errors.isEmpty()) {
throw new AtmLayerException("Alcuni file non sono stati creati: " + String.join(", ", errors),
throw new AtmLayerException("Errore nel caricamento dovuto ai seguenti file: " + String.join(", ", errors),
Response.Status.BAD_REQUEST, RESOURCES_CREATION_ERROR);
} else {
errors.add("file creati senza errori");
}
return errors; // This will be empty if no errors occurred
});
Expand All @@ -202,9 +200,6 @@ public Uni<ResourceEntity> updateResource(UUID uuid, File file) {
}
ResourceEntity resourceEntity = optionalResource.get();
String newFileSha256 = calculateSha256(file);
// if (Objects.equals(resourceEntity.getSha256(), newFileSha256)) {
// throw new AtmLayerException("La risorsa è già presente", Response.Status.BAD_REQUEST, RESOURCE_WITH_SAME_SHA256_ALREADY_EXISTS);
// }
return findBySHA256(newFileSha256)
.onItem().transformToUni(Unchecked.function(x -> {
if (x.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,20 @@
@ApplicationScoped
@Slf4j
public class ResourceEntityStorageServiceImpl implements ResourceEntityStorageService {
@Inject
ObjectStoreStrategy objectStoreStrategy;
private final ObjectStoreStrategy objectStoreStrategy;
private final ObjectStoreService objectStoreService;
@Inject
ObjectStoreProperties objectStoreProperties;
@Inject
ResourceFileService resourceFileService;
private final ObjectStoreProperties objectStoreProperties;
private final ResourceFileService resourceFileService;

@Inject
public ResourceEntityStorageServiceImpl(ObjectStoreStrategy objectStoreStrategy,
ObjectStoreProperties objectStoreProperties) {
ObjectStoreProperties objectStoreProperties,
ResourceFileService resourceFileService) {
this.objectStoreStrategy = objectStoreStrategy;
this.objectStoreService = objectStoreStrategy.getType(
ObjectStoreStrategyEnum.fromValue(objectStoreProperties.type()));
this.objectStoreProperties = objectStoreProperties;
this.resourceFileService = resourceFileService;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
Expand Down Expand Up @@ -93,7 +95,7 @@ public static String toHexString(byte[] hash) {
return hexString.toString();
}

public static File fromStringToFile(String fileBase64, String fileName) {
public static File fromStringToFile(String fileBase64) {
try {
byte[] decodedBytes = Base64.getDecoder().decode(fileBase64);
File tempFile = File.createTempFile("tempfile", ".tmp");
Expand All @@ -111,25 +113,4 @@ public static File fromStringToFile(String fileBase64, String fileName) {
}


// public static boolean isExtensionValid(File file, String fileName) throws IOException, MimeTypeException {
// String detectedExtension = getExtension(file);
// String extension = FilenameUtils.getExtension(fileName);
// if (Objects.equals(extension, "bpmn") || Objects.equals(extension, "dmn")) {
// extension = UtilityValues.XML_EXTENSION.getValue();
// }
// if (Objects.equals(extension, "form")) {
// extension = UtilityValues.TXT_EXTENSION.getValue();
// }
// return Objects.equals(extension, detectedExtension);
// }
//
// public static String getExtension(File file) throws IOException, MimeTypeException {
// Tika tika = new Tika();
// String mimeType = tika.detect(file);
// log.info("Detected mimeType: {}", mimeType);
// MimeTypes allTypes = MimeTypes.getDefaultMimeTypes();
// MimeType type = allTypes.forName(mimeType);
// return type.getExtension().replace(".", "");
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void testJsonPropertyOrder() {
.message("Invalid input data")
.build();

ObjectMapper objectMapper = new ObjectMapper();
try {
String json = objectMapper.writeValueAsString(errorResponse);
assertTrue(json.contains("\"type\":\"Validation Error\""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,66 +47,6 @@ class BpmnResourceTest {
@InjectMock
BpmnBankConfigService bpmnBankConfigService;

// @Test
// void testGetAllBpmn() {
// List<BpmnVersion> bpmnList = new ArrayList<>();
// BpmnVersion bpmnVersion = new BpmnVersion();
// bpmnList.add(bpmnVersion);
// List<BpmnDTO> dtoList = new ArrayList<>();
// BpmnDTO bpmnDTO = new BpmnDTO();
// dtoList.add(bpmnDTO);
// when(bpmnVersionService.getAll()).thenReturn(Uni.createFrom().item(bpmnList));
// when(bpmnVersionMapper.toDTOList(any(ArrayList.class))).thenReturn(dtoList);
// ArrayList result = given()
// .when().get("/api/v1/model/bpmn")
// .then()
// .statusCode(200)
// .extract()
// .body()
// .as(ArrayList.class);
// assertEquals(1, result.size());
// verify(bpmnVersionService, times(1)).getAll();
// verify(bpmnVersionMapper, times(1)).toDTOList(bpmnList);
// }

// @Test
// void testGetAllEmptyList() {
// List<BpmnVersion> bpmnList = new ArrayList<>();
// List<BpmnDTO> dtoList = new ArrayList<>();
// when(bpmnVersionService.getAll()).thenReturn(Uni.createFrom().item(bpmnList));
// when(bpmnVersionMapper.toDTOList(any(ArrayList.class))).thenReturn(dtoList);
// ArrayList result = given()
// .when().get("/api/v1/model/bpmn")
// .then()
// .statusCode(200)
// .extract()
// .body()
// .as(ArrayList.class);
// assertEquals(0, result.size());
// verify(bpmnVersionService, times(1)).getAll();
// verify(bpmnVersionMapper, times(1)).toDTOList(bpmnList);
// }

// @Test
// void testGetAllBpmnEmptyList() {
// List<BpmnVersion> bpmnList = new ArrayList<>();
// BpmnVersion bpmnVersion = new BpmnVersion();
// bpmnList.add(bpmnVersion);
// List<BpmnDTO> dtoList = new ArrayList<>();
// when(bpmnVersionService.getAll()).thenReturn(Uni.createFrom().item(bpmnList));
// when(bpmnVersionMapper.toDTOList(any(ArrayList.class))).thenReturn(dtoList);
// ArrayList result = given()
// .when().get("/api/v1/model/bpmn")
// .then()
// .statusCode(200)
// .extract()
// .body()
// .as(ArrayList.class);
// Assertions.assertTrue(result.isEmpty());
// verify(bpmnVersionService, times(1)).getAll();
// verify(bpmnVersionMapper, times(1)).toDTOList(bpmnList);
// }

@Test
void testGetEncodedFileOK() {
BpmnVersion bpmnVersion = new BpmnVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,43 +81,6 @@ void testUpdateResource() {
assertEquals(resourceDTO, result);
}


// @Test
// void testGetAllResources() {
// List<ResourceEntity> resourceEntities = new ArrayList<>();
// ResourceEntity resourceEntity = new ResourceEntity();
// resourceEntities.add(resourceEntity);
// List<ResourceDTO> dtoList = new ArrayList<>();
// ResourceDTO resourceDTO = new ResourceDTO();
// dtoList.add(resourceDTO);
// when(resourceEntityService.getAll()).thenReturn(Uni.createFrom().item(resourceEntities));
// when(resourceEntityMapper.toDTOList(any(ArrayList.class))).thenReturn(dtoList);
// ArrayList result = given()
// .when().get("/api/v1/model/resources")
// .then()
// .statusCode(200)
// .extract()
// .body()
// .as(ArrayList.class);
// assertEquals(1, result.size());
// verify(resourceEntityService, times(1)).getAll();
// verify(resourceEntityMapper, times(1)).toDTOList(resourceEntities);
// }

// @Test
// void testGetAllResourcesEmptyList() {
// List<ResourceEntity> emptyList = new ArrayList<>();
//
// when(resourceEntityService.getAll()).thenReturn(Uni.createFrom().item(emptyList));
//
// given()
// .when().get("/api/v1/model/resources")
// .then()
// .statusCode(200);
//
// verify(resourceEntityService, times(1)).getAll();
// }

@Test
void testGetResourceById() {
UUID uuid = UUID.randomUUID();
Expand Down
Loading

0 comments on commit 6a6d325

Please sign in to comment.