package hudson.plugins.git.extensions.impl;

import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.Test;

public class UserIdentityTest {

    @Test
    public void equalsContract() {
        EqualsVerifier.forClass(UserIdentity.class)
                .usingGetClass()
                .verify();
    }
}

@@ -49,102 +49,2065 @@
 ort 
-nl.jqno.equalsverifier.EqualsVerifier;%0Aimport org.junit.Test;%0A%0Apublic class UserIdentityTest %7B
+hudson.EnvVars;%0Aimport hudson.model.FreeStyleBuild;%0Aimport hudson.model.FreeStyleProject;%0Aimport hudson.model.Result;%0Aimport hudson.plugins.git.BranchSpec;%0Aimport hudson.plugins.git.GitSCM;%0Aimport hudson.plugins.git.TestGitRepo;%0Aimport hudson.plugins.git.UserRemoteConfig;%0Aimport hudson.plugins.git.extensions.GitSCMExtension;%0Aimport hudson.plugins.git.extensions.GitSCMExtensionTest;%0Aimport nl.jqno.equalsverifier.EqualsVerifier;%0Aimport org.jenkinsci.plugins.gitclient.Git;%0Aimport org.jenkinsci.plugins.gitclient.GitClient;%0Aimport org.junit.Test;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.List;%0A%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.Matchers.is;%0A%0Apublic class UserIdentityTest extends GitSCMExtensionTest  %7B%0A%0A    TestGitRepo repo;%0A    GitClient git;%0A%0A    @Override%0A    public void before() throws Exception %7B%0A        repo = new TestGitRepo(%22repo%22, tmp.newFolder(), listener);%0A        git = Git.with(listener, new EnvVars()).in(repo.gitDir).getClient();%0A    %7D%0A%0A    @Override%0A    protected GitSCMExtension getExtension() %7B%0A        return new UserIdentity(%22Jane Doe%22, %22janeDoe@xyz.com%22);%0A    %7D%0A%0A    @Test%0A    public void testUserIdentity() throws Exception %7B%0A        FreeStyleProject projectWithMaster = setupBasicProject(repo);%0A        UserIdentity userIdentity = new UserIdentity(%22Jane Doe%22, %22janeDoe@xyz.com%22);%0A        ((GitSCM)projectWithMaster.getScm()).getExtensions().add(userIdentity);%0A%0A        git.commit(%22First commit%22);%0A%0A        FreeStyleBuild build = build(projectWithMaster, Result.SUCCESS);%0A        EnvVars envVars = build.getEnvironment(listener);%0A        assertThat(%22Jane Doe%22, is(envVars.get(%22GIT_AUTHOR_NAME%22)));%0A        assertThat(%22janeDoe@xyz.com%22, is(envVars.get(%22GIT_AUTHOR_EMAIL%22)));%0A    %7D%0A%0A    @Test%0A    public void testGetNameAndEmail()%7B%0A        UserIdentity userIdentity = new UserIdentity(%22Jane Doe%22, %22janeDoe@xyz.com%22);%0A%0A        assertThat(%22Jane Doe%22, is(userIdentity.getName()));%0A        assertThat(%22janeDoe@xyz.com%22, is(userIdentity.getEmail()));%0A    %7D
 %0A%0A  

Add UserIdentityTest