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

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

Introduction

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

Prototype

public static String randomAlphabetic(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 alphabetic characters.

Usage

From source file:com.haulmont.restapi.service.filter.RestFilterParserTest.java

@Test
public void testOrGroup() throws Exception {
    new StrictExpectations() {
        {// ww w .j av a  2s.c o  m
            RandomStringUtils.randomAlphabetic(anyInt);
            result = "stringParamName";
            RandomStringUtils.randomAlphabetic(anyInt);
            result = "intParamName";
            RandomStringUtils.randomAlphabetic(anyInt);
            result = "booleanParamName";
        }
    };

    String data = readDataFromFile("data/restFilter3.json");
    MetaClass metaClass = metadata.getClass("test$TestEntity");
    RestFilterParseResult parseResult = restFilterParser.parse(data, metaClass);

    String expectedJpqlWhere = "(({E}.stringField <> :stringParamName or "
            + "{E}.intField > :intParamName) and " + "{E}.booleanField = :booleanParamName)";
    assertEquals(expectedJpqlWhere, parseResult.getJpqlWhere());

    Map<String, Object> queryParameters = parseResult.getQueryParameters();

    assertEquals("stringValue", queryParameters.get("stringParamName"));
    assertEquals(100, queryParameters.get("intParamName"));
    assertEquals(true, queryParameters.get("booleanParamName"));
}

From source file:com.magnet.mmx.server.plugin.mmxmgmt.api.tags.MMXUserTagsResourceTest.java

public static AppEntity createRandomApp() throws Exception {

    String serverUserId = "serverUser";
    String appName = "usertagresourcetestapp";
    String appId = RandomStringUtils.randomAlphanumeric(10);
    String apiKey = UUID.randomUUID().toString();
    String googleApiKey = UUID.randomUUID().toString();
    String googleProjectId = RandomStringUtils.randomAlphanumeric(8);
    String apnsPwd = RandomStringUtils.randomAlphanumeric(10);
    String ownerId = RandomStringUtils.randomAlphabetic(10);
    String ownerEmail = RandomStringUtils.randomAlphabetic(4) + "@magnet.com";
    String guestSecret = RandomStringUtils.randomAlphabetic(10);
    boolean apnsProductionEnvironment = false;

    AppEntity appEntity = new AppEntity();
    appEntity.setServerUserId(serverUserId);
    appEntity.setName(appName);/*from  w w  w. java2 s  .  co  m*/
    appEntity.setAppId(appId);
    appEntity.setAppAPIKey(apiKey);
    appEntity.setGoogleAPIKey(googleApiKey);
    appEntity.setGoogleProjectId(googleProjectId);
    appEntity.setApnsCertPassword(apnsPwd);
    appEntity.setOwnerId(ownerId);
    appEntity.setOwnerEmail(ownerEmail);
    appEntity.setGuestSecret(guestSecret);
    appEntity.setApnsCertProduction(apnsProductionEnvironment);
    DBTestUtil.getAppDAO().persist(appEntity);
    return appEntity;
}

From source file:com.gooddata.dataset.DatasetService.java

/**
 * Loads dataset into platform. Uploads given dataset and manifest to staging area and triggers ETL pull.
 * The call is asynchronous returning {@link com.gooddata.FutureResult} to let caller wait for results.
 * Uploaded files are deleted from staging area when finished.
 *
 * @param project  project to which dataset belongs
 * @param manifest dataset manifest/*from   ww w .jav  a 2 s .c o m*/
 * @param dataset  dataset to upload
 * @return {@link com.gooddata.FutureResult} of the task, which can throw {@link com.gooddata.dataset.DatasetException}
 * in case the ETL pull task fails
 * @throws com.gooddata.dataset.DatasetException if there is a problem to serialize manifest or upload dataset
 */
public FutureResult<Void> loadDataset(final Project project, final DatasetManifest manifest,
        final InputStream dataset) {
    notNull(project, "project");
    notNull(dataset, "dataset");
    notNull(manifest, "manifest");
    final Path dirPath = Paths.get("/", project.getId() + "_" + RandomStringUtils.randomAlphabetic(3), "/");
    try {
        dataStoreService.upload(dirPath.resolve(manifest.getFile()).toString(), dataset);
        final String manifestJson = mapper.writeValueAsString(manifest);
        final ByteArrayInputStream inputStream = new ByteArrayInputStream(manifestJson.getBytes(UTF_8));
        dataStoreService.upload(dirPath.resolve(MANIFEST_FILE_NAME).toString(), inputStream);

        return pullLoad(project, dirPath, manifest.getDataSet());
    } catch (IOException e) {
        throw new DatasetException("Unable to serialize manifest", manifest.getDataSet(), e);
    } catch (DataStoreException | GoodDataRestException | RestClientException e) {
        throw new DatasetException("Unable to load", manifest.getDataSet(), e);
    }
}

From source file:gobblin.writer.jdbc.MySqlBufferedInserterTest.java

private List<JdbcEntryData> createJdbcEntries(int colNums, int colSize, int entryCount) {
    Set<String> colNames = new HashSet<>();
    while (colNames.size() < colNums) {
        String colName = RandomStringUtils.randomAlphabetic(colSize);
        if (colNames.contains(colName)) {
            continue;
        }//from  www .  ja  v a2s . c  om
        colNames.add(colName);
    }

    List<JdbcEntryData> result = new ArrayList<>();
    for (int i = 0; i < entryCount; i++) {
        result.add(createJdbcEntry(colNames, colSize));
    }
    return result;
}

From source file:net.shopxx.entity.Admin.java

@PrePersist
public void prePersist() {
    setUsername(StringUtils.lowerCase(getUsername()));
    setEmail(StringUtils.lowerCase(getEmail()));
    setLockKey(DigestUtils.md5Hex(UUID.randomUUID() + RandomStringUtils.randomAlphabetic(30)));
}

From source file:net.nelz.simplesm.test.dao.TestDAOImpl.java

@ReadThroughMultiCache(namespace = "Delta", expiration = 1000)
public List<String> getRandomStrings(@ParameterValueKeyProvider final List<Long> keys) {
    try {//w  w w .j  a v  a 2  s  .co  m
        Thread.sleep(500);
    } catch (InterruptedException ex) {
    }
    final String series = RandomStringUtils.randomAlphabetic(6);
    final List<String> results = new ArrayList<String>(keys.size());
    for (final Long key : keys) {
        results.add(series + "-" + key.toString() + "-"
                + RandomStringUtils.randomAlphanumeric(25 + RandomUtils.nextInt(30)));
    }
    return results;
}

From source file:edu.samplu.common.ITUtil.java

public static String createUniqueDtsPlusTwoRandomChars() {
    return Calendar.getInstance().getTimeInMillis() + "" + RandomStringUtils.randomAlphabetic(2).toLowerCase();
}

From source file:edu.samplu.admin.test.IdentityPersonCreateNewAbstractSmokeTestBase.java

public void testIdentityPersonCreateNew() throws Exception {
    selectFrameIframePortlet();//ww  w  . j  a  v  a  2 s. c o m
    waitAndClickByXpath(CREATE_NEW_XPATH);
    waitAndTypeByName("document.documentHeader.documentDescription", "Test description of person");
    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", "99999");
    waitAndTypeByXpath("//*[@id='document.affiliations[0].newEmpInfo.primaryDepartmentCode']", "BL-BUS");
    waitAndClickByName("methodToCall.addEmpInfo.line0.anchor");
    waitAndClickByName("methodToCall.showAllTabs");
    selectByName("newName.nameCode", "Primary");
    waitAndTypeByName("newName.firstName", "Marco");
    waitAndTypeByName("newName.lastName", "Simoncelli");
    waitAndClickByName("newName.dflt");
    waitAndClickByName("methodToCall.addName.anchor");
    selectByName("newAddress.addressTypeCode", "Work");
    waitAndTypeByName("newAddress.line1", "123 Address Ln");
    waitAndTypeByName("newAddress.city", "Bloomington");
    selectByName("newAddress.stateProvinceCode", "INDIANA");
    waitAndTypeByName("newAddress.postalCode", "47408");
    selectByName("newAddress.countryCode", "United States");
    waitAndClickByName("newAddress.dflt");
    waitAndClickByName("methodToCall.addAddress.anchor");
    selectByName("newPhone.phoneTypeCode", "Work");
    waitAndTypeByName("newPhone.phoneNumber", "855-555-5555");
    selectByName("newPhone.countryCode", "United States");
    waitAndClickByName("newPhone.dflt");
    waitAndClickByName("methodToCall.addPhone.anchor");
    waitAndTypeByName("newEmail.emailAddress", "email@provider.net");
    selectByName("newEmail.emailTypeCode", "Work");
    waitAndClickByName("newEmail.dflt");
    waitAndClickByName("methodToCall.addEmail.anchor");
    waitAndTypeByName("document.principalName", RandomStringUtils.randomAlphabetic(12).toLowerCase());

    //Expand All , Submit , Close and Don't Save.        
    waitAndClickByName("methodToCall.route");
    checkForDocError();
    //        assertTextPresent("Document was successfully submitted.");
    waitAndClickByName("methodToCall.close");
    waitAndClickByName("methodToCall.processAnswer.button1");
}

From source file:com.shaie.solr.SplitShardTest.java

private static String generateRandomBody(Random random) {
    final int numWords = random.nextInt(900) + 100;
    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < numWords; i++) {
        final int sentenceLength = random.nextInt(10) + 10;
        for (int j = 0; j < sentenceLength && i < numWords; j++) {
            final int wordLength = random.nextInt(7) + 3;
            sb.append(RandomStringUtils.randomAlphabetic(wordLength)).append(" ");
        }//from ww  w.ja v  a2 s . co m
        sb.setLength(sb.length() - 1);
        sb.append('.');
    }
    return sb.toString();
}

From source file:eu.scape_project.archiventory.container.ArcContainer.java

/**
 * Create temporary files and create bidirectional file-record map.
 *
 * @throws IOException IO Error//from ww w  .  j  a  v  a 2  s .co m
 */
private void arcRecContentsToTempFiles() throws IOException {
    extractDirectoryName = "/tmp/archiventory_" + RandomStringUtils.randomAlphabetic(10) + "/";
    File destDir = new File(extractDirectoryName);
    destDir.mkdir();
    Iterator<ArchiveRecord> recordIterator = reader.iterator();
    try {
        // K: Record key V: Temporary file
        while (recordIterator.hasNext()) {
            ArchiveRecord nativeArchiveRecord = recordIterator.next();
            archiveRecords.add(nativeArchiveRecord);
            String readerIdentifier = nativeArchiveRecord.getHeader().getReaderIdentifier();
            String recordIdentifier = nativeArchiveRecord.getHeader().getRecordIdentifier();
            ARCRecord arcRecord = (ARCRecord) nativeArchiveRecord;
            byte[] content = ArcContainer.readArcRecContentToByteArr(arcRecord);
            String recordKey = readerIdentifier + "/" + recordIdentifier;
            if (nativeArchiveRecord.getHeader().getLength() < Integer.MAX_VALUE) {
                File tmpFile = IOUtils.copyByteArrayToTempFileInDir(content, extractDirectoryName, ".tmp");
                //                    tmpFile.deleteOnExit();
                this.put(recordKey, tmpFile.getAbsolutePath());
            }
        }
    } catch (RuntimeException ex) {
        logger.error("ARC reader error, skipped.", ex);
    }
}