Skip to content
Snippets Groups Projects
Commit 1601ac43 authored by Joonas Seppä's avatar Joonas Seppä
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
import java.nio.file.*;
import java.util.*;
import java.util.stream.*;
class SiteGen {
static String siteTitle = "My favorite movies";
static List<String> movieList = List.of(
"Star Wars",
"Star Trek",
"Battlestar Galactica"
);
static String htmlString =
"<html>" +
"<head><title>" + siteTitle + "</title></head>" +
"<body>" +
"<h1>" + siteTitle + "</h1>" +
"<ul>" + movieList.stream().map(i -> "<li>"+ i + "</li>").collect(Collectors.joining()) + "</ul>" +
"</body>" +
"<html>";
public static void main(String args[]) throws Exception {
Files.createDirectory(Paths.get("public/"));
Files.write(Paths.get("public/index.html"), htmlString.getBytes());
}
}
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class SiteGenTest {
@Test
public void testHtmlString() {
String correctHtml = "<html><head><title>My favorite movies</title></head><body><h1>My favorite movies</h1><ul><li>Star Wars</li><li>Star Trek</li><li>Battlestar Galactica</li></ul></body></html>";
Assertions.assertEquals(correctHtml, SiteGen.htmlString);
}
}
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment