Java 类hudson.model.Run 实例源码

项目:redtime    文件:RedtimeReportPortlet.java   
private RedInterval getLastRed(Job job, Run lastUnsuccessfulBuild) {
    Run repair = lastUnsuccessfulBuild.getNextBuild();
    Run initialFailure;
    Run previousSuccessfulBuild = lastUnsuccessfulBuild.getPreviousSuccessfulBuild();
    if (previousSuccessfulBuild == null) {
        // never succeeded, get the first build
        initialFailure = lastUnsuccessfulBuild;
        while (initialFailure.getPreviousBuild() != null) {
            initialFailure = initialFailure.getPreviousBuild();
        }
    } else {
        initialFailure = previousSuccessfulBuild.getNextBuild();
    }

    return new RedInterval(job, repair, initialFailure);
}
项目:jira-steps-plugin    文件:GetProjectsStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getProjects())
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:pipeline-github    文件:PullRequestGroovyObject.java   
public PullRequestGroovyObject(@Nonnull final CpsScript script) throws Exception {
    this.script = script;
    Run<?, ?> build = script.$build();
    if (build == null) {
        throw new IllegalStateException("No associated build");
    }
    Job job = build.getParent();

    this.pullRequestHead = GitHubHelper.getPullRequest(job);

    this.base = GitHubHelper.getRepositoryId(job);
    this.head = RepositoryId.create(pullRequestHead.getSourceOwner(), pullRequestHead.getSourceRepo());

    this.gitHubClient = GitHubHelper.getGitHubClient(job);
    this.pullRequestService = new ExtendedPullRequestService(gitHubClient);
    this.issueService = new ExtendedIssueService(gitHubClient);
    this.commitService = new ExtendedCommitService(gitHubClient);
    this.pullRequest = pullRequestService.getPullRequest(base, pullRequestHead.getNumber());
}
项目:jira-steps-plugin    文件:GetIssueWatchesStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getIssueWatches(anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:cppchecker    文件:Cppchecker.java   
@Override
public void perform(Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener) {
    /*
    // This also shows how you can consult the global configuration of the builder
    if (getDescriptor().getUseFrench()) {
        listener.getLogger().println("Bonjour, " + oFile + "!");
    } else {
        listener.getLogger().println("Hello, " + oFile + "!");
    }
     */

    listener.getLogger().println("[Cppchecker] " + "Starting the cppcheck.");
    try {
        ArgumentListBuilder args = getArgs();
        OutputStream out = listener.getLogger();
        FilePath of = new hudson.FilePath(workspace.getChannel(), workspace + "/" + this.oFile.trim());

        launcher.launch().cmds(args).stderr(of.write()).stdout(out).pwd(workspace).join();
    } catch (IOException | InterruptedException ex) {
        Logger.getLogger(Cppchecker.class.getName()).log(Level.SEVERE, null, ex);
    }

    listener.getLogger().println("[Cppchecker] " + "Ending the cppcheck.");
}
项目:kubernetes-cli-plugin    文件:KubectlBuildWrapper.java   
@Override
public void setUp(Context context, Run<?, ?> build,
                  FilePath workspace,
                  Launcher launcher,
                  TaskListener listener,
                  EnvVars initialEnvironment) throws IOException, InterruptedException {
    KubeConfigWriter kubeConfigWriter = KubeConfigWriterFactory.get(
            this.serverUrl,
            this.credentialsId,
            this.caCertificate,
            workspace,
            launcher,
            build);

    // Write the kubeconfig file
    String configFile = kubeConfigWriter.writeKubeConfig();

    // Remove it when the build is finished
    context.setDisposer(new CleanupDisposer(configFile));

    // Set environment for the kubectl calls to find the configuration
    context.env(KubeConfigWriter.ENV_VARIABLE_NAME, configFile);
}
项目:kubernetes-cli-plugin    文件:KubeConfigWriter.java   
/**
 * Get the {@link StandardCredentials}.
 *
 * @return the credentials matching the {@link #credentialsId} or {@code null} is {@code #credentialsId} is blank
 * @throws AbortException if no {@link StandardCredentials} matching {@link #credentialsId} is found
 */
private StandardCredentials getCredentials(Run<?, ?> build) throws AbortException {
    if (StringUtils.isBlank(credentialsId)) {
        return null;
    }
    StandardCredentials result = CredentialsProvider.findCredentialById(
            credentialsId,
            StandardCredentials.class,
            build,
            Collections.<DomainRequirement>emptyList());

    if (result == null) {
        throw new AbortException("No credentials found for id \"" + credentialsId + "\"");
    }
    return result;
}
项目:warrior-jenkins-plugin    文件:WarriorPluginBuilder.java   
/**
 * Private method to get the name of the virtual environment
 * given in virtualenv tag of warhorn config file
 *
 * @param build Build
 * @param workspace Jenkins job workspace
 * @param listener Task listener
 * @return virtEnvName Name of the Virtual Environment
 * @throws ParserConfigurationException ParserConfigurationException
 * @throws SAXException SAXException
 * @throws IOException IOException
 */
private String getVirtEnvName(Run<?,?> build, FilePath workspace, TaskListener listener)
        throws ParserConfigurationException, SAXException, IOException{

    String absWarhornConfig = "";
    if (configType.equals("configGit")){
        absWarhornConfig = workspace.getRemote() + "/configRepo/" + gitConfigFile;
    } else {
        absWarhornConfig = workspace.getRemote() + "/warhorn_config.xml";
    }
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document document = db.parse(new File(absWarhornConfig));
    NodeList veNodeList = document.getElementsByTagName("virtualenv");

    String virtEnvName = "";
    if(veNodeList.getLength() > 0){
        Element element = (Element) veNodeList.item(0);
        virtEnvName = element.getAttribute("name");
    }

    return virtEnvName;
}
项目:jira-steps-plugin    文件:GetIssueStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getIssue(anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());
  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:azure-cli-plugin    文件:Command.java   
public void parseExportedVariables(PrintStream logger, Run<?, ?> build, String output) throws IOException {

        if (exportVariablesString == null) {
            return;
        }
        if (exportVariablesString.trim().equals("")) {
            return;
        }
        logger.println("Transforming to environment variables: " + exportVariablesString);
        HashMap<String, String> exportVariablesNames = com.azure.azurecli.helpers.Utils.parseExportedVariables(exportVariablesString);
        HashMap<String, String> exportVariables = new HashMap<>();

        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(JsonInclude.Include.ALWAYS);

        JsonNode rootNode = mapper.readTree(output);
        for (Map.Entry<String, String> var
                :
                exportVariablesNames.entrySet()) {

            String value = rootNode.at(var.getKey()).asText();
            exportVariables.put(var.getValue(), value);
        }
        com.azure.azurecli.helpers.Utils.setEnvironmentVariables(build, exportVariables);
    }
项目:jira-steps-plugin    文件:GetFieldsStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getFields())
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:Jenkins-Plugin-Examples    文件:CatchErrorStep.java   
@Override public void onFailure(StepContext context, Throwable t) {
    try {
        TaskListener listener = context.get(TaskListener.class);
        Result r = Result.FAILURE;
        if (t instanceof AbortException) {
            listener.error(t.getMessage());
        } else if (t instanceof FlowInterruptedException) {
            FlowInterruptedException fie = (FlowInterruptedException) t;
            fie.handle(context.get(Run.class), listener);
            r = fie.getResult();
        } else {
            listener.getLogger().println(Functions.printThrowable(t).trim()); // TODO 2.43+ use Functions.printStackTrace
        }
        context.get(Run.class).setResult(r);
        context.onSuccess(null);
    } catch (Exception x) {
        context.onFailure(x);
    }
}
项目:hubot-steps-plugin    文件:ApproveStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {
  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Void> builder = ResponseData.builder();
  when(hubotServiceMock.sendMessage(anyString(), anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(envVarsMock.get("HUBOT_URL")).thenReturn("http://localhost:9090/");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:9090/hubot-testing/job/01");

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);

}
项目:envinject-api-plugin    文件:EnvVarsResolver.java   
@Nonnull
public static Map<String, String> getPollingEnvVars(@Nonnull Job<?, ?> job, @CheckForNull Node node) throws EnvInjectException {

    final Run<?, ?> lastBuild = job.getLastBuild();
    if (lastBuild != null) {
        if (EnvInjectPluginHelper.isEnvInjectPluginInstalled()) {
            return getEnVars(lastBuild);
        }
    }

    if (node == null) {
        return getFallBackMasterNode(job);
    }
    if (node.getRootPath() == null) {
        return getFallBackMasterNode(job);
    }

    return getDefaultEnvVarsJob(job, node);
}
项目:envinject-api-plugin    文件:EnvVarsResolver.java   
@Nonnull
public static Map<String, String> getEnVars(@Nonnull Run<?, ?> run) throws EnvInjectException {
    Action envInjectAction = EnvInjectActionRetriever.getEnvInjectAction(run);
    if (envInjectAction != null) {
        try {
            Method method = envInjectAction.getClass().getMethod("getEnvMap");
            return (Map<String, String>) method.invoke(envInjectAction);
        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassCastException e) {
            throw new EnvInjectException(e);
        }
    }

    // Retrieve node used for this build
    Node builtOn = (run instanceof AbstractBuild) ? ((AbstractBuild)run).getBuiltOn() : null;

    // Check if node is always on. Otherwise, gather master env vars
    if (builtOn == null) {
        return getFallBackMasterNode(run.getParent());
    }
    if (builtOn.getRootPath() == null) {
        return getFallBackMasterNode(run.getParent());
    }

    // Get envVars from the node of the last build
    return getDefaultEnvVarsJob(run.getParent(), builtOn);
}
项目:envinject-api-plugin    文件:EnvVarsResolver.java   
/**
 * Retrieves variables describing the Run cause. 
 * @param run Run
 * @return Set of environment variables, which depends on the cause type. 
 */
@Nonnull
public static Map<String, String> getCauseEnvVars(@Nonnull Run<?, ?> run) {
    CauseAction causeAction = run.getAction(CauseAction.class);
    Map<String, String> env = new HashMap<>();
    List<String> directCauseNames = new ArrayList<>();
    Set<String> rootCauseNames = new LinkedHashSet<>();

    if (causeAction != null) {
        List<Cause> buildCauses = causeAction.getCauses();
        for (Cause cause : buildCauses) {
            directCauseNames.add(CauseHelper.getTriggerName(cause));
            CauseHelper.insertRootCauseNames(rootCauseNames, cause, 0);
        }
    } else {
        directCauseNames.add("UNKNOWN");
        rootCauseNames.add("UNKNOWN");
    }
    env.putAll(CauseHelper.buildCauseEnvironmentVariables(ENV_CAUSE, directCauseNames));
    env.putAll(CauseHelper.buildCauseEnvironmentVariables(ENV_ROOT_CAUSE, rootCauseNames));
    return env;
}
项目:warrior-jenkins-plugin    文件:WarriorPluginBuilder.java   
/**
 * Uploads Warrior Execution Logs to remote server
 *
 * @param build Build
 * @param workspace Jenkins job workspace
 * @param listener Task listener
 * @throws InterruptedException InterruptedException
 * @throws IOException IOException
 * @throws SAXException SAXException
 * @throws ParserConfigurationException ParserConfigurationException
 */
private void uploadWarriorLog(Run<?,?> build, FilePath workspace, TaskListener listener)
        throws IOException, InterruptedException, ParserConfigurationException, SAXException {
    boolean status = true;
    listener.getLogger().println(">> Uploading warrior execution logs");
    File execLogFolder = new File(workspace.getRemote(), "/WarriorFramework/warrior/Warriorspace/Execution");
    String buildTag = build.getEnvironment(listener).get("BUILD_TAG");
    File execLogZip = new File(workspace.getRemote(), "/WarriorFramework/warrior/Warriorspace/Execution_"+ buildTag + ".zip");
    status = workspace.act(new FileUploadCallable(this, execLogFolder, execLogZip, listener));
    if (status != true) {
        throw new InterruptedException("Uploading warrior execution logs failed");
    } else {
        listener.getLogger().println(">> Successfully uploaded Warrior Execution logs to : " + 
         uploadServerIp + ":" + uploadServerDir + "/Execution_"+ buildTag + ".zip");
        //(sftp)logger.println("Uploaded Warrior Execution logs to : " + uploadServerIp + "://" + uploadServerDir);
        //(ftp)logger.println("Uploaded Warrior Execution logs: " + uploadServerUname + "@" + uploadServerIp + "/" + uploadServerDir);
    }
}
项目:hubot-steps-plugin    文件:SendStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Void> builder = ResponseData.builder();
  when(hubotServiceMock.sendMessage(anyString(), anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(envVarsMock.get("HUBOT_URL")).thenReturn("http://localhost:9090/");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:9090/hubot-testing/job/01");

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:GetIssueRemoteLinksStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getIssueRemoteLinks(anyString(), anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:AssignIssueStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Void> builder = ResponseData.builder();
  when(jiraServiceMock.assignIssue(anyString(), anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:JqlSearchStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.searchIssues(anyString(), anyInt(), anyInt()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:warrior-jenkins-plugin    文件:WarriorPluginBuilder.java   
/**
 * Clones warriorframework into Jenkins workspace
 *
 * @param build Build
 * @param workspace Jenkins job workspace
 * @param listener Task listener
 * @throws InterruptedException InterruptedException
 * @throws IOException IOException
 * @throws SAXException SAXException
 * @throws ParserConfigurationException ParserConfigurationException
 */
public void cloneWarriorFramework(Run<?,?> build, FilePath workspace, TaskListener listener)
        throws IOException, InterruptedException, ParserConfigurationException, SAXException {
    boolean status = true;
    listener.getLogger().println(">> Cloning WarrioFramework: " + gitConfigUrl + " to " + workspace.getRemote());

    // Get required details to clone WarriorFramework
    String[] cloneDetails = getWfCloneDetails(build, workspace, listener);

    // warriorframework will be cloned inside '<worksapce>/WarriorFramework' directory
    FilePath ws = new FilePath(workspace, "WarriorFramework");
    if(ws.exists()){
        ws.deleteRecursive();
    }
    File localPath = new File(ws.toURI());
    // Setting cloneType as 'tag' to avoid adding 'origin' with branch name
    // 'origin' is required when using branches and it is mandatory in warhorn config file
    String cloneType = "tag";
    // Perform clone operation in Workspace(Master/Slave)
    status = workspace.act(new GitCallable(cloneDetails[0], cloneDetails[1],
              cloneDetails[2], localPath, cloneDetails[3], cloneType, listener));
    if (status != true) {
        throw new InterruptedException("Cloning WarriorFramework: " + gitConfigUrl + " failed");
    }
    listener.getLogger().println(">> Successfuly cloned WarrioFramework");
}
项目:jira-steps-plugin    文件:GetCommentsStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getComments(anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:AddCommentStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.addComment(anyString(), anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);

}
项目:jira-steps-plugin    文件:AssignableUserSearchStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock
      .assignableUserSearch(anyString(), anyString(), anyString(), anyInt(), anyInt()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:GetProjectStatusesStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getProjectStatuses(anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:NotifyIssueStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Void> builder = ResponseData.builder();
  when(jiraServiceMock.notifyIssue(anyString(), any()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:DeleteIssueRemoteLinksStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.deleteIssueRemoteLinks(anyString(), anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:EditIssueStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.updateIssue(anyString(), any()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:DeleteIssueLinkStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.deleteIssueLink(anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:GetProjectStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getProject(anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:TransitionIssueStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Void> builder = ResponseData.builder();
  when(jiraServiceMock.transitionIssue(anyString(), any()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:EditComponentStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Void> builder = ResponseData.builder();
  when(jiraServiceMock.updateComponent(anyString(), any()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:GetIssueRemoteLinkStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getIssueRemoteLink(anyString(), anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:GetComponentStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getComponent(anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:GetIssueTransitionsStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getIssueTransitions(anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:EditVersionStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Void> builder = ResponseData.builder();
  when(jiraServiceMock.updateVersion(anyString(), any()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);

}
项目:jira-steps-plugin    文件:GetProjectVersionsStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.getProjectVersions(anyString()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}
项目:jira-steps-plugin    文件:NewComponentStepTest.java   
@Before
public void setup() throws IOException, InterruptedException {

  // Prepare site.
  when(envVarsMock.get("JIRA_SITE")).thenReturn("LOCAL");
  when(envVarsMock.get("BUILD_URL")).thenReturn("http://localhost:8080/jira-testing/job/01");

  PowerMockito.mockStatic(Site.class);
  Mockito.when(Site.get(any())).thenReturn(siteMock);
  when(siteMock.getService()).thenReturn(jiraServiceMock);

  when(runMock.getCauses()).thenReturn(null);
  when(taskListenerMock.getLogger()).thenReturn(printStreamMock);
  doNothing().when(printStreamMock).println();

  final ResponseDataBuilder<Object> builder = ResponseData.builder();
  when(jiraServiceMock.createComponent(any()))
      .thenReturn(builder.successful(true).code(200).message("Success").build());

  when(contextMock.get(Run.class)).thenReturn(runMock);
  when(contextMock.get(TaskListener.class)).thenReturn(taskListenerMock);
  when(contextMock.get(EnvVars.class)).thenReturn(envVarsMock);
}