<commit_before>package bla.tm.preconditions;

import bla.tm.definitions.site.pantheon.UserLogInDefinition;
import org.jbehave.core.annotations.BeforeStory;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import java.io.FileReader;
import java.io.IOException;

import static net.serenitybdd.core.Serenity.getCurrentSession;

public class Before_User_Story {

    @BeforeStory()
    public void putUserCredsInSession () throws IOException, ParseException {
        System.out.println("Before Story ...");
        UserLogInDefinition definition = new UserLogInDefinition();

        //Before test is started we are going to put user credentials to current Session
        getCurrentSession().put("username", definition.getLogin(parseJson()));
        getCurrentSession().put("password", definition.getPassword(parseJson()));
    }

    public JSONObject parseJson(){
        JSONParser parser = new JSONParser();

        Object obj = null;
        try {
            obj = parser.parse(new FileReader(System.getProperty("user.dir") + "\\src\\test\\resources\\json\\users.json"));
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        JSONObject jsonObject = (JSONObject) obj;
        return jsonObject;
    }

}
<commit_msg>Refactored @BeforeStory on  @BeforeScenario<commit_after>package bla.tm.preconditions;

import bla.tm.definitions.site.pantheon.UserLogInDefinition;
import org.jbehave.core.annotations.BeforeScenario;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import java.io.FileReader;
import java.io.IOException;

import static net.serenitybdd.core.Serenity.getCurrentSession;

public class Before_User_Story {

    @BeforeScenario()
    public void putUserCredsInSession () throws IOException, ParseException {
        System.out.println("Before Story ...");
        UserLogInDefinition definition = new UserLogInDefinition();

        //Before test is started we are going to put user credentials to current Session
        getCurrentSession().put("username", definition.getLogin(parseJson()));
        getCurrentSession().put("password", definition.getPassword(parseJson()));
    }

    public JSONObject parseJson(){
        JSONParser parser = new JSONParser();

        Object obj = null;
        try {
            obj = parser.parse(new FileReader(System.getProperty("user.dir") + "\\src\\test\\resources\\json\\users.json"));
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        JSONObject jsonObject = (JSONObject) obj;
        return jsonObject;
    }

}

{'fraction_non_alphanumeric': 0.11087570621468927, 'fraction_numerical': 0.0, 'mean_word_length': 3.298937784522003, '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': '7061278', 'n_tokens_mistral': 769, 'n_tokens_neox': 755, 'n_words': 167}