<commit_before>package org.smoothbuild.builtin.file;

import static org.assertj.core.api.Assertions.assertThat;
import static org.smoothbuild.fs.base.Path.path;

import org.junit.Test;
import org.smoothbuild.builtin.file.err.DuplicateMergedPathError;
import org.smoothbuild.fs.base.Path;
import org.smoothbuild.integration.IntegrationTestCase;
import org.smoothbuild.testing.parse.ScriptBuilder;
import org.smoothbuild.testing.type.impl.FakeFile;

public class MergeSmoothTest extends IntegrationTestCase {

  @Test
  public void mergingTwoSets() throws Exception {
    // given
    Path outputPath = path("output");
    Path path1 = path("def/fileA.txt");
    Path path2 = path("def/fileB.txt");
    fileSystem.createFileContainingItsPath(path1);
    fileSystem.createFileContainingItsPath(path2);

    ScriptBuilder builder = new ScriptBuilder();
    builder.addLine("a : [ file(" + path1 + ") ];");
    builder.addLine("b : [ file(" + path2 + ") ];");
    builder.addLine("run : merge(files=a, with=b) | save(" + outputPath + ");");
    script(builder.build());

    // when
    smoothApp.run("run");

    // then
    messages.assertNoProblems();
    fileSet(outputPath).file(path1).assertContentContainsFilePath();
    fileSet(outputPath).file(path2).assertContentContainsFilePath();
    assertThat(fileSet(outputPath)).hasSize(2);
  }

  @Test
  public void mergingFailsWhenSetsContainFileWithTheSamePath() throws Exception {
    // given
    Path outputPath = path("output");
    Path dirAPath = path("dirA");
    Path dirBPath = path("dirB");
    Path filePath = path("def/fileA.txt");

    FakeFile fileA = fileSet(dirAPath).file(filePath);
    FakeFile fileB = fileSet(dirBPath).file(filePath);
    fileA.createContentWithFilePath();
    fileB.createContentWithFilePath();

    ScriptBuilder builder = new ScriptBuilder();
    builder.addLine("a : files(" + dirAPath + ") ;");
    builder.addLine("b : files(" + dirBPath + ") ;");
    builder.addLine("run : merge(files=a, with=b) | save(" + outputPath + ");");
    script(builder.build());

    // when
    smoothApp.run("run");
<commit_msg>refactored MergeSmoothTest<commit_after>package org.smoothbuild.builtin.file;

import static org.smoothbuild.fs.base.Path.path;

import org.junit.Test;
import org.smoothbuild.builtin.file.err.DuplicateMergedPathError;
import org.smoothbuild.fs.base.Path;
import org.smoothbuild.integration.IntegrationTestCase;
import org.smoothbuild.testing.parse.ScriptBuilder;

public class MergeSmoothTest extends IntegrationTestCase {

  @Test
  public void mergingTwoSets() throws Exception {
    // given
    Path outputPath = path("output");
    Path path1 = path("def/fileA.txt");
    Path path2 = path("def/fileB.txt");
    fileSystem.createFileContainingItsPath(path1);
    fileSystem.createFileContainingItsPath(path2);

    ScriptBuilder builder = new ScriptBuilder();
    builder.addLine("a : [ file(" + path1 + ") ];");
    builder.addLine("b : [ file(" + path2 + ") ];");
    builder.addLine("run : merge(files=a, with=b) | save(" + outputPath + ");");
    script(builder.build());

    // when
    smoothApp.run("run");

    // then
    messages.assertNoProblems();
    fileSystem.assertFileContainsItsPath(outputPath, path1);
    fileSystem.assertFileContainsItsPath(outputPath, path2);
  }

  @Test
  public void mergingFailsWhenSetsContainFileWithTheSamePath() throws Exception {
    // given
    Path dir1Path = path("dirA");
    Path dir2Path = path("dirB");
    Path filePath = path("def/fileA.txt");
    Path outputPath = path("output");

    fileSystem.createFileContainingItsPath(dir1Path, filePath);
    fileSystem.createFileContainingItsPath(dir2Path, filePath);

    ScriptBuilder builder = new ScriptBuilder();
    builder.addLine("a : files(" + dir1Path + ") ;");
    builder.addLine("b : files(" + dir2Path + ") ;");
    builder.addLine("run : merge(files=a, with=b) | save(" + outputPath + ");");
    script(builder.build());

    // when
    smoothApp.run("run");

{'fraction_non_alphanumeric': 0.14465092918131592, 'fraction_numerical': 0.005775991963837268, 'mean_word_length': 4.289508632138114, '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': '6016072', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1217, 'n_words': 215}