// Path: src/main/java/cz/jiripinkas/jsitemapgenerator/exception/WebmasterToolsException.java
// public class WebmasterToolsException extends RuntimeException {
// 
//     public WebmasterToolsException(String message, Throwable ex) {
//         super(message, ex);
//     }
// 
//     public WebmasterToolsException(String message) {
//         super(message);
//     }
// 
//     public WebmasterToolsException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: src/test/java/cz/jiripinkas/jsitemapgenerator/util/TestUtil.java
// public class TestUtil {
// 
// 	public static void testSitemapXsd(InputStream sitemapXml, File xsd) throws SAXException, IOException {
// 		Source xmlFile = new StreamSource(sitemapXml);
// 		SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
// 		Schema schema = schemaFactory.newSchema(xsd);
// 		Validator validator = schema.newValidator();
// 		validator.validate(xmlFile);
// 	}
// 
// 	public static void testSitemapXsdFile(File file, File xsd) throws IOException, SAXException {
// 		try (FileInputStream inputStream = new FileInputStream(file)) {
// 			testSitemapXsd(inputStream, xsd);
// 		}
// 	}
// 
// }


import cz.jiripinkas.jsitemapgenerator.*;
import cz.jiripinkas.jsitemapgenerator.exception.WebmasterToolsException;
import cz.jiripinkas.jsitemapgenerator.util.TestUtil;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.junit.jupiter.api.Assertions.*;

	@Test
	void testConstructAlternateUrls() {
		String actualAlternateUrl = SitemapGenerator.of("http://www.javavids.com")
				.constructUrl(WebPage.builder()
				.name("latest.php")
				.alternateName("de", "latest-de.php")
				.alternateName("es", "latest-es.php")
				.build());
		String expectedAlaternateUrl = "<loc>http://www.javavids.com/latest.php</loc>\n<xhtml:link rel=\"alternate\" hreflang=\"de\" href=\"http://www.javavids.com/latest-de.php\"/>\n" +
				"<xhtml:link rel=\"alternate\" hreflang=\"es\" href=\"http://www.javavids.com/latest-es.php\"/>\n";
		assertEquals(expectedAlaternateUrl, actualAlternateUrl);
	}

	@Test
	void testConstructAlternateUrls2() {
		String actualAlternateUrl = SitemapGenerator.of("http://www.javavids.com").constructUrl(WebPage.builder()
				.name("latest.php")
				.alternateName("de", () -> "latest-de.php")
				.alternateName("es", () -> "latest-es.php")
				.build());
		String expectedAlternateUrl = "<loc>http://www.javavids.com/latest.php</loc>\n<xhtml:link rel=\"alternate\" hreflang=\"de\" href=\"http://www.javavids.com/latest-de.php\"/>\n" +
				"<xhtml:link rel=\"alternate\" hreflang=\"es\" href=\"http://www.javavids.com/latest-es.php\"/>\n";
		assertEquals(expectedAlternateUrl, actualAlternateUrl);
	}

	@Test
	void testConstructSitemap() throws Exception {
		String sitemap = sitemapGenerator.toString();
		ByteArrayInputStream sitemapXml = new ByteArrayInputStream(sitemap.getBytes(StandardCharsets.UTF_8));
// Path: src/main/java/cz/jiripinkas/jsitemapgenerator/exception/WebmasterToolsException.java
// public class WebmasterToolsException extends RuntimeException {
// 
//     public WebmasterToolsException(String message, Throwable ex) {
//         super(message, ex);
//     }
// 
//     public WebmasterToolsException(String message) {
//         super(message);
//     }
// 
//     public WebmasterToolsException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: src/test/java/cz/jiripinkas/jsitemapgenerator/util/TestUtil.java
// public class TestUtil {
// 
// 	public static void testSitemapXsd(InputStream sitemapXml, File xsd) throws SAXException, IOException {
// 		Source xmlFile = new StreamSource(sitemapXml);
// 		SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
// 		Schema schema = schemaFactory.newSchema(xsd);
// 		Validator validator = schema.newValidator();
// 		validator.validate(xmlFile);
// 	}
// 
// 	public static void testSitemapXsdFile(File file, File xsd) throws IOException, SAXException {
// 		try (FileInputStream inputStream = new FileInputStream(file)) {
// 			testSitemapXsd(inputStream, xsd);
// 		}
// 	}
// 
// }


// Path: src/test/java/cz/jiripinkas/jsitemapgenerator/generator/SitemapGeneratorTest.java
import cz.jiripinkas.jsitemapgenerator.*;
import cz.jiripinkas.jsitemapgenerator.exception.WebmasterToolsException;
import cz.jiripinkas.jsitemapgenerator.util.TestUtil;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.junit.jupiter.api.Assertions.*;


	@Test
	void testConstructAlternateUrls() {
		String actualAlternateUrl = SitemapGenerator.of("http://www.javavids.com")
				.constructUrl(WebPage.builder()
				.name("latest.php")
				.alternateName("de", "latest-de.php")
				.alternateName("es", "latest-es.php")
				.build());
		String expectedAlaternateUrl = "<loc>http://www.javavids.com/latest.php</loc>\n<xhtml:link rel=\"alternate\" hreflang=\"de\" href=\"http://www.javavids.com/latest-de.php\"/>\n" +
				"<xhtml:link rel=\"alternate\" hreflang=\"es\" href=\"http://www.javavids.com/latest-es.php\"/>\n";
		assertEquals(expectedAlaternateUrl, actualAlternateUrl);
	}

	@Test
	void testConstructAlternateUrls2() {
		String actualAlternateUrl = SitemapGenerator.of("http://www.javavids.com").constructUrl(WebPage.builder()
				.name("latest.php")
				.alternateName("de", () -> "latest-de.php")
				.alternateName("es", () -> "latest-es.php")
				.build());
		String expectedAlternateUrl = "<loc>http://www.javavids.com/latest.php</loc>\n<xhtml:link rel=\"alternate\" hreflang=\"de\" href=\"http://www.javavids.com/latest-de.php\"/>\n" +
				"<xhtml:link rel=\"alternate\" hreflang=\"es\" href=\"http://www.javavids.com/latest-es.php\"/>\n";
		assertEquals(expectedAlternateUrl, actualAlternateUrl);
	}

	@Test
	void testConstructSitemap() throws Exception {
		String sitemap = sitemapGenerator.toString();
		ByteArrayInputStream sitemapXml = new ByteArrayInputStream(sitemap.getBytes(StandardCharsets.UTF_8));
		TestUtil.testSitemapXsd(sitemapXml, new File("src/test/resources/sitemap.xsd"));