Java Code Examples for hudson.util.ListBoxModel#get()

The following examples show how to use hudson.util.ListBoxModel#get() . 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: ModelValidationTest.java    From warnings-ng-plugin with MIT License 6 votes vote down vote up
@Test
void doFillMinimumPriorityItemsShouldBeNotEmpty() {
    ModelValidation model = new ModelValidation();
    ListBoxModel allFilters = model.getAllSeverityFilters();

    assertThat(allFilters.size()).isEqualTo(3);

    Option actualHighOption = allFilters.get(0);
    Option actualNormalOption = allFilters.get(1);
    Option actualLowOption = allFilters.get(2);

    assertSoftly(softly -> {
        softly.assertThat(actualHighOption.value).isEqualTo(Severity.WARNING_HIGH.getName());
        softly.assertThat(actualHighOption.name).isEqualTo(Messages.SeverityFilter_High());
        softly.assertThat(actualNormalOption.value).isEqualTo(Severity.WARNING_NORMAL.getName());
        softly.assertThat(actualNormalOption.name).isEqualTo(Messages.SeverityFilter_Normal());
        softly.assertThat(actualLowOption.value).isEqualTo(Severity.WARNING_LOW.getName());
        softly.assertThat(actualLowOption.name).isEqualTo(Messages.SeverityFilter_Low());
    });
}
 
Example 2
Source File: ListGitBranchesParameterDefinition.java    From list-git-branches-parameter-plugin with MIT License 6 votes vote down vote up
@Override
public ParameterValue getDefaultParameterValue() {
    String defValue = getDefaultValue();
    if (!StringUtils.isBlank(defaultValue)) {
        return new ListGitBranchesParameterValue(getName(), defValue);
    }

    switch (getSelectedValue()) {
        case TOP:
            try {
                ListBoxModel valueItems = getDescriptor().doFillValueItems(getParentJob(), getName());
                if (valueItems.size() > 0) {
                    return new ListGitBranchesParameterValue(getName(), valueItems.get(0).value);
                }
            } catch (Exception e) {
                LOGGER.log(Level.SEVERE, getCustomJobName() + " " + " ", e);
            }
            break;
        case DEFAULT:
        case NONE:
        default:
            return super.getDefaultParameterValue();
    }

    return super.getDefaultParameterValue();
}
 
Example 3
Source File: BuildStatusConfigTest.java    From github-autostatus-plugin with MIT License 6 votes vote down vote up
/**
 * Verifies doFillCredentialsIdItems adds the passed in current value
 */
@Test
public void testDoFillCredentialsIdItemsAddsCurrent() {
    BuildStatusConfig instance = new BuildStatusConfig();
    
    final String currentValue = "mock-id";
    ListBoxModel model = instance.doFillCredentialsIdItems(currentValue);
    
    assertEquals(2, model.size());
    ListBoxModel.Option item1 = model.get(0);
    assertEquals("", item1.value);
    assertEquals("- none -", item1.name);

    ListBoxModel.Option item2 = model.get(1);
    assertEquals(currentValue, item2.value);
}
 
Example 4
Source File: BuildStatusConfigTest.java    From github-autostatus-plugin with MIT License 6 votes vote down vote up
/**
 * Verifies doFillCredentialsIdItems adds values from the credentials store
 * @throws IOException 
 */
@Test
public void testDoFillCredentialsIdItemsAddsFromCredentialsStore() throws IOException {
    StandardUsernameCredentials user = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, testCredentials, "Description", testCredentialsUser, testCredentialsPassword);
    CredentialsProvider.lookupStores(j.getInstance()).iterator().next().addCredentials(Domain.global(), user);

    BuildStatusConfig instance = new BuildStatusConfig();
    instance.setCredentialsId(testCredentials);
    
    ListBoxModel model = instance.doFillCredentialsIdItems(testCredentials);
    
    assertEquals(2, model.size());
    ListBoxModel.Option item1 = model.get(0);
    assertEquals("", item1.value);
    assertEquals("- none -", item1.name);

    ListBoxModel.Option item2 = model.get(1);
    assertEquals(testCredentials, item2.value);
}
 
Example 5
Source File: BuildStatusConfigTest.java    From github-autostatus-plugin with MIT License 6 votes vote down vote up
/**
 * Verifies doFillHttpCredentialsIdItems adds the passed in current value
 */
@Test
public void testDoFillHttpCredentialsIdItemsAddsCurrent() {
    BuildStatusConfig instance = new BuildStatusConfig();

    final String currentValue = "mock-id";
    ListBoxModel model = instance.doFillHttpCredentialsIdItems(currentValue);

    assertEquals(2, model.size());
    ListBoxModel.Option item1 = model.get(0);
    assertEquals("", item1.value);
    assertEquals("- none -", item1.name);

    ListBoxModel.Option item2 = model.get(1);
    assertEquals(currentValue, item2.value);
}
 
Example 6
Source File: BuildStatusConfigTest.java    From github-autostatus-plugin with MIT License 6 votes vote down vote up
/**
 * Verifies doFillCredentialsIdItems adds values from the credentials store
 * @throws IOException
 */
@Test
public void testDoFillHttpCredentialsIdItemsAddsFromCredentialsStore() throws IOException {
    StandardUsernameCredentials user = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, testCredentials, "Description", testCredentialsUser, testCredentialsPassword);
    CredentialsProvider.lookupStores(j.getInstance()).iterator().next().addCredentials(Domain.global(), user);

    BuildStatusConfig instance = new BuildStatusConfig();
    instance.setCredentialsId(testCredentials);

    ListBoxModel model = instance.doFillHttpCredentialsIdItems(testCredentials);

    assertEquals(2, model.size());
    ListBoxModel.Option item1 = model.get(0);
    assertEquals("", item1.value);
    assertEquals("- none -", item1.name);

    ListBoxModel.Option item2 = model.get(1);
    assertEquals(testCredentials, item2.value);
}