<commit_before>package org.osiam.tests.stress;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.osiam.client.connector.OsiamConnector;
import org.osiam.client.oauth.AccessToken;
import org.osiam.client.oauth.GrantType;
import org.osiam.client.oauth.Scope;
import org.osiam.resources.scim.User;

public class OsiamContext {
    private static OsiamContext mySingelton = null;
    private static final String AUTH_ENDPOINT_ADDRESS = "http://localhost:8180/osiam-auth-server";
    private static final String RESOURCE_ENDPOINT_ADDRESS = "http://localhost:8180/osiam-resource-server";
    private static final String CLIENT_ID = "example-client";
    private static final String CLIENT_SECRET = "secret";

    private AccessToken accessToken = null;
    private HashMap<String, OsiamConnector> connectors = new HashMap<String, OsiamConnector>();
    
    private List<User> users = new ArrayList<User>();

    private OsiamContext() {
    }

    public static OsiamContext getInstance() {
        if (mySingelton == null) {
            mySingelton = new OsiamContext();
        }
        return mySingelton;
    }

    public OsiamConnector getConnector(String key) {
        OsiamConnector osiamConnector = connectors.get(key);
        if(osiamConnector == null){
        OsiamConnector.Builder oConBuilder = new OsiamConnector.Builder().
                setAuthServiceEndpoint(AUTH_ENDPOINT_ADDRESS).
                setResourceEndpoint(RESOURCE_ENDPOINT_ADDRESS).
                setClientId(CLIENT_ID).
                setClientSecret(CLIENT_SECRET).
                setGrantType(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS).
                setUserName("marissa").
                setPassword("<PASSWORD>").
                setScope(Scope.ALL);
        osiamConnector = oConBuilder.build();
        connectors.put(key, osiamConnector);
        }
        return osiamConnector;
    }

    public AccessToken getValidAccessToken() {
        if (accessToken == null)
        {
            accessToken = getConnector("accessToken").retrieveAccessToken();
        }
        if (accessToken.isExpired()) {
            getConnector("accessToken").refreshAccessToken(accessToken, Scope.ALL);
        }
        return accessToken;
    }

    public void setListOfUsers(List<User> users) {
        this.users = users;
    }

    public String retrieveSingleUserId() {
        String userId = null;
        if (users.size() > 0) {
            int randomPosition = (int) (Math.random() * users.size() + 1);
            User user = users.get(randomPosition);
            userId = user.getId();
            users.remove(randomPosition);
        }
        return userId;
    }
}<commit_msg>[task] little refactoring<commit_after>package org.osiam.tests.stress;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.osiam.client.connector.OsiamConnector;
import org.osiam.client.oauth.AccessToken;
import org.osiam.client.oauth.GrantType;
import org.osiam.client.oauth.Scope;
import org.osiam.resources.scim.User;

public class OsiamContext {
    private static OsiamContext contextSingelton = null;
    private static final String AUTH_ENDPOINT_ADDRESS = "http://localhost:8180/osiam-auth-server";
    private static final String RESOURCE_ENDPOINT_ADDRESS = "http://localhost:8180/osiam-resource-server";
    private static final String CLIENT_ID = "example-client";
    private static final String CLIENT_SECRET = "secret";

    private AccessToken accessToken = null;
    private HashMap<String, OsiamConnector> connectors = new HashMap<String, OsiamConnector>();
    
    private List<User> users = new ArrayList<User>();

    private OsiamContext() {
    }

    public static OsiamContext getInstance() {
        if (contextSingelton == null) {
            contextSingelton = new OsiamContext();
        }
        return contextSingelton;
    }

    public OsiamConnector getConnector(String key) {
        OsiamConnector osiamConnector = connectors.get(key);
        if(osiamConnector == null){
        OsiamConnector.Builder oConBuilder = new OsiamConnector.Builder().
                setAuthServiceEndpoint(AUTH_ENDPOINT_ADDRESS).
                setResourceEndpoint(RESOURCE_ENDPOINT_ADDRESS).
                setClientId(CLIENT_ID).
                setClientSecret(CLIENT_SECRET).
                setGrantType(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS).
                setUserName("marissa").
                setPassword("<PASSWORD>").
                setScope(Scope.ALL);
        osiamConnector = oConBuilder.build();
        connectors.put(key, osiamConnector);
        }
        return osiamConnector;
    }

    public AccessToken getValidAccessToken() {
        if (accessToken == null)
        {
            accessToken = getConnector("accessToken").retrieveAccessToken();
        }
        if (accessToken.isExpired()) {
            getConnector("accessToken").refreshAccessToken(accessToken, Scope.ALL);
        }
        return accessToken;
    }

    public void setListOfUsers(List<User> users) {
        this.users = users;
    }

    public String retrieveSingleUserId() {
        String userId = null;
        if (users.size() > 0) {
            int randomPosition = (int) (Math.random() * users.size());
            User user = users.get(randomPosition);
            userId = user.getId();
            users.remove(randomPosition);
        }
        return userId;
    }
}
{'fraction_non_alphanumeric': 0.0982436882546652, 'fraction_numerical': 0.0034760336626417855, 'mean_word_length': 2.7064406779661017, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '418687', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1541, 'n_words': 301}