PR2WordCloud/src/test/java/WordCloudCreatorTest.java

31 lines
933 B
Java

import domain.WordCloudCreator;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
class WordCloudCreatorTest {
@Test
void testInsertWordsIntoTemplate_success() throws IOException {
// Prepare a simple HTML template with placeholder
File template = new File("wordcloud.html");
try (FileWriter fw = new FileWriter(template)) {
fw.write("<html><body><!-- TODO: Hier die generierten Tags einsetzen --></body></html>");
}
WordCloudCreator creator = new WordCloudCreator();
Map<String, Integer> words = Map.of("Test", 3, "Java", 2);
assertTrue(creator.insertWordsIntoTemplate(words));
File output = new File("createdHTML.html");
assertTrue(output.exists());
assertTrue(output.length() > 0);
}
}