Skip to content

Commit

Permalink
Merge pull request #9 from erasmobezerra/develop
Browse files Browse the repository at this point in the history
Updated Develop
  • Loading branch information
erasmobezerra authored Nov 29, 2023
2 parents 62573b9 + 03852dd commit 26c70b4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: java -jar target/whale.jar
web: java -jar target/whale-api.jar
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public ResponseEntity<Object> compactConverter(
@Parameter(description = "Enter the compression format. Choose a tar, zip, 7z or tar.gz") @RequestParam("outputFormat") String outputFormat) throws IOException {
List<byte[]> filesConverted = compactConverterService.converterFile(files, outputFormat);
String convertedFileName = StringUtils.stripFilenameExtension(Objects.requireNonNull(files.get(0).getOriginalFilename()))
+ outputFormat.toLowerCase();
+ "." + outputFormat.toLowerCase();

byte[] responseBytes;
if (filesConverted.size() == 1) responseBytes = filesConverted.get(0);
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ springdoc.api-docs.path=/api-docs
## Path Dos Certificados
certificate.path=${CERTIFICATE_PATCH:/home/mywhalecom/resources/certificatesmodels/}

server.port=${PORT:5047}
# Port Heroku
server.port=${PORT:8080}
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
spring.profiles.active=dev
spring.profiles.active=prod
21 changes: 7 additions & 14 deletions src/test/java/com/whale/web/documents/DocumentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,13 @@ void testCompactConverterForOneArchive() throws Exception {
MockMultipartFile file = createTestZipFile();
String outputFormat = "tar";

MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.multipart("/api/v1/documents/compactconverter")
mockMvc.perform(MockMvcRequestBuilders.multipart("/api/v1/documents/compactconverter")
.file(file)
.param("outputFormat", outputFormat))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.header().string("Content-Disposition", "attachment; filename=zip-test" + outputFormat))
.andExpect(MockMvcResultMatchers.header().string("Content-Disposition", "attachment; filename=zip-test." + outputFormat))
.andExpect(MockMvcResultMatchers.header().string("Content-Type", "application/octet-stream"))
.andReturn();

MockHttpServletResponse response = mvcResult.getResponse();
assertEquals("application/octet-stream", response.getContentType());
assertEquals("attachment; filename=zip-test" + outputFormat, response.getHeader("Content-Disposition"));
.andReturn();
}

@Test
Expand All @@ -156,18 +152,15 @@ void testCompactConverterForTwoArchives() throws Exception {
MockMultipartFile file2 = createTestZipFile();
String outputFormat = "7z";

MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.multipart("/api/v1/documents/compactconverter")
mockMvc.perform(MockMvcRequestBuilders.multipart("/api/v1/documents/compactconverter")
.file(file1)
.file(file2)
.param("outputFormat", outputFormat))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.header().string("Content-Disposition", "attachment; filename=zip-test" + outputFormat))
.andExpect(MockMvcResultMatchers.header().string("Content-Disposition", "attachment; filename=zip-test." + outputFormat))
.andExpect(MockMvcResultMatchers.header().string("Content-Type", "application/octet-stream"))
.andReturn();

MockHttpServletResponse response = mvcResult.getResponse();
assertEquals("application/octet-stream", response.getContentType());
assertEquals("attachment; filename=zip-test" + outputFormat, response.getHeader("Content-Disposition"));
}

@Test
Expand All @@ -193,7 +186,7 @@ void compressFileShouldReturnTheFileZip() throws Exception {
verify(compressorService, times(1)).compressFiles(any());
}

@Test
/* @Test
void shouldReturnTheCertificatesStatusCode200() throws Exception {
String csvContent = "col1,col2,col3\nvalue1,value2,value3";
Expand Down Expand Up @@ -221,7 +214,7 @@ void shouldReturnTheCertificatesStatusCode200() throws Exception {
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_OCTET_STREAM_VALUE))
.andExpect(MockMvcResultMatchers.header().string("Content-Disposition", Matchers.containsString("attachment")));
}
}*/

@Test
void shouldReturnARedirectionStatusCode500() throws Exception {
Expand Down

0 comments on commit 26c70b4

Please sign in to comment.