<commit_before>/*
 
 Copyright: All contributers to the Umple Project
 
 This file is made available subject to the open source license found at:
 http://umple.org/license

*/

package cruise.umple.docs;

import java.io.File;

import org.junit.*;

import cruise.umple.util.AssertHelper;
import cruise.umple.util.SampleFileWriter;
import cruise.umple.docs.Documenter;

public class DocumenterTest
{

  ContentParser parser;
  Documenter documenter;
  String pathToInput;

  @Before
  public void setUp()
  {
    pathToInput = SampleFileWriter.rationalize("test/cruise/umple/docs");
    File f = new File("source");
    f.mkdirs();
    
    f = new File("target");
    f.mkdirs();
  }
  
  @After
  public void tearDown()
  {
    SampleFileWriter.destroy("example");
    SampleFileWriter.destroy("source");
    SampleFileWriter.destroy("target");
    parser = null;
    documenter = null;
  }

/*
DISABLED BECAUSE OF MAJOR CHANGES WHEN GENERATING USER MANUAL 
  @Test
  public void NoSyntax()
  {
    assertParse("003_noSyntax.txt");
    String actual = documenter.toHtml("myTitle");
    
    File expected = new File(pathToInput,"003_noSyntax.html");
    // System.out.println(actual);
    SampleFileWriter.assertFileContent(expected,actual);
  }

  
  @Test
  public void UmpleGrammar()
  {
    assertParse("002_umpleGrammar.txt");
    String actual = documenter.toHtml("myGrammar");
    
    File expected = new File(pathToInput,"002_umpleGrammar.html");
    // System.out.println(actual);
    SampleFileWriter.assertFileContent(expected,actual);
  }
*/

/*
DISABLED BECAUSE OF MAJOR CHANGES WHEN GENERATING USER MANUAL

  @Test
  public void htmlBodyOne()
  {
    assertParse("001_oneExample.txt");
    String actual = documenter.toHtml("myTitle");
    
    File expected = new File(pathToInput,"001_oneExample.html");
    // System.out.println(actual);
    SampleFileWriter.assertFileContent(expected,actual);
  }
*/
/*
DISABLED BECAUSE OF MAJOR CHANGES WHEN GENERATING USER MANUAL

  @Test
  public void htmlMultipleExamples()
  {
    assertParse("001_multiExample.txt");
    String actual = documenter.toHtml("myTitle2");
    
    File expected = new File(pathToInput,"001_multiExample.html");
    // System.out.println(actual);
    SampleFileWriter.assertFileContent(expected,actual);
  }
*/
  
  @Test
  public void publishCreatesDirectories()
  {
    documenter = new Documenter("a","b");
    documenter.setParser(new ContentParser("content"));
    Assert.assertEquals(true,documenter.publish("example/two/three"));
    Assert.assertEquals(true,(new File("example")).exists());
    Assert.assertEquals(true,(new File("example/two")).exists());
    Assert.assertEquals(true,(new File("example/two/three")).exists());
  }
  
  @Test
  public void publishCreatesFiles()
  {
    assertParse("001_oneExample.txt", false);
    assertParse("001_spaceInName.txt", true);
    Assert.assertEquals(true,documenter.publish("example"));
    
    Assert.assertEquals(true,(new File("example/myTitle.html")).exists());
    Assert.assertEquals(true,(new File("example/myTitle3.html")).exists());
    Assert.assertEquals(1,documenter.numberOfMessages());
    AssertHelper.assertPathEquals("Created 2 manual pages, in 1 groups, including example\\myTitle3.html",documenter.getMessage(0));
  }
  
  @Test
  public void findMe()
  {
    String s = "a\\b";
    String newS = s.replace("\\", "/");
    Assert.assertEquals("a/b", newS);
        
  }
  
  @Test
  public void generate_invalidInput()
  {
    Documenter d = new Documenter("blah","target");
    Assert.assertEquals(false,d.generate());
    Assert.assertEquals("Unknown directory: blah", d.getMessage(0));
  }
  
  @Test
  public void generate_lookForGroupsFile()
  {
    Documenter d = new Documenter("source","target");
    SampleFileWriter.createFile("source/order.group", "General;\nMisc;");
    Assert.assertEquals(true,d.generate());
    Assert.assertEquals("Created Groups: [General] [Misc]",d.getMessage(0));<commit_msg>updating test to indicate new file<commit_after>/*
 
 Copyright: All contributers to the Umple Project
 
 This file is made available subject to the open source license found at:
 http://umple.org/license

*/

package cruise.umple.docs;

import java.io.File;

import org.junit.*;

import cruise.umple.util.AssertHelper;
import cruise.umple.util.SampleFileWriter;
import cruise.umple.docs.Documenter;

public class DocumenterTest
{

  ContentParser parser;
  Documenter documenter;
  String pathToInput;

  @Before
  public void setUp()
  {
    pathToInput = SampleFileWriter.rationalize("test/cruise/umple/docs");
    File f = new File("source");
    f.mkdirs();
    
    f = new File("target");
    f.mkdirs();
  }
  
  @After
  public void tearDown()
  {
    SampleFileWriter.destroy("example");
    SampleFileWriter.destroy("source");
    SampleFileWriter.destroy("target");
    parser = null;
    documenter = null;
  }

/*
DISABLED BECAUSE OF MAJOR CHANGES WHEN GENERATING USER MANUAL 
  @Test
  public void NoSyntax()
  {
    assertParse("003_noSyntax.txt");
    String actual = documenter.toHtml("myTitle");
    
    File expected = new File(pathToInput,"003_noSyntax.html");
    // System.out.println(actual);
    SampleFileWriter.assertFileContent(expected,actual);
  }

  
  @Test
  public void UmpleGrammar()
  {
    assertParse("002_umpleGrammar.txt");
    String actual = documenter.toHtml("myGrammar");
    
    File expected = new File(pathToInput,"002_umpleGrammar.html");
    // System.out.println(actual);
    SampleFileWriter.assertFileContent(expected,actual);
  }
*/

/*
DISABLED BECAUSE OF MAJOR CHANGES WHEN GENERATING USER MANUAL

  @Test
  public void htmlBodyOne()
  {
    assertParse("001_oneExample.txt");
    String actual = documenter.toHtml("myTitle");
    
    File expected = new File(pathToInput,"001_oneExample.html");
    // System.out.println(actual);
    SampleFileWriter.assertFileContent(expected,actual);
  }
*/
/*
DISABLED BECAUSE OF MAJOR CHANGES WHEN GENERATING USER MANUAL

  @Test
  public void htmlMultipleExamples()
  {
    assertParse("001_multiExample.txt");
    String actual = documenter.toHtml("myTitle2");
    
    File expected = new File(pathToInput,"001_multiExample.html");
    // System.out.println(actual);
    SampleFileWriter.assertFileContent(expected,actual);
  }
*/
  
  @Test
  public void publishCreatesDirectories()
  {
    documenter = new Documenter("a","b");
    documenter.setParser(new ContentParser("content"));
    Assert.assertEquals(true,documenter.publish("example/two/three"));
    Assert.assertEquals(true,(new File("example")).exists());
    Assert.assertEquals(true,(new File("example/two")).exists());
    Assert.assertEquals(true,(new File("example/two/three")).exists());
  }
  
  @Test
  public void publishCreatesFiles()
  {
    assertParse("001_oneExample.txt", false);
    assertParse("001_spaceInName.txt", true);
    Assert.assertEquals(true,documenter.publish("example"));
    
    Assert.assertEquals(true,(new File("example/myTitle.html")).exists());
    Assert.assertEquals(true,(new File("example/myTitle3.html")).exists());
    Assert.assertEquals(1,documenter.numberOfMessages());
    AssertHelper.assertPathEquals("Created 2 manual pages, in 1 groups, including example\\UmpleUserManualCombined.html",documenter.getMessage(0));
  }
  
  @Test
  public void findMe()
  {
    String s = "a\\b";
    String newS = s.replace("\\", "/");
    Assert.assertEquals("a/b", newS);
        
  }
  
  @Test
  public void generate_invalidInput()
  {
    Documenter d = new Documenter("blah","target");
    Assert.assertEquals(false,d.generate());
    Assert.assertEquals("Unknown directory: blah", d.getMessage(0));
  }
  
  @Test
  public void generate_lookForGroupsFile()
  {
    Documenter d = new Documenter("source","target");
    SampleFileWriter.createFile("source/order.group", "General;\nMisc;");
    Assert.assertEquals(true,d.generate());
    Assert.assertEquals("Created Groups: [General] [Misc]",d.getMessage(0));
{'fraction_non_alphanumeric': 0.13620430645968953, 'fraction_numerical': 0.009639459188783174, 'mean_word_length': 4.049936788874842, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6076257', 'n_tokens_mistral': 2550, 'n_tokens_neox': 2456, 'n_words': 466}