Java 类hudson.model.User 实例源码

项目:Jenkins-Plugin-Examples    文件:RetryStepTest.java   
@Issue("JENKINS-41276")
@Test
public void abortShouldNotRetry() throws Exception {
    r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    p.setDefinition(new CpsFlowDefinition(
            "int count = 0; retry(3) { echo 'trying '+(count++); semaphore 'start'; echo 'NotHere' } echo 'NotHere'", true));
    final WorkflowRun b = p.scheduleBuild2(0).waitForStart();
    SemaphoreStep.waitForStart("start/1", b);
    ACL.impersonate(User.get("dev").impersonate(), new Runnable() {
        @Override public void run() {
            b.getExecutor().doStop();
        }
    });
    r.assertBuildStatus(Result.ABORTED, r.waitForCompletion(b));
    r.assertLogContains("trying 0", b);
    r.assertLogContains("Aborted by dev", b);
    r.assertLogNotContains("trying 1", b);
    r.assertLogNotContains("trying 2", b);
    r.assertLogNotContains("NotHere", b);

}
项目:Jenkins-Plugin-Examples    文件:CatchErrorStepTest.java   
@Test public void specialStatus() throws Exception {
    User.get("smrt");
    WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
    p.setDefinition(new CpsFlowDefinition(
            "catchError {\n" +
            "  semaphore 'specialStatus'\n" +
            "}", true));
    SemaphoreStep.failure("specialStatus/1", new FlowInterruptedException(Result.UNSTABLE, new CauseOfInterruption.UserInterruption("smrt")));
    WorkflowRun b = p.scheduleBuild2(0).get();
    r.assertLogContains("smrt", r.assertBuildStatus(Result.UNSTABLE, b));
    /* TODO fixing this is trickier since CpsFlowExecution.setResult does not implement a public method, and anyway CatchErrorStep in its current location could not refer to FlowExecution:
    List<FlowNode> heads = b.getExecution().getCurrentHeads();
    assertEquals(1, heads.size());
    assertEquals(Result.UNSTABLE, ((FlowEndNode) heads.get(0)).getResult());
    */
}
项目:impersonation-plugin    文件:ImpersonationAction.java   
/**
 * Gets the names of the authorities that this action is associated with.
 *
 * @return the names of the authorities that this action is associated with.
 */
@NonNull
public List<String> getAuthorities() {
    Authentication authentication = Jenkins.getAuthentication();
    GrantedAuthority[] authorities = authentication.getAuthorities();
    if (authorities == null) {
        return Collections.emptyList();
    }
    String id = authentication.getName();
    List<String> result = new ArrayList<>(authorities.length);
    for (GrantedAuthority a : authorities) {
        String n = a.getAuthority();
        if (n != null && !User.idStrategy().equals(n, id)) {
            result.add(n);
        }
    }
    Collections.sort(result, String.CASE_INSENSITIVE_ORDER);
    return result;
}
项目:restricted-register-plugin    文件:ActivationCodeFormValidator.java   
@Override
public void verifyFormData(HudsonSecurityRealmRegistration securityRealmRegistration, JSONObject object)
        throws RegistrationException, InvalidSecurityRealmException {
    final String activationCode = BaseFormField.ACTIVATION_CODE.fromJSON(object);
    if (StringUtils.isEmpty(activationCode)) {
        throw new RegistrationException(Messages.RRError_Hudson_ActiviationCodeInvalid());
    }
    final User user = RRHudsonUserProperty.getUserForActivationCode(activationCode);
    final RRHudsonUserProperty hudsonUserProperty = RRHudsonUserProperty.getPropertyForUser(user);
    if (hudsonUserProperty == null) {
        throw new RegistrationException(Messages.RRError_Hudson_ActiviationCodeInvalid());
    }
    if (hudsonUserProperty.getActivated()) {
        throw new RegistrationException(Messages.RRError_Hudson_UserIsActivated());
    }
    final Mailer.UserProperty mailerProperty = user.getProperty(Mailer.UserProperty.class);
    if (mailerProperty == null) {
        throw new RegistrationException(Messages.RRError_Hudson_UserNoEmailAddress());
    }
    final String emailAddress = Utils.fixEmptyString(mailerProperty.getAddress());
    if (!EmailValidator.getInstance().isValid(emailAddress)) {
        throw new RegistrationException(Messages.RRError_Hudson_UserInvalidEmail(emailAddress));
    }
}
项目:latch-plugin-jenkins    文件:LatchAccountProperty.java   
public FormValidation doLatchPairConnection(@QueryParameter("pairToken") final String pairToken,
                                            @AncestorInPath User user,
                                            @QueryParameter("csrf") final String csrf) throws IOException {
    if (validCSRF(csrf)) {
        if (pairToken != null && !pairToken.isEmpty()) {
            LatchApp latchApp = LatchSDK.getInstance();
            if (latchApp != null) {
                LatchResponse pairResponse = latchApp.pair(pairToken);

                if (pairResponse == null) {
                    return FormValidation.error(Messages.LatchAccountProperty_UnreachableConnection());
                } else if (pairResponse.getError() != null && pairResponse.getError().getCode() != 205) {
                    return FormValidation.error(Messages.LatchAccountProperty_Invalid_Token());
                } else {
                    LatchAccountProperty lap = newInstance(user);
                    lap.accountId = pairResponse.getData().get("accountId").getAsString();
                    user.addProperty(lap);
                    return FormValidation.ok(Messages.LatchAccountProperty_Pair());
                }
            }
            return FormValidation.ok(Messages.LatchAccountProperty_PluginDisabled());
        }
        return FormValidation.error(Messages.LatchAccountProperty_Invalid_Token());
    }
    return FormValidation.error(Messages.LatchAccountProperty_Csrf());
}
项目:latch-plugin-jenkins    文件:LatchAccountProperty.java   
public FormValidation doLatchUnpairConnection(@AncestorInPath User user,
                                              @QueryParameter("csrf") final String csrf) throws IOException {
    if (validCSRF(csrf)) {
        LatchAccountProperty lap = user.getProperty(LatchAccountProperty.class);
        LatchApp latchApp = LatchSDK.getInstance();
        if (latchApp != null) {
            LatchResponse unpairResponse = latchApp.unpair(lap.getAccountId());

            if (unpairResponse == null) {
                return FormValidation.error(Messages.LatchAccountProperty_UnreachableConnection());
            } else if (unpairResponse.getError() != null && unpairResponse.getError().getCode() != 201) {
                return FormValidation.error(unpairResponse.getError().getMessage());
            } else {
                lap.accountId = null;
                lap.user.save();
                return FormValidation.ok(Messages.LatchAccountProperty_Unpair());
            }
        }
        return FormValidation.ok(Messages.LatchAccountProperty_PluginDisabled());
    }
    return FormValidation.error(Messages.LatchAccountProperty_Csrf());
}
项目:jenkins-fossil-adapter    文件:FossilChangeLogEntry.java   
/**
 * Gets the user who made this change.
 * 
 * This is a mandatory part of the Change Log Architecture
 * 
 * @return the author of the checkin (aka commit)
 */
@Exported
public User getAuthor() {
    User user = User.get(author, false);

    if (user == null) {
        user = User.get(author, true);

        // set email address for user
        if (fixEmpty(authorEmail) != null) {
            try {
                user.addProperty(new Mailer.UserProperty(authorEmail));
            } catch (IOException e) {
                // ignore error
            }
        }
    }

    return user;
}
项目:gitlab-auth-plugin    文件:GitLabUserProperty.java   
/**
 * Creates a new instance of the GitLabUserInformation object containing information about the logged in user.
 * 
 * @return the UserPropery object
 */
@Override
public UserProperty newInstance(User user) {
    Authentication auth = Jenkins.getAuthentication();

    if (auth instanceof GitLabUserDetails) {
        GitLabUserInfo gitLabUser;
        try {
            gitLabUser = GitLab.getUser(((GitLabUserDetails) auth.getPrincipal()).getId());
            return new GitLabUserProperty(gitLabUser);
        } catch (GitLabApiException e) {
            LOGGER.warning(e.getMessage());
        }
    }
    return new GitLabUserProperty();
}
项目:flaky-test-handler-plugin    文件:TestGitRepo.java   
public TestGitRepo(String name, File tmpDir, TaskListener listener) throws IOException, InterruptedException {
  this.name = name;
  this.listener = listener;

  envVars = new EnvVars();

  gitDir = tmpDir;
  User john = User.get(johnDoe.getName(), true);
  UserProperty johnsMailerProperty = new Mailer.UserProperty(johnDoe.getEmailAddress());
  john.addProperty(johnsMailerProperty);

  User jane = User.get(janeDoe.getName(), true);
  UserProperty janesMailerProperty = new Mailer.UserProperty(janeDoe.getEmailAddress());
  jane.addProperty(janesMailerProperty);

  // initialize the git interface.
  gitDirPath = new FilePath(gitDir);
  git = Git.with(listener, envVars).in(gitDir).getClient();

  // finally: initialize the repo
  git.init();
}
项目:jenkins.py    文件:UserNameResolverPW.java   
private void initPython() {
    if (pexec == null) {
        pexec = new PythonExecutor(this);
        String[] jMethods = new String[1];
        jMethods[0] = "findNameFor";
        String[] pFuncs = new String[1];
        pFuncs[0] = "find_name_for";
        Class[][] argTypes = new Class[1][];
        argTypes[0] = new Class[1];
        argTypes[0][0] = User.class;
        pexec.checkAbstrMethods(jMethods, pFuncs, argTypes);
        String[] functions = new String[0];
        int[] argsCount = new int[0];
        pexec.registerFunctions(functions, argsCount);
    }
}
项目:jenkins.py    文件:UserAvatarResolverPW.java   
private void initPython() {
    if (pexec == null) {
        pexec = new PythonExecutor(this);
        String[] jMethods = new String[1];
        jMethods[0] = "findAvatarFor";
        String[] pFuncs = new String[1];
        pFuncs[0] = "find_avatar_for";
        Class[][] argTypes = new Class[1][];
        argTypes[0] = new Class[3];
        argTypes[0][0] = User.class;
        argTypes[0][1] = int.class;
        argTypes[0][2] = int.class;
        pexec.checkAbstrMethods(jMethods, pFuncs, argTypes);
        String[] functions = new String[0];
        int[] argsCount = new int[0];
        pexec.registerFunctions(functions, argsCount);
    }
}
项目:delivery-pipeline-plugin    文件:DeliveryPipelineViewTest.java   
@Test
public void testRebuildNotAuthorized() throws Exception {
    FreeStyleProject projectA = jenkins.createFreeStyleProject("A");
    jenkins.createFreeStyleProject("B");
    projectA.getPublishersList().add(new BuildPipelineTrigger("B", null));

    jenkins.getInstance().rebuildDependencyGraph();
    DeliveryPipelineView view = new DeliveryPipelineView("View");
    jenkins.getInstance().addView(view);

    jenkins.getInstance().setSecurityRealm(jenkins.createDummySecurityRealm());
    GlobalMatrixAuthorizationStrategy gmas = new GlobalMatrixAuthorizationStrategy();
    gmas.add(Permission.READ, "devel");
    jenkins.getInstance().setAuthorizationStrategy(gmas);

    SecurityContext oldContext = ACL.impersonate(User.get("devel").impersonate());
    try {
        view.triggerRebuild("B", "1");
        fail();
    } catch (AuthenticationException e) {
        //Should throw this
    }
    SecurityContextHolder.setContext(oldContext);
}
项目:quarantine    文件:MailNotifier.java   
public String getEmailAddress(String username) {
   String address = null;
   User u = User.get(username);
   if (u == null) {
      println("failed obtaining user for name " + username);
      return address;
   }
   Mailer.UserProperty p = u.getProperty(Mailer.UserProperty.class);
   if (p == null) {
      println("failed obtaining email address for user " + username);
      return address;
   }

   if (p.getAddress() == null) {
      println("failed obtaining email address (is null) for user " + username);
      return address;
   }

   return p.getAddress();
}
项目:quarantine    文件:QuarantineCoreTest.java   
@Override
protected void setUp() throws Exception {
   super.setUp();
   java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.SEVERE);

   project = createFreeStyleProject(projectName);
   DescribableList<TestDataPublisher, Descriptor<TestDataPublisher>> publishers = new DescribableList<TestDataPublisher, Descriptor<TestDataPublisher>>(
         project);
   publishers.add(new QuarantineTestDataPublisher());
   QuarantinableJUnitResultArchiver archiver = new QuarantinableJUnitResultArchiver("*.xml");
   archiver.setTestDataPublishers(publishers);
   project.getPublishersList().add(archiver);

   hudson.setAuthorizationStrategy(new FullControlOnceLoggedInAuthorizationStrategy());
   hudson.setSecurityRealm(createDummySecurityRealm());

   User u = User.get("user1");
   u.addProperty(new Mailer.UserProperty(user1Mail));
}
项目:chatwork-plugin    文件:ChatWorkNotifier.java   
private String generatedMessage(AbstractBuild<?, ?> build) {

    final StringBuilder userBuilder = new StringBuilder();
    for(User user: build.getCulprits()) {
        userBuilder.append(user.getFullName() + " ");
    }

    final StringBuilder changeSetBuilder = new StringBuilder();
    for(ChangeLogSet.Entry entry: build.getChangeSet()) {
        changeSetBuilder.append(entry.getAuthor() + " : " + entry.getMsg() + "\n");
    }

    String replacedMessage = message.replace("${user}", userBuilder.toString());
    replacedMessage = replacedMessage.replace("${result}", build.getResult().toString());
    replacedMessage = replacedMessage.replace("${project}", build.getProject().getName());
    replacedMessage = replacedMessage.replace("${number}", String.valueOf(build.number));
    replacedMessage = replacedMessage.replace("${url}", JenkinsLocationConfiguration.get().getUrl() + build.getUrl());
    replacedMessage = replacedMessage.replace("${changeSet}", changeSetBuilder.toString());

    return replacedMessage;
}
项目:jenkins-artifactory-polling-plugin    文件:ArtifactoryChangeLogSet.java   
@Override
public User getAuthor()
{
    if (user == null)
    {
        return User.getUnknown();
    }
    return user;
}
项目:impersonation-plugin    文件:ImpersonationAction.java   
/**
 * {@inheritDoc}
 */
@Override
public String getIconFileName() {
    Authentication a = Jenkins.getAuthentication();
    if (a instanceof ImpersonationAuthentication) {
        return null;
    }
    GrantedAuthority[] authorities = a.getAuthorities();
    return authorities != null && authorities.length > 0 && User.idStrategy().equals(a.getName(), user.getId())
            ? "plugin/impersonation/images/24x24/impersonate.png"
            : null;
}
项目:impersonation-plugin    文件:ImpersonationAction.java   
/**
 * {@inheritDoc}
 */
@Nonnull
@Override
public ACL getACL() {
    return new ACL() {
        /**
         * {@inheritDoc}
         */
        @Override
        public boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission) {
            return User.idStrategy().equals(a.getName(), user.getId());
        }
    };
}
项目:restricted-register-plugin    文件:RRHudsonUserProperty.java   
@Nullable
public static User getUserForActivationCode(@Nullable String activationCode) {
    if (StringUtils.isEmpty(activationCode)) {
        return null;
    }
    return getUserForCode(activationCode);
}
项目:restricted-register-plugin    文件:RRHudsonUserProperty.java   
@Nullable
private static User getUserForCode(@Nonnull String activationCode) {
    final List<User> allUsers = new ArrayList<>(User.getAll());
    for (User user : allUsers) {
        final RRHudsonUserProperty userProperty = user.getProperty(RRHudsonUserProperty.class);
        if (userProperty != null && activationCode.equals(userProperty.getActivationCode())) {
            return user;
        }
    }
    return null;
}
项目:restricted-register-plugin    文件:RRHudsonUserProperty.java   
@Nullable
public static String getActivationCodeForUser(User user) {
    final RRHudsonUserProperty hudsonUserProperty = getPropertyForUser(user);
    if (hudsonUserProperty == null) {
        return null;
    }
    return hudsonUserProperty.getActivationCode();
}
项目:restricted-register-plugin    文件:RRHudsonUserProperty.java   
@Nonnull
public static RRHudsonUserProperty obtainPropertyForUser(User user) {
    RRHudsonUserProperty ret = getPropertyForUser(user);
    if (ret == null) {
        ret = new RRHudsonUserProperty();
    }
    return ret;
}
项目:restricted-register-plugin    文件:RRHudsonUserProperty.java   
@Nullable
public static RRHudsonUserProperty getPropertyForUser(@Nullable User user) {
    if (user == null) {
        return null;
    }
    return user.getProperty(RRHudsonUserProperty.class);
}
项目:restricted-register-plugin    文件:HudsonSecurityRealmRegistration.java   
private void validateActivationCode(String activationCode) throws RegistrationException {
    final User user = getUserForActivationCode(activationCode);
    if (user == null) {
        throw new RegistrationException(Messages.RRError_Hudson_ActiviationCodeInvalid());
    }
    if (RRHudsonUserProperty.isUserActivated(user)) {
        throw new RegistrationException(Messages.RRError_Hudson_UserIsActivated());
    }
}
项目:restricted-register-plugin    文件:HudsonSecurityRealmRegistration.java   
@SuppressWarnings("unused")
public String getUsernameFromAuthCode() {
    final StaplerRequest request = Stapler.getCurrentRequest();
    if (request.hasParameter(getCodeParamKey())) {
        final User user = getUserForActivationCode(request.getParameter(getCodeParamKey()));
        if (user != null) {
            return user.getId();
        }
    }
    return "";
}
项目:browserstack-integration-plugin    文件:BrowserStackCredentials.java   
public final FormValidation doCheckId(@QueryParameter String value, @AncestorInPath ModelObject context) {
    if (value.isEmpty()) {
        return FormValidation.ok();
    }
    if (!value.matches("[a-zA-Z0-9_.-]+")) { // anything else considered kosher?
        return FormValidation.error("Unacceptable characters");
    }
    FormValidation problem = checkForDuplicates(value, context, context);
    if (problem != null) {
        return problem;
    }
    if (!(context instanceof User)) {
        User me = User.current();
        if (me != null) {
            problem = checkForDuplicates(value, context, me);
            if (problem != null) {
                return problem;
            }
        }
    }
    if (!(context instanceof Jenkins)) {
        // CredentialsProvider.lookupStores(User) does not return SystemCredentialsProvider.
        Jenkins j = Jenkins.getInstance();
        if (j != null) {
            problem = checkForDuplicates(value, context, j);
            if (problem != null) {
                return problem;
            }
        }
    }
    return FormValidation.ok();
}
项目:jira-ext-plugin    文件:MockChangeLogUtil.java   
public static ChangeLogSet.Entry mockChangeLogSetEntry(MockChangeLog mockChangeLog)
{
    ChangeLogSet.Entry mockChange = mock(ChangeLogSet.Entry.class);
    mock(ChangeLogSet.Entry.class);
    when(mockChange.getMsg()).thenReturn(mockChangeLog.commitMessage);
    User mockUser = mock(User.class);
    when(mockUser.toString()).thenReturn(mockChangeLog.author);
    when(mockChange.getAuthor()).thenReturn(mockUser);
    when(mockChange.getCommitId()).thenReturn("mockCommitId");

    return mockChange;
}
项目:deepin-oauth-plugin    文件:DeepinSecurityRealm.java   
public HttpResponse doFinishLogin(StaplerRequest request) throws IOException {
    String code = request.getParameter("code");

    if (StringUtils.isBlank(code)) {
        LOGGER.log(Level.SEVERE, "doFinishLogin() code = null");
        return HttpResponses.redirectToContextRoot();
    }

    DeepinToken token = new DeepinOAuthApiService(clientID, clientSecret).getTokenByAuthorizationCode(code);

    if (!token.accessToken.isEmpty()) {
        DeepinAuthenticationToken auth = new DeepinAuthenticationToken(token, clientID, clientSecret);
        SecurityContextHolder.getContext().setAuthentication(auth);
        User u = User.current();
        u.setFullName(auth.getName());
    } else {
        LOGGER.log(Level.SEVERE, "doFinishLogin() accessToken = null");
    }

    // redirect to referer
    String referer = (String) request.getSession().getAttribute(REFERER_ATTRIBUTE);
    if (referer != null) {
        return HttpResponses.redirectTo(referer);
    } else {
        return HttpResponses.redirectToContextRoot();
    }
}
项目:fabric8-jenkins-workflow-steps    文件:UserDTO.java   
public UserDTO(User user) {
    this.displayName = user.getDisplayName();
    this.id = user.getId();
    this.url = user.getUrl();
    this.fullName = user.getFullName();
    this.description = user.getDescription();
}
项目:github-integration-plugin    文件:GitHubPRRepositoryTest.java   
private void hasPermissionExpectation(Permission permission, boolean isAllowed) {
    PowerMockito.mockStatic(Jenkins.class);
    when(Jenkins.getInstance()).thenReturn(instance);
    when(instance.hasPermission(permission)).thenReturn(isAllowed);
    PowerMockito.mockStatic(User.class);
    when(User.current()).thenReturn(user);
}
项目:latch-plugin-jenkins    文件:LatchSecurityListener.java   
private static boolean checkLatch(UserDetails userDetails){
    boolean result = true;
    User user  = Jenkins.getInstance().getUser(userDetails.getUsername());
    LatchAccountProperty latchUserProperties = (user != null) ? user.getProperty(LatchAccountProperty.class) : null;
    if (latchUserProperties != null && latchUserProperties.getAccountId() != null) {
        result = AsyncLatchHandler.checkLatchUnlockedStatus(LatchSDK.getInstance(), latchUserProperties.getAccountId());
    }
    return result;
}
项目:p4-jenkins    文件:P4AddressResolver.java   
@Override
public String findMailAddressFor(User user) {
    P4UserProperty prop = user.getProperty(P4UserProperty.class);
    if (prop != null) {
        String id = user.getId();
        String email = prop.getEmail();
        logger.fine("MailAddressResolver: " + id + ":" + email);
        return email;
    }
    return null;
}
项目:p4-jenkins    文件:P4ChangeEntry.java   
public void setLabel(ConnectionHelper p4, String labelId) throws Exception {
    Label label = (Label) p4.getLabel(labelId);

    // set id
    id = new P4LabelRef(labelId);

    // set author
    String user = label.getOwnerName();
    user = (user != null && !user.isEmpty()) ? user : "unknown";
    author = User.get(user);

    // set date of change
    date = label.getLastAccess();

    // set client id
    clientId = labelId;

    // set display message
    msg = label.getDescription();

    // set list of file revisions in change
    List<IFileSpec> files = p4.getLabelFiles(labelId, fileCountLimit + 1);
    if (files.size() > fileCountLimit) {
        fileLimit = true;
        files = files.subList(0, fileCountLimit);
    }

    // set list of affected files
    affectedFiles = new ArrayList<P4AffectedFile>();
    for (IFileSpec item : files) {
        affectedFiles.add(new P4AffectedFile(item));
    }
}
项目:p4-jenkins    文件:P4ChangeEntry.java   
public void setGraphCommit(ConnectionHelper p4, String repo, String sha) throws Exception {

        ICommit commit = p4.getGraphCommit(sha, repo);
        id = new P4GraphRef(repo, commit);

        // set author
        String user = commit.getAuthor();
        user = (user != null && !user.isEmpty()) ? user : "unknown";
        author = User.get(user);

        // set date of change
        date = commit.getDate();

        // set client id
        clientId = commit.getAuthorEmail();

        // set display message
        msg = commit.getDescription();

        // set list of affected paths
        affectedFiles = new ArrayList<>();

        List<IFileSpec> graphFiles = p4.getCommitFiles(repo, sha);
        for (IFileSpec item : graphFiles) {
            String path = item.getDepotPathString();
            FileAction action = item.getAction();
            affectedFiles.add(new P4AffectedFile(path, sha, action));
        }

        if (affectedFiles.size() > fileCountLimit) {
            fileLimit = true;
            affectedFiles = affectedFiles.subList(0, fileCountLimit);
        }
    }
项目:p4-jenkins    文件:P4ChangeEntry.java   
@Override
public User getAuthor() {
    // JENKINS-31169
    if (author == null) {
        return User.getUnknown();
    }
    return author;
}
项目:jenkins-build-monitor-plugin    文件:HeadlineOfAborted.java   
private Optional<String> userResponsibleFor(InterruptedBuildAction details) {

        if (details.getCauses().size() == 1) {
            CauseOfInterruption cause = details.getCauses().get(0);

            if (cause instanceof CauseOfInterruption.UserInterruption) {
                User user = ((CauseOfInterruption.UserInterruption) cause).getUser();

                return Optional.of(user.getFullName());
            }
        }

        return Optional.absent();
    }
项目:jenkins-build-monitor-plugin    文件:BuildStateRecipe.java   
private InterruptedBuildAction interruptedBuildAction(User user) {
    List<CauseOfInterruption> causes = Lists.<CauseOfInterruption>newArrayList(
            new CauseOfInterruption.UserInterruption(user)
    );

    InterruptedBuildAction action = mock(InterruptedBuildAction.class);
    when(action.getCauses()).thenReturn(causes);

    return action;
}
项目:jenkins-build-monitor-plugin    文件:BuildStateRecipe.java   
private List<ChangeLogSet.Entry> entriesBy(String... authors) {
    List<ChangeLogSet.Entry> entries = new ArrayList<ChangeLogSet.Entry>();

    for (String name : authors) {
        User author = mock(User.class);
        ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);

        when(author.getFullName()).thenReturn(name);
        when(entry.getAuthor()).thenReturn(author);

        entries.add(entry);
    }
    return entries;
}
项目:jenkins-build-monitor-plugin    文件:BuildStateRecipe.java   
private User userCalled(String name) {
    User user = mock(User.class);
    when(user.getId()).thenReturn(name.toLowerCase());
    when(user.getFullName()).thenReturn(name);

    return user;
}
项目:delivery-pipeline-plugin    文件:CoreCauseResolver.java   
protected static String getDisplayName(String userName) {
    User user = JenkinsUtil.getInstance().getUser(userName);
    if (user != null) {
        return user.getDisplayName();
    } else {
        return "anonymous";
    }
}