2024-06-06 12:54:12 +03:00
|
|
|
package stirling.software.SPDF.utils;
|
|
|
|
|
|
2024-12-24 09:52:53 +00:00
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import stirling.software.SPDF.model.api.converters.HTMLToPdfRequest;
|
2024-06-06 12:54:12 +03:00
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
2024-12-24 09:52:53 +00:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
2024-06-06 12:54:12 +03:00
|
|
|
|
|
|
|
|
public class FileToPdfTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testConvertHtmlToPdf() {
|
|
|
|
|
HTMLToPdfRequest request = new HTMLToPdfRequest();
|
2024-08-03 13:52:50 +02:00
|
|
|
byte[] fileBytes = new byte[0]; // Sample file bytes
|
2024-06-06 12:54:12 +03:00
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|