hudson.util.ComboBoxModel Java Examples

The following examples show how to use hudson.util.ComboBoxModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ToolSelectionDescriptorTest.java    From warnings-ng-plugin with MIT License 6 votes vote down vote up
@ParameterizedTest(name = "{index} => Existing Job IDs = <{0}>")
@ValueSource(strings = {"", "1", "1, 2", "1, 2, 3"})
void shouldFillIDItems(final String ids) {
    String[] elements = ids.split(",", -1);

    ToolSelectionDescriptor toolSelectionDescriptor = new ToolSelectionDescriptor();

    List<JobAction> actions = new ArrayList<>();
    for (String element : elements) {
        JobAction jobAction = mock(JobAction.class);
        when(jobAction.getId()).thenReturn(element);
        actions.add(jobAction);
    }

    Job job = mock(Job.class);
    when(job.getActions(JobAction.class)).thenReturn(actions);

    JenkinsFacade jenkinsFacade = mock(JenkinsFacade.class);
    when(jenkinsFacade.getAllJobs()).thenReturn(Lists.list(job));
    ToolSelectionDescriptor.setJenkinsFacade(jenkinsFacade);

    ComboBoxModel model = toolSelectionDescriptor.doFillIdItems();

    assertThat(model).containsExactly(elements);
}
 
Example #2
Source File: ToolSelection.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * Returns a model that contains all static analysis tool IDs of all jobs.
 *
 * @return a model with all static analysis tool IDs of all jobs
 */
public ComboBoxModel doFillIdItems() {
    ComboBoxModel model = new ComboBoxModel();
    Set<String> ids = jenkinsFacade.getAllJobs()
            .stream()
            .flatMap(job -> job.getActions(JobAction.class).stream())
            .map(JobAction::getId).collect(Collectors.toSet());
    model.addAll(ids);
    return model;
}
 
Example #3
Source File: ModelValidationTest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
@Test
void shouldContainDefaultCharsets() {
    ModelValidation model = new ModelValidation();

    ComboBoxModel allCharsets = model.getAllCharsets();
    assertThat(allCharsets).isNotEmpty().contains("UTF-8", "ISO-8859-1");
}
 
Example #4
Source File: ModelValidationTest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
@Test
void shouldContainEmptyJobPlaceHolder() {
    JenkinsFacade jenkins = mock(JenkinsFacade.class);
    ModelValidation model = new ModelValidation(jenkins);
    ComboBoxModel actualModel = model.getAllJobs();

    assertThat(actualModel).hasSize(1);
    assertThat(actualModel).containsExactly(NO_REFERENCE_JOB);
}
 
Example #5
Source File: ModelValidationTest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
@Test
void shouldContainSingleElementAndPlaceHolder() {
    JenkinsFacade jenkins = mock(JenkinsFacade.class);
    Job<?, ?> job = mock(Job.class);
    String name = "Job Name";
    when(jenkins.getFullNameOf(job)).thenReturn(name);
    when(jenkins.getAllJobNames()).thenReturn(Collections.singleton(name));

    ModelValidation model = new ModelValidation(jenkins);

    ComboBoxModel actualModel = model.getAllJobs();

    assertThat(actualModel).hasSize(2);
    assertThat(actualModel).containsExactly(NO_REFERENCE_JOB, name);
}
 
Example #6
Source File: NodesByLabelStep.java    From pipeline-utility-steps-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings("unused") // used by stapler
public ComboBoxModel doFillLabelItems() {
    ComboBoxModel cbm = new ComboBoxModel();
    Set<Label> labels = Jenkins.get().getLabels();
    for (Label label : labels) {
        cbm.add(label.getDisplayName());
    }
    return cbm;
}
 
Example #7
Source File: Environment.java    From jenkins-deployment-dashboard-plugin with MIT License 5 votes vote down vote up
public ComboBoxModel doFillBuildJobItems() {
    ComboBoxModel model = new ComboBoxModel();

    for (String jobName : Jenkins.getInstance().getJobNames()) {
        model.add(jobName);
    }

    return model;
}
 
Example #8
Source File: ModelValidation.java    From warnings-ng-plugin with MIT License 4 votes vote down vote up
/**
 * Returns the model with the possible reference jobs.
 *
 * @return the model with the possible reference jobs
 */
public ComboBoxModel getAllJobs() {
    ComboBoxModel model = new ComboBoxModel(jenkins.getAllJobNames());
    model.add(0, NO_REFERENCE_JOB); // make sure that no input is valid
    return model;
}
 
Example #9
Source File: AnalysisStepDescriptor.java    From warnings-ng-plugin with MIT License 2 votes vote down vote up
/**
 * Returns a model with all available charsets.
 *
 * @return a model with all available charsets
 */
public ComboBoxModel doFillSourceCodeEncodingItems() {
    return model.getAllCharsets();
}
 
Example #10
Source File: AnalysisStepDescriptor.java    From warnings-ng-plugin with MIT License 2 votes vote down vote up
/**
 * Returns the model with the possible reference jobs.
 *
 * @return the model with the possible reference jobs
 */
public ComboBoxModel doFillReferenceJobNameItems() {
    return model.getAllJobs();
}
 
Example #11
Source File: IssuesRecorder.java    From warnings-ng-plugin with MIT License 2 votes vote down vote up
/**
 * Returns a model with all available charsets.
 *
 * @return a model with all available charsets
 */
public ComboBoxModel doFillSourceCodeEncodingItems() {
    return model.getAllCharsets();
}
 
Example #12
Source File: IssuesRecorder.java    From warnings-ng-plugin with MIT License 2 votes vote down vote up
/**
 * Returns the model with the possible reference jobs.
 *
 * @return the model with the possible reference jobs
 */
public ComboBoxModel doFillReferenceJobNameItems() {
    return model.getAllJobs();
}
 
Example #13
Source File: ReportScanningTool.java    From warnings-ng-plugin with MIT License 2 votes vote down vote up
/**
 * Returns a model with all available charsets.
 *
 * @return a model with all available charsets
 */
public ComboBoxModel doFillReportEncodingItems() {
    return model.getAllCharsets();
}
 
Example #14
Source File: ModelValidation.java    From warnings-ng-plugin with MIT License 2 votes vote down vote up
/**
 * Returns all available character set names.
 *
 * @return all available character set names
 */
public ComboBoxModel getAllCharsets() {
    return new ComboBoxModel(ALL_CHARSETS);
}