package com.knecon.fforesight.service.layoutparser.server.services;

import java.nio.file.Path;
import java.util.List;

import org.junit.jupiter.api.Test;

import com.knecon.fforesight.service.layoutparser.internal.api.queue.LayoutParsingType;
import com.knecon.fforesight.service.layoutparser.processor.model.ClassificationDocument;
import com.knecon.fforesight.service.layoutparser.processor.utils.RectangleTransformations;
import com.knecon.fforesight.service.layoutparser.server.utils.BuildDocumentTest;
import com.knecon.fforesight.service.layoutparser.server.utils.visualizations.PdfDraw;

import lombok.SneakyThrows;

class BodyTextFrameServiceTest extends BuildDocumentTest {

    @Test
    @SneakyThrows
    public void testCalculateBodyTextFrame() {

        String filename = "files/211.pdf";
        String outputFilename = "/tmp/" + Path.of(filename).getFileName() + "_MAINBODY.pdf";
        ClassificationDocument document = parseLayout(filename, LayoutParsingType.CLARIFYND);
        PdfDraw.drawRectanglesPerPage(filename,
                document.getPages().stream().map(page -> List.of(RectangleTransformations.toRectangle2D(page.getBodyTextFrame()))).toList(),
                outputFilename);

    }

}