List of usage examples for org.apache.commons.lang3 RandomUtils nextLong
public static long nextLong(final long startInclusive, final long endExclusive)
Returns a random long within the specified range.
From source file:cl.sebastian.random.run.App.java
/** * @param args the command line arguments *//* ww w .ja v a 2 s. co m*/ public static void main(String[] args) { // TODO code application logic here long numero = RandomUtils.nextLong(1000000000000000000L, Long.MAX_VALUE); String aleatoreo = String.format("private static final long serialVersionUID = %dL;", numero); System.out.println(aleatoreo); }
From source file:edu.depaul.armada.util.TestUtil.java
public static ContainerLog newContainerLog() { ContainerLog log = new ContainerLog(); log.setTimestamp(new Timestamp(0)); log.setCpuUsed(RandomUtils.nextLong(0, 100)); log.setCpuTotal(100);/* w w w .j ava 2 s . c o m*/ log.setMemUsed(RandomUtils.nextLong(0, 100)); log.setMemTotal(100); log.setDiskUsed(RandomUtils.nextLong(0, 100)); log.setDiskTotal(100); return log; }
From source file:info.archinnov.achilles.test.integration.tests.bugs.AllowInsertingStaticColumnWithoutClusteringColumnsIT.java
@Test public void should_insert_only_static_columns() throws Exception { //Given// w ww. j a v a2s. c om Long id = RandomUtils.nextLong(0, Long.MAX_VALUE); final ClusteredEntityWithStaticColumn entity = new ClusteredEntityWithStaticColumn(id, null, "city", null); manager.insert(entity); //When final TypedMap found = manager .nativeQuery(select().from(ClusteredEntityWithStaticColumn.TABLE_NAME).where(eq("id", id))) .getFirst(); //Then assertThat(found.getTyped("name")).isNull(); assertThat(found.<String>getTyped("city")).isEqualTo("city"); }
From source file:info.archinnov.achilles.it.bugs.TestEntityWithByteBufferTypeIT.java
@Test public void should_support_bytebuffer_type() throws Exception { //Given/* w w w. j av a 2s . co m*/ final Cluster cluster = CassandraEmbeddedServerBuilder.builder().useUnsafeCassandraDeamon() .withScript("functions/createFunctions.cql").buildNativeCluster(); final Long id = RandomUtils.nextLong(0, Long.MAX_VALUE); final byte[] bytes = RandomUtils.nextBytes(100); final ByteBuffer value = ByteBuffer.wrap(bytes); //When final ManagerFactory managerFactory = ManagerFactoryBuilder.builder(cluster) .withManagedEntityClasses(EntityWithByteBufferType.class).doForceSchemaCreation(true) .withDefaultKeyspaceName(DEFAULT_CASSANDRA_EMBEDDED_KEYSPACE_NAME).build(); final EntityWithByteBufferType_Manager manager = managerFactory.forEntityWithByteBufferType(); final EntityWithByteBufferType entity = new EntityWithByteBufferType(id, value); manager.crud().insert(entity).execute(); final Row one = manager.getNativeSession() .execute("SELECT * FROM " + EntityWithByteBufferType.TABLE + " WHERE id = " + id).one(); assertThat(one).isNotNull(); assertThat(one.getBytes("value")).isEqualTo(value); }
From source file:com.navercorp.pinpoint.common.server.bo.RandomTSpan.java
public TSpan randomTSpan() { final TSpan tSpan = new TSpan(); tSpan.setAgentId("agentId"); tSpan.setApplicationName("appName"); tSpan.setAgentStartTime(System.currentTimeMillis()); tSpan.setTransactionId(TransactionIdUtils.formatByteBuffer("agent", System.currentTimeMillis(), RandomUtils.nextLong(0, Long.MAX_VALUE))); tSpan.setSpanId(random.nextLong());//from www . j a va 2 s. c o m tSpan.setParentSpanId(RandomUtils.nextInt(0, 100000)); tSpan.setStartTime(System.currentTimeMillis() + RandomUtils.nextInt(0, 1000)); tSpan.setElapsed(RandomUtils.nextInt(0, 2000)); tSpan.setRpc(RandomStringUtils.random(10)); tSpan.setServiceType(randomServerServiceType()); tSpan.setEndPoint(RandomStringUtils.random(20)); tSpan.setRemoteAddr(RandomStringUtils.random(20)); List<TAnnotation> tAnnotationList = randomTAnnotationList(); if (CollectionUtils.isNotEmpty(tAnnotationList)) { tSpan.setAnnotations(tAnnotationList); } tSpan.setFlag((short) RandomUtils.nextInt(0, 4)); tSpan.setErr((short) RandomUtils.nextInt(0, 2)); // tSpan.setSpanEventList() tSpan.setParentApplicationName("parentApp"); tSpan.setParentApplicationType(randomServerServiceType()); tSpan.setAcceptorHost("acceptHost"); tSpan.setApiId(RandomUtils.nextInt(0, 5000)); if (random.nextBoolean()) { tSpan.setApplicationServiceType(randomServerServiceType()); } else { tSpan.setApplicationServiceType(tSpan.getServiceType()); } if (random.nextBoolean()) { TIntStringValue exceptionInfo = new TIntStringValue(); exceptionInfo.setIntValue(RandomUtils.nextInt(0, 5000)); exceptionInfo.setStringValue(RandomStringUtils.random(100)); tSpan.setExceptionInfo(exceptionInfo); } tSpan.setLoggingTransactionInfo((byte) RandomUtils.nextInt(0, 256)); return tSpan; }
From source file:info.archinnov.achilles.test.integration.tests.EntityWithTypeTransformerIT.java
@Test public void should_insert_and_find_entity_with_transformed_types() throws Exception { //Given/*from w ww .ja v a2 s . c o m*/ Long id = RandomUtils.nextLong(0, Long.MAX_VALUE); Long longValue = RandomUtils.nextLong(0, Long.MAX_VALUE); final EntityWithTypeTransformer entity = new EntityWithTypeTransformer(id, longValue, Arrays.asList(longValue), Sets.newSet(longValue), ImmutableMap.of(longValue, "longValue"), ImmutableMap.of(1, longValue), ImmutableMap.of(longValue, NamingStrategy.CASE_SENSITIVE)); manager.insert(entity); //When final EntityWithTypeTransformer found = manager.find(EntityWithTypeTransformer.class, id); //Then assertThat(found.getLongToString()).isEqualTo(longValue); assertThat(found.getMyList()).contains(longValue); assertThat(found.getMySet()).contains(longValue); assertThat(found.getKeyMap()).hasSize(1).containsKey(longValue).containsValue("longValue"); assertThat(found.getValueMap()).hasSize(1).containsKey(1).containsValue(longValue); assertThat(found.getKeyValueMap()).hasSize(1).containsKey(longValue) .containsValue(NamingStrategy.CASE_SENSITIVE); }
From source file:info.archinnov.achilles.test.integration.tests.bugs.WrongConsistencyForSliceQueryIT.java
@Test public void should_slice_query_with_class_consistency_level() throws Exception { //Given/*from w ww . ja v a2s .com*/ Long id = RandomUtils.nextLong(0, Long.MAX_VALUE); Date date1 = new Date(1); Date date2 = new Date(2); Date date3 = new Date(3); final ClusteredEntityWithConsistencyLevel entity1 = new ClusteredEntityWithConsistencyLevel(id, date1, "1"); final ClusteredEntityWithConsistencyLevel entity2 = new ClusteredEntityWithConsistencyLevel(id, date2, "2"); final ClusteredEntityWithConsistencyLevel entity3 = new ClusteredEntityWithConsistencyLevel(id, date3, "3"); manager.insert(entity1); manager.insert(entity2); manager.insert(entity3); //When logAsserter.prepareLogLevelForDriverConnection(); final ClusteredEntityWithConsistencyLevel found = manager .sliceQuery(ClusteredEntityWithConsistencyLevel.class).forSelect().withPartitionComponents(id) .fromClusterings(date1).getOne(); //Then assertThat(found.getId().getDate()).isEqualTo(date1); logAsserter.assertConsistencyLevels(ConsistencyLevel.LOCAL_ONE); }
From source file:com.devicehive.service.JwtClientServiceTest.java
@Test public void should_generate_jwt_token_with_access_type() throws Exception { // Create payload Long userId = RandomUtils.nextLong(10, 1000); Set<String> actions = new HashSet<>(); actions.add("string"); Set<String> networkIds = new HashSet<>(); networkIds.add("string"); Set<String> deviceGuids = new HashSet<>(); deviceGuids.add("string"); JwtPayload.Builder builder = new JwtPayload.Builder(); JwtPayload payload = builder.withPublicClaims(userId, actions, networkIds, deviceGuids).buildPayload(); String token = jwtClientService.generateJwtAccessToken(payload); JwtPayload resultPayload = jwtClientService.getPayload(token); assertEquals(resultPayload.getTokenType(), TokenType.ACCESS); }
From source file:info.archinnov.achilles.test.integration.tests.NamingStrategyIT.java
@Test public void should_apply_snake_case_naming() throws Exception { //Given/* w w w .j a v a 2s. c om*/ Long id = RandomUtils.nextLong(0, Long.MAX_VALUE); EntityWithNamingStrategy entity = new EntityWithNamingStrategy(id, "fn", "ln", "nick"); //When manager.insert(entity); //Then final Row row = session.execute("SELECT * from achilles_test.snake_case_naming WHERE my_id = ?", id).one(); assertThat(row).isNotNull(); assertThat(row.getLong("my_id")).isEqualTo(id); assertThat(row.getString("fn")).isEqualTo("fn"); assertThat(row.getString("last_name")).isEqualTo("ln"); assertThat(row.getString("nickName")).isEqualTo("nick"); //When final EntityWithNamingStrategy found = manager.find(EntityWithNamingStrategy.class, id); //Then assertThat(found.getFirstName()).isEqualTo("fn"); assertThat(found.getLastName()).isEqualTo("ln"); assertThat(found.getNickName()).isEqualTo("nick"); }
From source file:info.archinnov.achilles.test.integration.tests.CacheSizeIT.java
@Test public void should_re_prepare_statements_when_cache_size_exceeded() throws Exception { //Given// w w w . j av a 2 s . com CompleteBean bean = builder().id(RandomUtils.nextLong(0, Long.MAX_VALUE)).name("name").buid(); CompleteBean managed = pm.insert(bean); //When managed.setAge(10L); pm.update(managed); managed.setFriends(Arrays.asList("foo", "bar")); pm.update(managed); managed.setFollowers(Sets.newHashSet("George", "Paul")); pm.update(managed); managed.setAge(11L); pm.update(managed); //Then CompleteBean found = pm.find(CompleteBean.class, bean.getId()); assertThat(found.getAge()).isEqualTo(11L); assertThat(found.getName()).isEqualTo("name"); assertThat(found.getFriends()).containsExactly("foo", "bar"); assertThat(found.getFollowers()).containsOnly("George", "Paul"); }