# Description This pull request includes several changes aimed at improving the code structure and removing redundant code. The most significant changes involve reordering methods, removing unnecessary annotations, and refactoring constructors to use dependency injection. Autowired now comes via constructor (which also doesn't need autowired annotation as its done by default for configuration) ## Checklist - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have performed a self-review of my own code - [ ] I have attached images of the change if it is UI based - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] If my code has heavily changed functionality I have updated relevant docs on [Stirling-PDFs doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) - [ ] My changes generate no new warnings - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only)
36 lines
1.1 KiB
Java
36 lines
1.1 KiB
Java
package stirling.software.SPDF.utils;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
import stirling.software.SPDF.model.api.converters.HTMLToPdfRequest;
|
|
|
|
import java.io.IOException;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
|
|
public class FileToPdfTest {
|
|
|
|
@Test
|
|
public void testConvertHtmlToPdf() {
|
|
HTMLToPdfRequest request = new HTMLToPdfRequest();
|
|
byte[] fileBytes = new byte[0]; // Sample file bytes
|
|
String fileName = "test.html"; // Sample file name
|
|
boolean htmlFormatsInstalled = true; // Sample boolean value
|
|
|
|
// Check if the method throws IOException
|
|
assertThrows(IOException.class, () -> {
|
|
FileToPdf.convertHtmlToPdf(request, fileBytes, fileName, htmlFormatsInstalled);
|
|
});
|
|
}
|
|
|
|
@Test
|
|
public void testConvertBookTypeToPdf() {
|
|
byte[] bytes = new byte[10]; // Sample bytes
|
|
String originalFilename = "test.epub"; // Sample original filename
|
|
|
|
// Check if the method throws IOException
|
|
assertThrows(IOException.class, () -> {
|
|
FileToPdf.convertBookTypeToPdf(bytes, originalFilename);
|
|
});
|
|
}
|
|
}
|