Skip to content

Commit

Permalink
Merge pull request #10 from ProjectBIGWHALE/develop
Browse files Browse the repository at this point in the history
v2.0.7
  • Loading branch information
erasmobezerra authored Nov 29, 2023
2 parents 28a77d8 + 26c70b4 commit edec725
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 23 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
9 changes: 4 additions & 5 deletions src/main/java/com/whale/web/config/OpenApiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ public OpenAPI customOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("My Big Whale API")
.description("API developed for manipulating images and documents for free.")
.contact(new Contact().name("Whalers team").email("mybigwhale@gmail.com").url("https://mybigwhale.com/"))
.version("1.0.0"))
.externalDocs(new ExternalDocumentation().description("Documentation")
.url("https://pastoral-thorn-cf3.notion.site/WHALE-0227a8c241084a1998fa7bb8bc01e35b?pvs=4"));
.description("API developed for manipulating images and documents.")
.contact(new Contact().name("Whalers team").email("mybigwhale@gmail.com"))
.version("1.0.0"));

}

@Bean
Expand Down
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 edec725

Please sign in to comment.