<commit_before>package gist

import org.junit.Before
import org.junit.Test

class GistCommentFinderIntegrationTests {
  static String oneLineGist = "Some gist content"
  static String twoLineGist = oneLineGist + "\n" + oneLineGist

  GistCommentFinder gistCommentFinder = new GistCommentFinder()
  
  File gistFile
  
  @Before
  void createFile() {
    gistFile = new File("target/gistCommentFinder.txt")
    gistFile.text = ""
  }
  
  @Test
  void whenOneLineGistInFileShouldGetGist() {
    gistFile.text = createGistText(oneLineGist)
    
    def gistsFromFile = gistCommentFinder.findGistsInFile(gistFile)
    assert gistsFromFile.size() == 1
    
    assert gistsFromFile[0].contentLines == [oneLineGist]
    assert gistsFromFile[0].isPublic
  }

  @Test
  void whenTwoLineGistInFileShouldGetGist() {
    gistFile.text = createGistText(twoLineGist)

    def gistsFromFile = gistCommentFinder.findGistsInFile(gistFile)
    assert gistsFromFile.size() == 1

    assert gistsFromFile[0].contentLines == [oneLineGist, oneLineGist]
  }

  @Test
  void shouldGetGistIdFromFile() {
    final String id = "123"

    gistFile.text = createGistText("Some text", [id: id])

    def gistsFromFile = gistCommentFinder.findGistsInFile(gistFile)
    assert gistsFromFile.size() == 1

    assert gistsFromFile[0].id == id
  }

  @Test
  void whenNotPublicShouldGetPublicFromFile() {
    gistFile.text = createGistText("Some text", ['public': 'false'])

    def gistsFromFile = gistCommentFinder.findGistsInFile(gistFile)
    assert gistsFromFile.size() == 1

    assert !gistsFromFile[0].isPublic<commit_msg>Adding integration test for another case that I thought was failing but actually works<commit_after>package gist

import org.junit.Before
import org.junit.Test

class GistCommentFinderIntegrationTests {
  static String oneLineGist = "Some gist content"
  static String twoLineGist = oneLineGist + "\n" + oneLineGist

  GistCommentFinder gistCommentFinder = new GistCommentFinder()
  
  File gistFile
  
  @Before
  void createFile() {
    gistFile = new File("target/gistCommentFinder.txt")
    gistFile.text = ""
  }
  
  @Test
  void whenOneLineGistInFileShouldGetGist() {
    gistFile.text = createGistText(oneLineGist)
    
    def gistsFromFile = gistCommentFinder.findGistsInFile(gistFile)
    assert gistsFromFile.size() == 1
    
    assert gistsFromFile[0].contentLines == [oneLineGist]
    assert gistsFromFile[0].isPublic
  }

  @Test
  void whenTwoLineGistInFileShouldGetGist() {
    gistFile.text = createGistText(twoLineGist)

    def gistsFromFile = gistCommentFinder.findGistsInFile(gistFile)
    assert gistsFromFile.size() == 1

    assert gistsFromFile[0].contentLines == [oneLineGist, oneLineGist]
  }
  
  @Test
  void whenFullFileGistShouldGetGist() {
    gistFile.text = """// <gist>
class TestService {

  def serviceMethod() {
    println "In service method"
  }
}
// </gist>
"""
    
    def gistsFromFile = gistCommentFinder.findGistsInFile(gistFile)
    assert gistsFromFile.size() == 1

    assert gistsFromFile[0].contentLines.size() == 6
    assert gistsFromFile[0].contentLines[5] == "}"
  }

  @Test
  void shouldGetGistIdFromFile() {
    final String id = "123"

    gistFile.text = createGistText("Some text", [id: id])

    def gistsFromFile = gistCommentFinder.findGistsInFile(gistFile)
    assert gistsFromFile.size() == 1

    assert gistsFromFile[0].id == id
  }

  @Test
  void whenNotPublicShouldGetPublicFromFile() {
    gistFile.text = createGistText("Some text", ['public': 'false'])

    def gistsFromFile = gistCommentFinder.findGistsInFile(gistFile)
    assert gistsFromFile.size() == 1

    assert !gistsFromFile[0].isPublic
{'fraction_non_alphanumeric': 0.09888313810950694, 'fraction_numerical': 0.00789975483519477, 'mean_word_length': 4.078838174273859, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6345010', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1252, 'n_words': 239}