Java Code Examples for org.apache.commons.lang3.RandomUtils#nextBoolean()
The following examples show how to use
org.apache.commons.lang3.RandomUtils#nextBoolean() .
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: ReadMyWriteWorkflow.java From azure-cosmosdb-java with MIT License | 6 votes |
/** * Generates a random query * * @return a randomly generated query */ private SqlQuerySpec generateRandomQuery() { int docCount = RandomUtils.nextInt(1, 2); Set<Integer> keys = new HashSet<>(); for (int i = 0; i < docCount; i++) { int key = RandomUtils.nextInt(0, cacheSize); keys.add(key); } List<Document> documentList = null; if (RandomUtils.nextBoolean()) { documentList = keys.stream().map(cache::get).collect(Collectors.toList()); } int top = RandomUtils.nextInt(0, MAX_TOP_QUERY_COUNT); boolean useOrderBy = RandomUtils.nextBoolean(); return generateQuery(documentList, top > 1000 ? top : null, useOrderBy); }
Example 2
Source File: NetBankResultNotifyYEEPAYAction.java From seed with Apache License 2.0 | 6 votes |
/** * 对易宝的请求参数进行验签 * @param param 易宝的请求参数 * @return 验签通过则返回true,反之则返回false */ private boolean checkSign(Map<String, String> param) { //String merNo = ConfigUtil.INSTANCE.getProperty("yeepay.merNo"); //String p1_MerId = param.get("p1_MerId"); //if(!merNo.equals(p1_MerId)){ // LogUtil.getLogger().info("易宝网银结果通知-->验签未通过:易宝通知的商户号[" + p1_MerId + "]与本地存储的商户号[" + merNo + "]不一致"); // return false; //} //StringBuilder sb = new StringBuilder(); //sb.append(p1_MerId).append(param.get("r0_Cmd")).append(param.get("r1_Code")).append(param.get("r2_TrxId")).append(param.get("r3_Amt")) // .append(param.get("r4_Cur")).append(param.get("r5_Pid")).append(param.get("r6_Order")).append(param.get("r7_Uid")) // .append(param.get("r8_MP")).append(param.get("r9_BType")); //if(param.get("hmac").equals(DigestUtil.hmacSign(sb.toString(), ConfigUtil.INSTANCE.getProperty("yeepay.privateKey")))){ //if(true){ // LogUtil.getLogger().info("易宝网银结果通知-->验签通过"); // return true; //}else{ // LogUtil.getLogger().info("易宝网银结果通知-->验签未通过"); // return false; //} return RandomUtils.nextBoolean(); }
Example 3
Source File: TestRegionMergeTransactionOnCluster.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testWholesomeMerge() throws Exception { LOG.info("Starting " + name.getMethodName()); final TableName tableName = TableName.valueOf(name.getMethodName()); try { // Create table and load data. Table table = createTableAndLoadData(MASTER, tableName); // Merge 1st and 2nd region mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1); // Merge 2nd and 3th region PairOfSameType<RegionInfo> mergedRegions = mergeRegionsAndVerifyRegionNum(MASTER, tableName, 1, 2, INITIAL_REGION_NUM - 2); verifyRowCount(table, ROWSIZE); // Randomly choose one of the two merged regions RegionInfo hri = RandomUtils.nextBoolean() ? mergedRegions.getFirst() : mergedRegions.getSecond(); MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); AssignmentManager am = cluster.getMaster().getAssignmentManager(); RegionStates regionStates = am.getRegionStates(); // We should not be able to assign it again am.assign(hri); assertFalse("Merged region can't be assigned", regionStates.isRegionInTransition(hri)); // We should not be able to unassign it either am.unassign(hri); assertFalse("Merged region can't be unassigned", regionStates.isRegionInTransition(hri)); table.close(); } finally { TEST_UTIL.deleteTable(tableName); } }
Example 4
Source File: Address.java From DataDefender with Apache License 2.0 | 5 votes |
public String randomCanadianOrUsFiveOrNineDigitPostalCode() { if (RandomUtils.nextBoolean()) { return randomCanadianPostalCode(); } else if (RandomUtils.nextBoolean()) { return randomUsZipCode(); } return randomUsZipCodeNineDigit(); }
Example 5
Source File: MiniOzoneChaosCluster.java From hadoop-ozone with Apache License 2.0 | 4 votes |
public boolean shouldStop() { if (failedOmSet.size() >= numOzoneManagers/2) { return false; } return RandomUtils.nextBoolean(); }
Example 6
Source File: MiniOzoneChaosCluster.java From hadoop-ozone with Apache License 2.0 | 4 votes |
private int getNumberOfDnToFail() { return RandomUtils.nextBoolean() ? 1 : 2; }
Example 7
Source File: FailureManager.java From hadoop-ozone with Apache License 2.0 | 4 votes |
public static boolean isFastRestart() { return RandomUtils.nextBoolean(); }
Example 8
Source File: LoadBucket.java From hadoop-ozone with Apache License 2.0 | 4 votes |
private boolean isFsOp() { return RandomUtils.nextBoolean(); }
Example 9
Source File: Address.java From DataDefender with Apache License 2.0 | 4 votes |
public String randomCanadianOrUsFiveDigitPostalCode() { if (RandomUtils.nextBoolean()) { return randomCanadianPostalCode(); } return randomUsZipCode(); }
Example 10
Source File: ReadMyWriteWorkflow.java From azure-cosmosdb-java with MIT License | 3 votes |
/** * Given a document list generates a randomly generated sql query which can find only and only the documents * <p> * The generated query may have a top, orderby, top and orderby. * * @param documentList list of documents to be queried for * @return SqlQuerySpec */ private SqlQuerySpec generateQuery(List<Document> documentList) { int top = RandomUtils.nextInt(0, MAX_TOP_QUERY_COUNT); boolean useOrderBy = RandomUtils.nextBoolean(); return generateQuery(documentList, top >= documentList.size() ? top : null, useOrderBy); }