Java Code Examples for hudson.util.ListBoxModel#Option

The following examples show how to use hudson.util.ListBoxModel#Option . 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: 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 2
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 3
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 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 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);
}
 
Example 5
Source File: AWSDeviceFarmRecorder.java    From aws-device-farm-jenkins-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Populate the project drop-down Appium Version.
 *
 * @return The ListBoxModel for the UI.
 */
@SuppressWarnings("unused")
public ListBoxModel doFillAppiumVersionJunitItems(@QueryParameter String currentAppiumVersion) {
    List<ListBoxModel.Option> entries = new ArrayList<ListBoxModel.Option>();
    ArrayList<String> appiumVersions = new ArrayList<String>();
    appiumVersions.add(APPIUM_VERSION_1_4_16);
    appiumVersions.add(APPIUM_VERSION_1_6_3);
    appiumVersions.add(APPIUM_VERSION_1_6_5);
    appiumVersions.add(APPIUM_VERSION_1_7_1);
    appiumVersions.add(APPIUM_VERSION_1_7_2);
    appiumVersions.add(APPIUM_VERSION_1_9_1);
    for (String appiumVersion: appiumVersions) {
        entries.add(new ListBoxModel.Option(appiumVersion, appiumVersion, appiumVersion.equals(currentAppiumVersion)));
    }
    return new ListBoxModel(entries);
}
 
Example 6
Source File: AWSDeviceFarmRecorder.java    From aws-device-farm-jenkins-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Populate the project drop-down Appium Version.
 *
 * @return The ListBoxModel for the UI.
 */
@SuppressWarnings("unused")
public ListBoxModel doFillAppiumVersionTestngItems(@QueryParameter String currentAppiumVersion) {
    List<ListBoxModel.Option> entries = new ArrayList<ListBoxModel.Option>();
    ArrayList<String> appiumVersions = new ArrayList<String>();
    appiumVersions.add(APPIUM_VERSION_1_4_16);
    appiumVersions.add(APPIUM_VERSION_1_6_3);
    appiumVersions.add(APPIUM_VERSION_1_6_5);
    appiumVersions.add(APPIUM_VERSION_1_7_1);
    appiumVersions.add(APPIUM_VERSION_1_7_2);
    appiumVersions.add(APPIUM_VERSION_1_9_1);
    for (String appiumVersion: appiumVersions) {
        // We don't ignore case because these *should* be unique.
        entries.add(new ListBoxModel.Option(appiumVersion, appiumVersion, appiumVersion.equals(currentAppiumVersion)));
    }
    return new ListBoxModel(entries);
}
 
Example 7
Source File: AWSDeviceFarmRecorder.java    From aws-device-farm-jenkins-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Populate the project drop-down Appium Version.
 *
 * @return The ListBoxModel for the UI.
 */
@SuppressWarnings("unused")
public ListBoxModel doFillAppiumVersionPythonItems(@QueryParameter String currentAppiumVersion) {
    // Create ListBoxModel from all projects for this AWS Device Farm account.
    List<ListBoxModel.Option> entries = new ArrayList<ListBoxModel.Option>();
    //System.out.print("getting appium version");
    ArrayList<String> appiumVersions = new ArrayList<String>();
    appiumVersions.add(APPIUM_VERSION_1_4_16);
    appiumVersions.add(APPIUM_VERSION_1_6_3);
    appiumVersions.add(APPIUM_VERSION_1_6_5);
    appiumVersions.add(APPIUM_VERSION_1_7_1);
    appiumVersions.add(APPIUM_VERSION_1_7_2);
    appiumVersions.add(APPIUM_VERSION_1_9_1);
    for (String appiumVersion: appiumVersions) {
        entries.add(new ListBoxModel.Option(appiumVersion, appiumVersion, appiumVersion.equals(currentAppiumVersion)));
    }
    return new ListBoxModel(entries);
}
 
Example 8
Source File: AWSDeviceFarmRecorder.java    From aws-device-farm-jenkins-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Populate the project drop-down from the AWS Device Farm API or local cache.
 *
 * @return The ListBoxModel for the UI.
 */
@SuppressWarnings("unused")
public ListBoxModel doFillProjectNameItems(@QueryParameter String currentProjectName) {
    // Create ListBoxModel from all projects for this AWS Device Farm account.
    List<ListBoxModel.Option> entries = new ArrayList<ListBoxModel.Option>();
    System.out.print("getting projects");
    List<String> projectNames = getAWSDeviceFarmProjects();
    System.out.print(String.format("project length = %d", projectNames.size()));
    for (String projectName : projectNames) {
        // We don't ignore case because these *should* be unique.
        entries.add(new ListBoxModel.Option(projectName, projectName, projectName.equals(currentProjectName)));
    }
    return new ListBoxModel(entries);
}
 
Example 9
Source File: AWSDeviceFarmRecorder.java    From aws-device-farm-jenkins-plugin with Apache License 2.0 5 votes vote down vote up
public ListBoxModel doFillVpceServiceNameItems(@QueryParameter String currentVpceServiceName) {
    List<ListBoxModel.Option> entries = new ArrayList<ListBoxModel.Option>();
    // Create ListBoxModel for all VPCE configs for this AWS Device Farm account.
    try {
        System.out.print("Getting VPCE configs");
        List<String> vpceServiceNames = getAWSDeviceFarmVpceConfigurations();
        System.out.print(String.format("VPCE configs length = %d", vpceServiceNames.size()));
        for (String vpceServiceName : vpceServiceNames) {
            entries.add(new ListBoxModel.Option(vpceServiceName, vpceServiceName, vpceServiceName.equals(currentVpceServiceName)));
        }
    } catch (ServiceAccountException e) {
        System.out.println("Account does not have a VPC configured or has not been whitelisted for VPC. Note: VPC is a private device only feature");
    }
    return new ListBoxModel(entries);
}
 
Example 10
Source File: AWSDeviceFarmRecorder.java    From aws-device-farm-jenkins-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Populate the device pool drop-down from AWS Device Farm API or local cache.
 * based on the selected project.
 *
 * @param projectName           Name of the project selected.
 * @param currentDevicePoolName Name of the device pool selected.
 * @return The ListBoxModel for the UI.
 */
@SuppressWarnings("unused")
public ListBoxModel doFillDevicePoolNameItems(@QueryParameter String projectName, @QueryParameter String currentDevicePoolName) {
    List<ListBoxModel.Option> entries = new ArrayList<ListBoxModel.Option>();
    List<String> devicePoolNames = getAWSDeviceFarmDevicePools(projectName);
    if (devicePoolNames == null) {
        return new ListBoxModel();
    }
    for (String devicePoolName : devicePoolNames) {
        // We don't ignore case because these *should* be unique.
        entries.add(new ListBoxModel.Option(devicePoolName, devicePoolName, devicePoolName.equals(currentDevicePoolName)));
    }
    return new ListBoxModel(entries);
}
 
Example 11
Source File: AWSDeviceFarmRecorder.java    From aws-device-farm-jenkins-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Populate the TestSpec drop-down from AWS Device Farm API or local cache.
 * based on the selected project.
 *
 * @param projectName           Name of the project selected.
 * @param currentTestSpecName Name of the TestSpec selected.
 * @return The ListBoxModel for the UI.
 */
@SuppressWarnings("unused")
public ListBoxModel doFillTestSpecNameItems(@QueryParameter String projectName, @QueryParameter String currentTestSpecName) {
    List<ListBoxModel.Option> entries = new ArrayList<ListBoxModel.Option>();
    List<String> testSpecNames = getAWSDeviceFarmTestSpec(projectName);
    if (testSpecNames == null) {
        return new ListBoxModel();
    }
    for (String testSpecName : testSpecNames) {
        // We don't ignore case because these *should* be unique.
        entries.add(new ListBoxModel.Option(testSpecName, testSpecName, testSpecName.equals(currentTestSpecName)));
    }
    return new ListBoxModel(entries);
}
 
Example 12
Source File: SMABuilder.java    From salesforce-migration-assistant with MIT License 5 votes vote down vote up
public ListBoxModel doFillServerTypeItems()
{
    return new ListBoxModel(
            new ListBoxModel.Option("Production (https://login.salesforce.com)", "https://login.salesforce.com"),
            new ListBoxModel.Option("Sandbox (https://test.salesforce.com)", "https://test.salesforce.com")
    );
}
 
Example 13
Source File: SMABuilder.java    From salesforce-migration-assistant with MIT License 5 votes vote down vote up
public ListBoxModel doFillTestLevelItems()
{
    return new ListBoxModel(
            new ListBoxModel.Option("None", "NoTestRun"),
            new ListBoxModel.Option("Relevant", "RunSpecifiedTests"),
            new ListBoxModel.Option("Local", "RunLocalTests"),
            new ListBoxModel.Option("All", "RunAllTestsInOrg")
    );
}
 
Example 14
Source File: DockerAPI.java    From docker-plugin with MIT License 5 votes vote down vote up
private static boolean optionIsAvailable(final String optionValue, final ListBoxModel available) {
    for (ListBoxModel.Option o : available) {
        if (o.value == null) {
            if (optionValue == null) {
                return true; // both null = match
            }
        } else {
            if (optionValue != null && optionValue.equals(o.value)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 15
Source File: GerritSCMSource.java    From gerrit-code-review-plugin with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public FormValidation doCheckCredentialsId(
    @AncestorInPath Item context, @QueryParameter String remote, @QueryParameter String value) {
  if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
      || context != null && !context.hasPermission(Item.EXTENDED_READ)) {
    return FormValidation.ok();
  }

  value = Util.fixEmptyAndTrim(value);
  if (value == null) {
    return FormValidation.ok();
  }

  remote = Util.fixEmptyAndTrim(remote);
  if (remote == null)
  // not set, can't check
  {
    return FormValidation.ok();
  }

  for (ListBoxModel.Option o :
      CredentialsProvider.listCredentials(
          StandardUsernameCredentials.class,
          context,
          context instanceof Queue.Task
              ? Tasks.getAuthenticationOf((Queue.Task) context)
              : ACL.SYSTEM,
          URIRequirementBuilder.fromUri(remote).build(),
          GitClient.CREDENTIALS_MATCHER)) {
    if (StringUtils.equals(value, o.value)) {
      // TODO check if this type of credential is acceptable to the Git client or does it merit
      // warning
      // NOTE: we would need to actually lookup the credential to do the check, which may
      // require
      // fetching the actual credential instance from a remote credentials store. Perhaps this
      // is
      // not required
      return FormValidation.ok();
    }
  }
  // no credentials available, can't check
  return FormValidation.warning("Cannot find any credentials with id " + value);
}