<commit_before>package jUnit;

import static org.junit.Assert.*;
import generalNetwork.state.Profile;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

import org.junit.Test;

import com.google.gson.Gson;

import dta_solver.Simulator;

public class TestSimulation {

  static String parallel_path_network = "JUnitTests/parallelPath.json";
  static String parallel_path_data = "JUnitTests/parallelPathData.json";

  /**
   * @brief Save the simulation for the parallelPath network into file
   */
  public static void registerParallelPath() {
    Simulator simu = new Simulator(parallel_path_network, parallel_path_data,
        false);
    simu.run(false);

    Gson gson = new Gson();

    for (int k = 0; k < simu.time_discretization.getNb_steps(); k++) {
      // Open the file
      Writer writer = null;
      try {
        writer = new FileWriter("JUnitTests/solutions/parallelPath" + k);
      } catch (IOException e) {
        e.printStackTrace();
      }

      gson.toJson(simu.profiles[k], Profile.class, writer);

      // Close the file
      try {
        if (writer != null)
          writer.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }

  @Test
  public void testParallelPath() {
    Simulator simu = new Simulator(parallel_path_network, parallel_path_data,
        false);
    simu.run(false);

    Gson gson = new Gson();
    Profile p;
    for (int k = 0; k < simu.time_discretization.getNb_steps(); k++) {
      Reader reader = null;
      try {
        reader = new FileReader("JUnitTests/solutions/parallelPath" + k);
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }

      p = gson.fromJson(reader, Profile.class);

      simu.profiles[k].junction_info = null;

      System.out.println(gson.toJson(simu.profiles[k], Profile.class));
      System.out.println(gson.toJson(p, Profile.class));

      assertTrue("The result for time step " + k
          + " is not the same as the registered solution",
          p.equals(simu.profiles[k], 1e-6));

      try {
        if (reader != null)
          reader.close();
      } catch (IOException e) {
        e.printStackTrace();
      }<commit_msg>FIX: Simulation jUnit test<commit_after>package jUnit;

import static org.junit.Assert.*;
import generalNetwork.state.Profile;
import generalNetwork.state.State;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

import org.junit.Test;

import com.google.gson.Gson;

import dta_solver.Simulator;

public class TestSimulation {

  static String parallel_path_network = "JUnitTests/parallelPath.json";
  static String parallel_path_data = "JUnitTests/parallelPathData.json";

  /**
   * @brief Save the simulation for the parallelPath network into file
   */
  public static void registerParallelPath() {
    Simulator simu = new Simulator(parallel_path_network, parallel_path_data,
        false);
    State state = simu.run(false);

    Gson gson = new Gson();

    for (int k = 0; k < simu.time_discretization.getNb_steps(); k++) {
      // Open the file
      Writer writer = null;
      try {
        writer = new FileWriter("JUnitTests/solutions/parallelPath" + k);
      } catch (IOException e) {
        e.printStackTrace();
      }

      gson.toJson(state.profiles[k], Profile.class, writer);

      // Close the file
      try {
        if (writer != null)
          writer.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }

  @Test
  public void testParallelPath() {
    Simulator simu = new Simulator(parallel_path_network, parallel_path_data,
        false);
    State state = simu.run(false);

    Gson gson = new Gson();
    Profile p;
    for (int k = 0; k < simu.time_discretization.getNb_steps(); k++) {
      Reader reader = null;
      try {
        reader = new FileReader("JUnitTests/solutions/parallelPath" + k);
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }

      p = gson.fromJson(reader, Profile.class);

      state.profiles[k].junction_info = null;

      System.out.println(gson.toJson(state.profiles[k], Profile.class));
      System.out.println(gson.toJson(p, Profile.class));

      assertTrue("The result for time step " + k
          + " is not the same as the registered solution",
          p.equals(state.profiles[k], 1e-6));

      try {
        if (reader != null)
          reader.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
{'fraction_non_alphanumeric': 0.11594202898550725, 'fraction_numerical': 0.0017050298380221654, 'mean_word_length': 2.7544, 'pattern_counts': {'":': 0, '<': 7, '<?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': '494426', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1430, 'n_words': 345}