package com.yaoyicloud.render.test;

import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Map;

import org.junit.Test;

import com.yaoyicloud.message.FxyProtos.AntiBribery;
import com.yaoyicloud.message.FxyProtos.CheckSummary;
import com.yaoyicloud.message.FxyProtos.QuestionnaireItem;
import com.yaoyicloud.render.AntiBriberyRender;

public class TestAntiBriberyRender {

    @Test
    public void testRenderDocx() throws IOException {

        byte[] content = Files
            .readAllBytes(Paths.get(getClass().getClassLoader().getResource("docx/antiBribery.docx").getFile()));
        AntiBriberyRender render = new AntiBriberyRender("../temp/");
        String retPath = render.renderDocx(
            AntiBribery.newBuilder()
                .setAntiBriberySummary(CheckSummary.newBuilder().setRiskSummary("high risk").setSuggestion("accept it"))
                .addQuestionnaireItems(
                    QuestionnaireItem.newBuilder().setId(1).setQuestion("question1").setAnswer("answer1"))
                .addQuestionnaireItems(
                    QuestionnaireItem.newBuilder().setId(1).setQuestion("question2").setAnswer("answer2"))
                .build(),
            Map.of(),
            content);

        assertTrue(retPath.length() > 0);
    }

}
