added watermark removal test
This commit is contained in:
parent
e1f9d178b0
commit
95af0faecd
@ -0,0 +1,33 @@
|
||||
package com.iqser.red.service.ocr.v1.server.service;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import com.iqser.red.service.ocr.v1.server.AbstractTest;
|
||||
import com.iqser.red.service.ocr.v1.server.utils.OsUtils;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
class WatermarkRemovalServiceTest extends AbstractTest {
|
||||
|
||||
@Autowired
|
||||
private WatermarkRemovalService watermarkRemovalService;
|
||||
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void removeWatermarksTest() {
|
||||
|
||||
String filename = "files/403-17_Fantom_ToxicidadeInalatoriaAguda.pdf";
|
||||
try (var in = new ClassPathResource(filename).getInputStream(); var out = new FileOutputStream(OsUtils.createTmpFileName(filename, "WATERMARK_REMOVED"))) {
|
||||
watermarkRemovalService.removeWatermarks(in, out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,5 +1,8 @@
|
||||
package com.iqser.red.service.ocr.v1.server.utils;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
@ -55,4 +58,8 @@ public final class OsUtils {
|
||||
return "/tmp";
|
||||
}
|
||||
|
||||
public static String createTmpFileName(String filename, String suffix) {
|
||||
|
||||
return Path.of(OsUtils.getTemporaryDirectory()).resolve(Path.of(filename).getFileName()).toString().replace(".pdf", "_" + suffix + ".pdf");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user