// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java
// public class Constants {
//     public static final String USE_VAR = "dot_trace";
//     public static final String PATH_VAR = "dot_trace_path";
//     public static final String THRESHOLDS_VAR = "dot_trace_thresholds";
//     public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type";
//     public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes";
//     public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters";
//     public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path";
// }


import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import jetbrains.buildServer.dotTrace.Constants;
import jetbrains.buildServer.dotNet.buildRunner.agent.*;
import org.jetbrains.annotations.NotNull;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.assertj.core.api.BDDAssertions.then;
    myPatternsGenerator = (ResourceGenerator<Context>)myCtx.mock(ResourceGenerator.class, "PatternsGenerator");
    //noinspection unchecked
    myCmdGenerator = (ResourceGenerator<Context>)myCtx.mock(ResourceGenerator.class, "CmdGenerator");
    //noinspection unchecked
    myRunnerParametersService = myCtx.mock(RunnerParametersService.class);
    myBeforeBuildPublisher = myCtx.mock(ResourcePublisher.class, "beforeBuildPublisher");
    myDotTraceBuildPublisher = myCtx.mock(ResourcePublisher.class, "dotTraceBuildPublisher");
    myDotTraceSnapshotsPublisher = myCtx.mock(ResourcePublisher.class, "dotTraceSnapshotsPublisher");
    myCommandLineResource = myCtx.mock(CommandLineResource.class);
    myFileService = myCtx.mock(FileService.class);
    myAssertions = myCtx.mock(RunnerAssertions.class);
  }

  @Test
  public void shouldCreateSetupWhenGetSetup()
  {
    // Given
    final CommandLineSetup baseSetup = new CommandLineSetup("someTool", Arrays.asList(new CommandLineArgument("/arg1", CommandLineArgument.Type.PARAMETER), new CommandLineArgument("/arg2", CommandLineArgument.Type.PARAMETER)), Collections.singletonList(myCommandLineResource));
    final File cmdFile = new File("cmd");
    final File projectFile = new File("project");
    final File snapshotDir = new File("snapshotRoot");
    final File snapshotFile = new File(snapshotDir, DotTraceSetupBuilder.DOT_TRACE_SNAPSHOT_FILE);
    final File patternsFile = new File("patterns");
    final File reportFile = new File("report");
    final Context ctx = new Context(baseSetup, projectFile, snapshotFile, patternsFile, reportFile);

    myCtx.checking(new Expectations() {{
      oneOf(myAssertions).contains(RunnerAssertions.Assertion.PROFILING_IS_NOT_ALLOWED);
      will(returnValue(false));
      
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java
// public class Constants {
//     public static final String USE_VAR = "dot_trace";
//     public static final String PATH_VAR = "dot_trace_path";
//     public static final String THRESHOLDS_VAR = "dot_trace_thresholds";
//     public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type";
//     public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes";
//     public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters";
//     public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path";
// }


// Path: dotTrace-agent/src/test/java/jetbrains/buildServer/dotTrace/agent/DotTraceSetupBuilderTest.java
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import jetbrains.buildServer.dotTrace.Constants;
import jetbrains.buildServer.dotNet.buildRunner.agent.*;
import org.jetbrains.annotations.NotNull;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.assertj.core.api.BDDAssertions.then;

    myPatternsGenerator = (ResourceGenerator<Context>)myCtx.mock(ResourceGenerator.class, "PatternsGenerator");
    //noinspection unchecked
    myCmdGenerator = (ResourceGenerator<Context>)myCtx.mock(ResourceGenerator.class, "CmdGenerator");
    //noinspection unchecked
    myRunnerParametersService = myCtx.mock(RunnerParametersService.class);
    myBeforeBuildPublisher = myCtx.mock(ResourcePublisher.class, "beforeBuildPublisher");
    myDotTraceBuildPublisher = myCtx.mock(ResourcePublisher.class, "dotTraceBuildPublisher");
    myDotTraceSnapshotsPublisher = myCtx.mock(ResourcePublisher.class, "dotTraceSnapshotsPublisher");
    myCommandLineResource = myCtx.mock(CommandLineResource.class);
    myFileService = myCtx.mock(FileService.class);
    myAssertions = myCtx.mock(RunnerAssertions.class);
  }

  @Test
  public void shouldCreateSetupWhenGetSetup()
  {
    // Given
    final CommandLineSetup baseSetup = new CommandLineSetup("someTool", Arrays.asList(new CommandLineArgument("/arg1", CommandLineArgument.Type.PARAMETER), new CommandLineArgument("/arg2", CommandLineArgument.Type.PARAMETER)), Collections.singletonList(myCommandLineResource));
    final File cmdFile = new File("cmd");
    final File projectFile = new File("project");
    final File snapshotDir = new File("snapshotRoot");
    final File snapshotFile = new File(snapshotDir, DotTraceSetupBuilder.DOT_TRACE_SNAPSHOT_FILE);
    final File patternsFile = new File("patterns");
    final File reportFile = new File("report");
    final Context ctx = new Context(baseSetup, projectFile, snapshotFile, patternsFile, reportFile);

    myCtx.checking(new Expectations() {{
      oneOf(myAssertions).contains(RunnerAssertions.Assertion.PROFILING_IS_NOT_ALLOWED);
      will(returnValue(false));
      
      oneOf(myRunnerParametersService).tryGetRunnerParameter(Constants.USE_VAR);