<commit_before>package com.google.sps.image;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.Set;

@RunWith(JUnit4.class)
public final class ImageSelectionTest {
  // This is how every Bing image link starts
  private static final String EXPECTED_LINK = "https://tse";

  private void assertOutputLink(Set<String> keywords, String expectedLink) {
    ImageSelection imageSelection = new ImageSelection(keywords);

    try {
      String actualLink = imageSelection.getBestImage();
      Assert.assertEquals(expectedLink, actualLink.substring(0, 11));
    } catch(IOException ex) {
      // Test fail because the function threw an exception
      Assert.fail(ex.getMessage());
    }
  }

  @Test
  public void singleKeyword() {
    Set<String> keywords = new LinkedHashSet<>();
    keywords.add("london");

    assertOutputLink(keywords, EXPECTED_LINK);
  }

  @Test
  public void specialCharactersKeywords() {
    Set<String> keywords = new LinkedHashSet<>();

    keywords.add("travel");
    keywords.add("morning");
    keywords.add("sun");
    keywords.add("Washington, D.C.");

    assertOutputLink(keywords, EXPECTED_LINK);
  }

  @Test
  public void commonKeywords() {
    Set<String> keywords = new LinkedHashSet<>();

    keywords.add("job");
    keywords.add("promotion");
    keywords.add("engineer");

    assertOutputLink(keywords, EXPECTED_LINK);
  }

  @Test
  public void addSpaceIntoKeywords() {
    Set<String> keywords = new LinkedHashSet<>();
    keywords.add("good morning");

    assertOutputLink(keywords, EXPECTED_LINK);
  }

  @Test
  public void removeExtraKeywords() {
    Set<String> keywords = new LinkedHashSet<>();
    for (char letter = 'a'; letter <= 'z'; ++letter) {
      keywords.add(String.valueOf(letter));
    }

    assertOutputLink(keywords, EXPECTED_LINK);
  }
}<commit_msg>small style change<commit_after>package com.google.sps.image;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.Set;

@RunWith(JUnit4.class)
public final class ImageSelectionTest {
  // This is how every Bing image link starts
  private static final String EXPECTED_LINK = "https://tse";

  private void assertOutputLink(Set<String> keywords, String expectedLink) throws IOException {
    ImageSelection imageSelection = new ImageSelection(keywords);

    String actualLink = imageSelection.getBestImage();
    Assert.assertEquals(expectedLink, actualLink.substring(0, 11));
  }

  @Test
  public void singleKeyword() throws IOException {
    Set<String> keywords = new LinkedHashSet<>();
    keywords.add("london");

    assertOutputLink(keywords, EXPECTED_LINK);
  }

  @Test
  public void specialCharactersKeywords() throws IOException {
    Set<String> keywords = new LinkedHashSet<>();

    keywords.add("travel");
    keywords.add("morning");
    keywords.add("sun");
    keywords.add("Washington, D.C.");

    assertOutputLink(keywords, EXPECTED_LINK);
  }

  @Test
  public void commonKeywords() throws IOException {
    Set<String> keywords = new LinkedHashSet<>();

    keywords.add("job");
    keywords.add("promotion");
    keywords.add("engineer");

    assertOutputLink(keywords, EXPECTED_LINK);
  }

  @Test
  public void addSpaceIntoKeywords() throws IOException {
    Set<String> keywords = new LinkedHashSet<>();
    keywords.add("good morning");

    assertOutputLink(keywords, EXPECTED_LINK);
  }

  @Test
  public void removeExtraKeywords() throws IOException {
    Set<String> keywords = new LinkedHashSet<>();
    for (char letter = 'a'; letter <= 'z'; ++letter) {
      keywords.add(String.valueOf(letter));
    }

    assertOutputLink(keywords, EXPECTED_LINK);
  }
}
{'fraction_non_alphanumeric': 0.1229907452508524, 'fraction_numerical': 0.0024354603019970775, 'mean_word_length': 4.265384615384615, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, 'https://': 2, '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': '7655087', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1171, 'n_words': 282}