Skip to content

Commit

Permalink
feat: testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sorydi3 committed Aug 8, 2024
1 parent 84a76f8 commit cfc832e
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void test_exemption_is_thrown_when_url_is_not_reachable() {
// Assert
assertEquals("URL is not reachable, please provide a valid URL.", thrown.getMessage());
}

@Test
public void test_no_exemption_is_thrown_when_valid_url_format_provided() {

Expand All @@ -48,23 +48,29 @@ public void test_no_exemption_is_thrown_when_valid_url_format_provided() {
UrlToPdfRequest request = new UrlToPdfRequest();
request.setUrlInput(valid_format_Url);
// Act
assertDoesNotThrow(() -> {
try {
convertWebsiteToPDF.urlToPdf(request);
});
} catch (Exception e) {
e.printStackTrace();
fail("IOException was thrown: " + e.getMessage());
}

}

@Test void test_pdf_bytes_are_returned_when_valid_url_provided() {
String valid_format_Url = "http://localhost:8080/url-to-pdf";
// Arrange
ConvertWebsiteToPDF convertWebsiteToPDF = new ConvertWebsiteToPDF();
UrlToPdfRequest request = new UrlToPdfRequest();
request.setUrlInput(valid_format_Url);
// Act
ResponseEntity<byte[]> pdfBytes = assertDoesNotThrow(() -> {
return convertWebsiteToPDF.urlToPdf(request);
});

// Assert
assertNotNull(pdfBytes.getBody());
try {
convertWebsiteToPDF.urlToPdf(request);
} catch (Exception e) {
e.printStackTrace();
fail("IOException was thrown: " + e.getMessage());
}
}

}

0 comments on commit cfc832e

Please sign in to comment.