test.java.pro.verron.officestamper.test.BasicPowerpointTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of engine Show documentation
Show all versions of engine Show documentation
Office-stamper is a Java template engine for docx documents, forked from org.wickedsource.docx-stamper
package pro.verron.officestamper.test;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.PresentationMLPackage;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Path;
import static pro.verron.officestamper.preset.ExperimentalStampers.pptxStamper;
import static pro.verron.officestamper.test.IOStreams.getInputStream;
import static pro.verron.officestamper.test.IOStreams.getOutputStream;
class BasicPowerpointTest {
@Test
void testStamper()
throws IOException, Docx4JException {
var stamper = pptxStamper();
var templateStream = TestUtils.getResource(Path.of("powerpoint-base.pptx"));
record Person(String name) {}
var context = new Person("Bart");
PresentationMLPackage load = PresentationMLPackage.load(templateStream);
OutputStream outputStream = getOutputStream();
stamper.stamp(load, context, outputStream);
InputStream inputStream = getInputStream(outputStream);
PresentationMLPackage presentationMLPackage = PresentationMLPackage.load(inputStream);
Assertions.assertEquals("""
Hello
Bart
""",
Stringifier.stringifyPowerpoint(presentationMLPackage));
}
}