<commit_before>package com.opera.core.systems;

import com.opera.core.systems.runner.OperaRunner;
import com.opera.core.systems.runner.OperaRunnerSettings;
import com.opera.core.systems.arguments.OperaArgument;
import com.opera.core.systems.arguments.OperaCoreArguments;
import com.opera.core.systems.arguments.OperaDesktopArguments;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class OperaRunnerTest {

  private static OperaRunner runner;
  private OperaRunnerSettings settings;

  @Before
  public void beforeEach() {
    settings = new OperaRunnerSettings();
  }

  @Test
  public void testConstruction() {
    runner = new OperaRunner();
    List<OperaArgument> arguments = runner.settings.getArguments().getArguments();

    // TODO(andreastt): Problems with core-gogi disallows us to have -autotestmode as the first argument
    assertNotNull(runner);
    assertNotNull(runner.settings.getProfile());
    assertEquals("autotestmode", arguments.get(2).getArgument());  // 0
    assertEquals("pd", arguments.get(0).getArgument());  // 1
    assertEquals("debugproxy", arguments.get(1).getArgument());  // 2
    assertTrue(Integer.valueOf(arguments.get(1).getValue().split(":")[1]) > 0);  // 2
  }

  @Test
  public void testConstructionWithProductCore() {
    runner = null;  // Cleaning up from previous test

    settings.setProduct("core-desktop");
    runner = new OperaRunner(settings);
    assertNotNull(runner);
    assertTrue(runner.settings.getArguments() instanceof OperaCoreArguments);
  }

  @Test
  public void testConstructionWithProductDesktop() {
    runner = null;  // Cleaning up from previous test

    settings.setProduct("desktop");
    runner = new OperaRunner(settings);
    assertNotNull(runner);
    assertTrue(runner.settings.getArguments() instanceof OperaDesktopArguments);
  }

  @Test
  public void testConstructionWithProfile() {
    runner = null;  // Cleaning up from previous test

    String profile = "/my/profile";
    settings.setProfile(profile);
    runner = new OperaRunner(settings);
    assertNotNull(runner);
    assertEquals(profile, runner.settings.getArguments().getArguments().get(0).getValue());  // 1
  }

  @Test
  public void testConstructionWithPort() {
    runner = null;  // Cleaning up from previous test

    settings.setPort(0);
    runner = new OperaRunner(settings);
    assertNotNull(runner);
    assertTrue(Integer.valueOf(runner.settings.getArguments().getArguments().get(1).getValue().split(":")[1]) > 0);  // 2
  }

  @Test
  public void testConstructionWithArguments() {
    runner = null;  // Cleaning up from previous test

    OperaArguments arguments = new OperaArguments();
    arguments.add("foo");
    arguments.add("bar", "bah");
    arguments.add("baz", "abc");

    settings.setArguments(arguments);
    runner = new OperaRunner(settings);
    assertNotNull(runner);
    assertTrue(runner.settings.getArguments().getArguments().containsAll(arguments.getArguments()));
  }

  @Test
  @Ignore
  public void testStartOpera() {

  }

  @Test
  @Ignore
  public void testStopOpera() {

  }

  @Test
  @Ignore
  public void testIsOperaRunning() {

  }

  @Test<commit_msg>Resetting runner field in beforeEach(), as we seem to be doing this in every test<commit_after>package com.opera.core.systems;

import com.opera.core.systems.runner.OperaRunner;
import com.opera.core.systems.runner.OperaRunnerSettings;
import com.opera.core.systems.arguments.OperaArgument;
import com.opera.core.systems.arguments.OperaCoreArguments;
import com.opera.core.systems.arguments.OperaDesktopArguments;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class OperaRunnerTest {

  private static OperaRunner runner;
  private OperaRunnerSettings settings;

  @Before
  public void beforeEach() {
    settings = new OperaRunnerSettings();
    runner = null;
  }

  @Test
  public void testConstruction() {
    runner = new OperaRunner();
    List<OperaArgument> arguments = runner.settings.getArguments().getArguments();

    // TODO(andreastt): Problems with core-gogi disallows us to have -autotestmode as the first argument
    assertNotNull(runner);
    assertNotNull(runner.settings.getProfile());
    assertEquals("autotestmode", arguments.get(2).getArgument());  // 0
    assertEquals("pd", arguments.get(0).getArgument());  // 1
    assertEquals("debugproxy", arguments.get(1).getArgument());  // 2
    assertTrue(Integer.valueOf(arguments.get(1).getValue().split(":")[1]) > 0);  // 2
  }

  @Test
  public void testConstructionWithProductCore() {
    settings.setProduct("core-desktop");
    runner = new OperaRunner(settings);
    assertNotNull(runner);
    assertTrue(runner.settings.getArguments() instanceof OperaCoreArguments);
  }

  @Test
  public void testConstructionWithProductDesktop() {
    settings.setProduct("desktop");
    runner = new OperaRunner(settings);
    assertNotNull(runner);
    assertTrue(runner.settings.getArguments() instanceof OperaDesktopArguments);
  }

  @Test
  public void testConstructionWithProfile() {
    String profile = "/my/profile";
    settings.setProfile(profile);
    runner = new OperaRunner(settings);
    assertNotNull(runner);
    assertEquals(profile, runner.settings.getArguments().getArguments().get(0).getValue());  // 1
  }

  @Test
  public void testConstructionWithPort() {
    settings.setPort(0);
    runner = new OperaRunner(settings);
    assertNotNull(runner);
    assertTrue(Integer.valueOf(runner.settings.getArguments().getArguments().get(1).getValue().split(":")[1]) > 0);  // 2
  }

  @Test
  public void testConstructionWithArguments() {
    OperaArguments arguments = new OperaArguments();
    arguments.add("foo");
    arguments.add("bar", "bah");
    arguments.add("baz", "abc");

    settings.setArguments(arguments);
    runner = new OperaRunner(settings);
    assertNotNull(runner);
    assertTrue(runner.settings.getArguments().getArguments().containsAll(arguments.getArguments()));
  }

  @Test
  @Ignore
  public void testStartOpera() {

  }

  @Test
  @Ignore
  public void testStopOpera() {

  }

  @Test
  @Ignore
  public void testIsOperaRunning() {

  }

  @Test
{'fraction_non_alphanumeric': 0.12449984610649431, 'fraction_numerical': 0.0052323791935980305, 'mean_word_length': 4.331419196062346, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 9, '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': '2487943', 'n_tokens_mistral': 1907, 'n_tokens_neox': 1821, 'n_words': 388}