<commit_before>package lv.ctco.cukesrest.loadrunner.junit;

import com.jayway.restassured.*;
import com.jayway.restassured.filter.Filter;
import cucumber.runtime.Runtime;
import cucumber.runtime.junit.*;
import cucumber.runtime.model.*;
import lv.ctco.cukesrest.*;
import lv.ctco.cukesrest.loadrunner.*;
import org.junit.runner.notification.*;
import org.junit.runners.model.*;

import java.io.*;
import java.util.*;
import java.util.logging.*;

class LoadRunnerFeature extends FeatureRunner {

    public static final String LOADRUNNER_OUTPUT_DIR = "target/loadrunner_output";

    private final Logger logger = Logger.getLogger(LoadRunnerFeature.class.getName());

    private final String featureName;
    private final LoadRunnerFilter filter;

    public LoadRunnerFeature(CucumberFeature cucumberFeature, Runtime runtime, JUnitReporter jUnitReporter,
                             LoadRunnerFilter filter) throws InitializationError {
        super(cucumberFeature, runtime, jUnitReporter);
        this.filter = filter;
        this.featureName = cucumberFeature.getGherkinFeature().getName();
    }

    @Override
    public void run(RunNotifier notifier) {
        RestAssured.filters(filter);
        filter.createLoadRunnerAction();
        super.run(notifier);

        try {
            boolean mkdirsFailed = new File(LOADRUNNER_OUTPUT_DIR).mkdirs();
            if (mkdirsFailed) throw new CukesRuntimeException("Failed to create Folder: " + LOADRUNNER_OUTPUT_DIR);

            String fileName = featureName + ".vugen";
            File file = new File(LOADRUNNER_OUTPUT_DIR + File.separator + fileName);
            OutputStream out = new FileOutputStream(file);
            filter.dump(out);
            out.close();

            logger.info(file.getAbsolutePath());

            ArrayList<Filter> filtersCopy = new ArrayList<Filter>(RestAssured.filters());
            filtersCopy.remove(filter);
            RestAssured.replaceFiltersWith(filtersCopy);
        } catch (Exception e) {
            throw new CukesRuntimeException(e);
        }
    }


}<commit_msg>Fixed Exception when LoadRunner target folder was already created<commit_after>package lv.ctco.cukesrest.loadrunner.junit;

import com.jayway.restassured.*;
import com.jayway.restassured.filter.Filter;
import cucumber.runtime.Runtime;
import cucumber.runtime.junit.*;
import cucumber.runtime.model.*;
import lv.ctco.cukesrest.*;
import lv.ctco.cukesrest.loadrunner.*;
import org.junit.runner.notification.*;
import org.junit.runners.model.*;

import java.io.*;
import java.util.*;
import java.util.logging.*;

class LoadRunnerFeature extends FeatureRunner {

    public static final String LOADRUNNER_OUTPUT_DIR = "target/loadrunner_output";

    private final Logger logger = Logger.getLogger(LoadRunnerFeature.class.getName());

    private final String featureName;
    private final LoadRunnerFilter filter;

    public LoadRunnerFeature(CucumberFeature cucumberFeature, Runtime runtime, JUnitReporter jUnitReporter,
                             LoadRunnerFilter filter) throws InitializationError {
        super(cucumberFeature, runtime, jUnitReporter);
        this.filter = filter;
        this.featureName = cucumberFeature.getGherkinFeature().getName();
    }

    @Override
    public void run(RunNotifier notifier) {
        RestAssured.filters(filter);
        filter.createLoadRunnerAction();
        super.run(notifier);

        try {
            File dir = new File(LOADRUNNER_OUTPUT_DIR);
            if (!dir.exists()) {
                boolean mkdirsFailed = dir.mkdirs();
                if (mkdirsFailed) throw new CukesRuntimeException("Failed to create Folder: " + LOADRUNNER_OUTPUT_DIR);
            }

            String fileName = featureName + ".vugen";
            File file = new File(LOADRUNNER_OUTPUT_DIR + File.separator + fileName);
            OutputStream out = new FileOutputStream(file);
            filter.dump(out);
            out.close();

            logger.info(file.getAbsolutePath());

            ArrayList<Filter> filtersCopy = new ArrayList<Filter>(RestAssured.filters());
            filtersCopy.remove(filter);
            RestAssured.replaceFiltersWith(filtersCopy);
        } catch (Exception e) {
            throw new CukesRuntimeException(e);
        }
    }


}
{'fraction_non_alphanumeric': 0.0962566844919786, 'fraction_numerical': 0.0, 'mean_word_length': 3.0661625708884688, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4049627', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1129, 'n_words': 249}