Example usage for org.apache.commons.lang RandomStringUtils randomNumeric

List of usage examples for org.apache.commons.lang RandomStringUtils randomNumeric

Introduction

In this page you can find the example usage for org.apache.commons.lang RandomStringUtils randomNumeric.

Prototype

public static String randomNumeric(int count) 

Source Link

Document

Creates a random string whose length is the number of characters specified.

Characters will be chosen from the set of numeric characters.

Usage

From source file:com.maogousoft.wuliu.service.DriverService.java

public static Result driver_reg_getcode(Param param) {
    String phone = param.getRequiredString("phone");
    if (User.dao.existsPhone(phone)) {
        throw new BusinessException("???.");
    }/*from   w  w  w .  jav  a2 s  . co m*/
    if (Driver.dao.existsPhone(phone)) {
        throw new BusinessException("?:" + phone);
    }
    String captcha = RandomStringUtils.randomNumeric(6);
    String content = "????" + captcha;
    SmsService.send(phone, content);
    VcodeManagerPlugin.me().putVcode(phone, captcha);
    return Result.success("????:" + phone + "?");
}

From source file:net.sf.ipsedixit.core.impl.DefaultDataProvider.java

/**
 * {@inheritDoc}/*  ww w .j  a  v a2  s .  c o  m*/
 */
public String randomString(StringType stringType, int length) {
    if (stringType == StringType.ALPHANUMERIC) {
        return RandomStringUtils.randomAlphanumeric(length);
    } else if (stringType == StringType.ALPHA) {
        return RandomStringUtils.randomAlphabetic(length);
    } else if (stringType == StringType.NUMERIC) {
        return RandomStringUtils.randomNumeric(length);
    }
    return RandomStringUtils.randomAscii(length);
}

From source file:com.jslsolucoes.tagria.doc.repository.impl.PessoaRepositoryImpl.java

public PessoaRepositoryImpl() {
    pessoas = new ArrayList<Pessoa>();
    for (int i = 1; i <= 10; i++) {
        Pessoa pessoa = new Pessoa();
        pessoa.setNome(RandomStringUtils.randomAlphabetic(10));
        pessoa.setDataNascimento(Calendar.getInstance().getTime());
        pessoa.setGostaChocolate((i % 2 == 0 ? 1 : 0));
        pessoa.setCpf(RandomStringUtils.randomNumeric(11));
        pessoa.setCep(RandomStringUtils.randomNumeric(8));
        pessoa.setId(Long.valueOf(i));
        pessoas.add(pessoa);/*from   w w  w .  ja  v a2 s  . c o  m*/
    }

}

From source file:com.splicemachine.testutil.RandomDerbyDecimalBuilder.java

public static BigDecimal buildOne(int precision, int scale, boolean negative) {
    checkArgument(precision >= PRECISION_MIN && precision <= PRECISION_MAX);
    checkArgument(scale <= precision);

    BigInteger unscaledVal = new BigInteger((negative ? "-" : "") + RandomStringUtils.randomNumeric(precision));
    return new BigDecimal(unscaledVal, scale);
}

From source file:com.liusoft.dlog4j.servlet.DLOG_RandomImageServlet.java

protected static String random() {
    return RandomStringUtils.randomNumeric(4);
}

From source file:edu.internet2.middleware.psp.names.CreateLdapNames.java

public static String getUid(String givenName, String surname) {
    String name = givenName + surname;
    name = name.replaceAll("[\\s-']", "");

    String uid = RandomStringUtils.random(3, name).toLowerCase() + RandomStringUtils.randomNumeric(3);

    while (uids.contains(uid)) {
        uid = RandomStringUtils.random(3, name).toLowerCase() + RandomStringUtils.randomNumeric(3);
    }//from  w ww. j a  v  a2 s .co m

    uids.add(uid);

    return uid;
}

From source file:edu.sampleu.demo.kitchensink.ConfigurationTestViewUifController.java

/**
 * places a message containing apostrophes into the message map for display as a growl
 *///from w ww  .  j a  va  2s  .  com
@Override
@RequestMapping(params = "methodToCall=start")
public ModelAndView start(UifFormBase form) {
    String randomYear = RandomStringUtils.randomNumeric(2);
    GlobalVariables.getMessageMap().putInfo("growl.testing.apostrophe", "sampleapp.growl.testmsg",
            "'" + randomYear);

    return super.start(form);
}

From source file:com.merrill.examples.framework.lang.text.impl.CommonsRandomTextGenerator.java

public String randomNumeric(int count) {
    return RandomStringUtils.randomNumeric(count);
}

From source file:com.gs.collections.impl.jmh.domain.Positions.java

public Position createPosition() {
    String accountName = this.stringPool.put(RandomStringUtils.randomNumeric(5));
    String category = this.stringPool.put(RandomStringUtils.randomAlphabetic(1).toUpperCase());
    String productName = this.stringPool.put(RandomStringUtils.randomNumeric(3));
    Account account = this.accountPool.put(new Account(accountName));
    Product product = this.productPool.put(new Product(productName, category, DOUBLES.nextDouble()));
    return new Position(account, product, INTS.nextInt());
}

From source file:edu.sampleu.kim.api.identity.IdentityPersonLookUpEditAftBase.java

public void testIdentityPersonLookUpEdit() throws Exception {
    String randomSalary = RandomStringUtils.randomNumeric(6);
    String randomMiddleName = RandomStringUtils.randomAlphabetic(6);
    ;/*  w w  w.ja  v a  2  s  . com*/
    String randomAddress = RandomStringUtils.randomNumeric(6);
    ;
    String randomExtension = RandomStringUtils.randomNumeric(6);
    ;
    String randomEmail = RandomStringUtils.randomAlphabetic(6);
    ;

    selectFrameIframePortlet();
    waitAndTypeByName("principalName", "fran");
    waitAndClickSearchSecond();
    selectFrameIframePortlet();
    waitAndClickByXpath("//a[@title='edit Person withPrincipal ID=fran ']");
    waitAndTypeByName("document.documentHeader.documentDescription", "Test description of person");

    // Add new information if it is not present.  Otherwise, edit the existing information.
    if (isElementPresentByName("document.affiliations[0].campusCode")) {
        clearTextByName("document.affiliations[0].empInfos[0].baseSalaryAmount");
        waitAndTypeByName("document.affiliations[0].empInfos[0].baseSalaryAmount", "1" + randomSalary);
    } else {
        selectByName("newAffln.affiliationTypeCode", "Staff");
        selectByName("newAffln.campusCode", "BL - BLOOMINGTON");
        waitAndClickByName("newAffln.dflt");
        waitAndClickByName("methodToCall.addAffln.anchor");
        waitAndTypeByName("document.affiliations[0].newEmpInfo.employeeId", "9999999999");
        waitAndClickByName("document.affiliations[0].newEmpInfo.primary");
        selectByName("document.affiliations[0].newEmpInfo.employmentStatusCode", "Active");
        selectByName("document.affiliations[0].newEmpInfo.employmentTypeCode", "Professional");
        waitAndTypeByName("document.affiliations[0].newEmpInfo.baseSalaryAmount", "1" + randomSalary);
        waitAndTypeByXpath("//*[@id='document.affiliations[0].newEmpInfo.primaryDepartmentCode']", "BL-BUS");
        waitAndClickByName("methodToCall.addEmpInfo.line0.anchor");
    }

    waitAndClickByName("methodToCall.showAllTabs");

    // Add nick name or edit the existing one
    if (isTextPresent("CrazyNickName")) {
        clearTextByName("document.names[1].middleName");
        waitAndTypeByName("document.names[1].middleName", randomMiddleName);
    } else {
        waitAndTypeByName("newName.firstName", "CrazyNickName");
        waitAndTypeByName("newName.middleName", randomMiddleName);
        waitAndTypeByName("newName.lastName", "fran");
        waitAndClickByName("methodToCall.addName.anchor");
    }

    // Add address or edit the existing one
    if (isTextPresent("CrazyHomeAddress")) {
        clearTextByName("document.addrs[0].line1");
        waitAndTypeByName("document.addrs[0].line1", randomAddress + " Main St");
    } else {
        waitAndTypeByName("newAddress.line1", randomAddress + " Main St");
        waitAndTypeByName("newAddress.line2", "CrazyHomeAddress");
        waitAndTypeByName("newAddress.city", "Bloomington");
        selectByName("newAddress.stateProvinceCode", "ALASKA");
        waitAndTypeByName("newAddress.postalCode", "61821");
        selectByName("newAddress.countryCode", "United States");
        waitAndClickByName("newAddress.dflt");
        waitAndClickByName("methodToCall.addAddress.anchor");
    }

    // Add phone number or edit the existing one
    if (isTextPresent("555-555-5555")) {
        clearTextByName("document.phones[0].extensionNumber");
        waitAndTypeByName("document.phones[0].extensionNumber", randomExtension);
    } else {
        waitAndTypeByName("newPhone.phoneNumber", "555-555-5555");
        waitAndTypeByName("newPhone.extensionNumber", randomExtension);
        selectByName("newPhone.countryCode", "United States");
        waitAndClickByName("newPhone.dflt");
        waitAndClickByName("methodToCall.addPhone.anchor");
    }

    // Add home email or edit the existing one
    if (isTextPresent("@gmailCrazy.com")) {
        clearTextByName("document.emails[1].emailAddress");
        waitAndTypeByName("document.emails[1].emailAddress", randomEmail + "@gmailCrazy.com");
    } else {
        waitAndTypeByName("newEmail.emailAddress", randomEmail + "@gmailCrazy.com");
        waitAndClickByName("methodToCall.addEmail.anchor");
    }

    waitAndClickByName("methodToCall.route");
    waitForTextPresent("Document was successfully submitted.");

    selectTopFrame();
    waitAndClickAdministration();
    waitAndClickByLinkText("Person");
    selectFrameIframePortlet();
    waitAndTypeByName("principalName", "fran");
    waitAndClickSearchSecond();
    selectFrameIframePortlet();
    waitAndClickByXpath("//a[@title='edit Person withPrincipal ID=fran ']");
    waitAndClickByName("methodToCall.showAllTabs");

    waitForTextPresent("1," + StringUtils.substring(randomSalary, 0, 3) + ","
            + StringUtils.substring(randomSalary, 3, 6) + ".00");
    assertTextPresent(randomMiddleName);
    assertTextPresent(randomAddress);
    assertTextPresent(randomExtension);
    assertTextPresent(randomEmail);

    testCancelConfirmation();
}