package org.studiorailgun;

import static org.junit.jupiter.api.Assertions.*;

import java.io.File;

import org.junit.jupiter.api.Test;
import org.studiorailgun.knowledge.CSVExport;
import org.studiorailgun.knowledge.KnowledgeWeb;

/**
 * Test loading webs
 */
public class LoadingTests {
    


    @Test
    public void testLoadWeb(){
        assertDoesNotThrow(() -> {
            KnowledgeWeb web = FileUtils.loadObjectFromFile(new File("./data/webs/test/web.json"), KnowledgeWeb.class);
            web.initLinks();
        });
    }

    @Test
    public void testExportCSV(){
        assertDoesNotThrow(() -> {
            KnowledgeWeb web = FileUtils.loadObjectFromFile(new File("./data/webs/test/web.json"), KnowledgeWeb.class);
            web.initLinks();
            Globals.web = web;
            CSVExport.export("test");
        });
    }

    @Test
    public void testNoTag(){
        assertThrows(UnsupportedOperationException.class, () -> {
            KnowledgeWeb.load("./data/webs/test/web_no_tag.json");
        });
    }

}
