<commit_before>package hudson.plugins.promoted_builds;

import hudson.EnvVars;
import hudson.model.Action;
import hudson.model.Descriptor;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.ParameterValue;
import hudson.model.TaskListener;
import hudson.plugins.promoted_builds.conditions.ManualCondition;
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import org.junit.Rule;
import org.jvnet.hudson.test.JenkinsRule;
import static org.junit.Assert.*;
import org.jvnet.hudson.test.MockFolder;

/**
 * @author <NAME>
 */

public class PromotionEnvironmentVariablesTest {
    
    @Rule public JenkinsRule r = new JenkinsRule();
    
    @Test
    public void shouldSetJobAndJobFullNames() throws Descriptor.FormException, IOException, InterruptedException, ExecutionException {
        // Assemble
        MockFolder parent = r.createFolder("Folder");
        FreeStyleProject project = parent.createProject(FreeStyleProject.class, "Project");
        
        JobPropertyImpl promotionProperty = new JobPropertyImpl(project);
        PromotionProcess promotionProcess = promotionProperty.addProcess("promo");
        promotionProcess.conditions.clear();
        promotionProcess.conditions.add(new ManualCondition());
        Action approvalAction = new ManualCondition.ManualApproval(promotionProcess.getName(), new ArrayList<ParameterValue>());
        
        // Act
        FreeStyleBuild build = project.scheduleBuild2(0).get();
        build.setDisplayName("1234");
        build.addAction(approvalAction);
        build.save();
        
        Promotion promotion = promotionProcess.considerPromotion2(build).get();
        EnvVars env = promotion.getEnvironment(TaskListener.NULL);
        
        String rootUrl = r.jenkins.getRootUrl();
        
        // Assert
        assertEquals("Folder/Project", env.get("PROMOTED_JOB_FULL_NAME"));
        assertEquals("Project", env.get("PROMOTED_JOB_NAME"));
        assertEquals("SYSTEM", env.get("PROMOTED_USER_NAME"));
        assertEquals("SYSTEM", env.get("PROMOTED_USER_ID"));
        assertEquals("1234", env.get("PROMOTED_DISPLAY_NAME"));

        project.delete();
        parent.delete();
    }
    
}<commit_msg>Better test for USER_ID and USER_NAME: make sure they are different<commit_after>package hudson.plugins.promoted_builds;

import hudson.EnvVars;
import hudson.model.Action;
import hudson.model.Descriptor;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.ParameterValue;
import hudson.model.TaskListener;
import hudson.model.User;
import hudson.plugins.promoted_builds.conditions.ManualCondition;
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;
import org.acegisecurity.context.SecurityContextHolder;
import org.junit.Test;
import org.junit.Rule;
import org.jvnet.hudson.test.JenkinsRule;
import static org.junit.Assert.*;
import org.jvnet.hudson.test.MockFolder;

/**
 * @author <NAME>
 */

public class PromotionEnvironmentVariablesTest {
    
    @Rule public JenkinsRule r = new JenkinsRule();
    
    @Test
    public void shouldSetJobAndJobFullNames() throws Descriptor.FormException, IOException, InterruptedException, ExecutionException, Exception {
        // Assemble
        r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
        User u = User.get("foo");
        u.setFullName("Foobar");

        SecurityContextHolder.getContext().setAuthentication(u.impersonate());

        MockFolder parent = r.createFolder("Folder");
        FreeStyleProject project = parent.createProject(FreeStyleProject.class, "Project");
        
        JobPropertyImpl promotionProperty = new JobPropertyImpl(project);
        PromotionProcess promotionProcess = promotionProperty.addProcess("promo");
        promotionProcess.conditions.clear();
        promotionProcess.conditions.add(new ManualCondition());
        Action approvalAction = new ManualCondition.ManualApproval(promotionProcess.getName(), new ArrayList<ParameterValue>());
        
        // Act
        FreeStyleBuild build = project.scheduleBuild2(0).get();
        build.setDisplayName("1234");
        build.addAction(approvalAction);
        build.save();
        
        Promotion promotion = promotionProcess.considerPromotion2(build).get();
        EnvVars env = promotion.getEnvironment(TaskListener.NULL);
        
        String rootUrl = r.jenkins.getRootUrl();
        
        // Assert
        assertEquals("Folder/Project", env.get("PROMOTED_JOB_FULL_NAME"));
        assertEquals("Project", env.get("PROMOTED_JOB_NAME"));
        assertEquals("Foobar", env.get("PROMOTED_USER_NAME"));
        assertEquals("foo", env.get("PROMOTED_USER_ID"));
        assertEquals("1234", env.get("PROMOTED_DISPLAY_NAME"));

        project.delete();
        parent.delete();
    }
    
}
{'fraction_non_alphanumeric': 0.10923014913341395, 'fraction_numerical': 0.004433696090286175, 'mean_word_length': 3.818446601941748, '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': '6820117', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1339, 'n_words': 237}