public static int rand(int ceiling) { return RandomUtils.instance().nextInt(ceiling); }
@Override protected Snapshot generateNewEntity() { return new Snapshot(Guid.newGuid(), RandomUtils.instance().nextEnum(SnapshotStatus.class), EXISTING_VM_ID, RandomUtils.instance().nextString(200000), RandomUtils.instance().nextEnum(SnapshotType.class), RandomUtils.instance().nextString(1000), new Date(), RandomUtils.instance().nextString(200000)); }
public static Stream<Arguments> data() { // XmlUtils.getXYZValue support recursive searching from a depth of 2 and above, e.g.: // <tag><innerTag>value</innerTag><tag> return IntStream.range(2, 10).mapToObj(i -> Arguments.of(i, String.valueOf(RandomUtils.instance().nextInt()))); }
private List<GlusterClientInfo> getClientList(int listSize) { ArrayList<GlusterClientInfo> list = new ArrayList<>(); for(int i=0; i < listSize; i++) { GlusterClientInfo clientInfo = new GlusterClientInfo(); clientInfo.setBytesRead(RandomUtils.instance().nextLong()); clientInfo.setBytesWritten(RandomUtils.instance().nextLong()); clientInfo.setClientPort(RandomUtils.instance().nextInt()); clientInfo.setHostname(RandomUtils.instance().nextString(7)); list.add(clientInfo); } return list; }
@Override protected void updateExistingEntity() { existingEntity.setDescription(RandomUtils.instance().nextString(1000)); }
@Override protected void updateExistingEntity() { existingEntity.setName(RandomUtils.instance().nextString(15)); }
@Override protected void updateExistingEntity() { existingEntity.setName(RandomUtils.instance().nextString(15)); }
@Override protected DiskLunMapId generateNonExistingId() { return new DiskLunMapId(Guid.newGuid(), RandomUtils.instance().nextString(10)); }
/** * Ensures an empty list is returned for an invalid connection. */ @Test public void testGetAllForConnectionWithInvalidConnection() { List<StorageDomain> result = dao.getAllForConnection(RandomUtils.instance().nextString(10)); assertTrue(result.isEmpty()); }
/** * Ensures an empty list is returned for an invalid connection. */ @Test public void testGetAllByStoragePoolAndConnectionWithInvalidConnection() { List<StorageDomain> result = dao.getAllByStoragePoolAndConnection(FixturesTool.STORAGE_POOL_NFS, RandomUtils.instance().nextString(10)); assertTrue(result.isEmpty()); }
@BeforeEach @Override public void setUp() throws Exception { super.setUp(); existingEngineBackupLog = dao.getLastSuccessfulEngineBackup(SCOPE); newEntity = new EngineBackupLog(); newEntity.setScope(RandomUtils.instance().nextString(20)); newEntity.setDoneAt(new Date()); newEntity.setPassed(true); newEntity.setOutputMessage(RandomUtils.instance().nextString(20)); newEntity.setFqdn(RandomUtils.instance().nextString(20)); newEntity.setLogPath(RandomUtils.instance().nextString(20)); }
/** * Ensures an empty list is returned for an invalid storage pool id and connection. */ @Test public void testGetAllByStoragePoolAndConnectionWithInvalidInput() { List<StorageDomain> result = dao.getAllByStoragePoolAndConnection(Guid.newGuid(), RandomUtils.instance().nextString(10)); assertTrue(result.isEmpty()); }
private VdsNetworkInterface createVlan(String baseIfaceName) { VdsNetworkInterface iface = new Vlan(); iface.setVlanId(RandomUtils.instance().nextInt(100)); iface.setBaseInterface(baseIfaceName); return iface; }
@ParameterizedTest @MethodSource public void ranges(List<LongRange> inputRanges, List<LongRange> expectedRanges) { Collections.shuffle(inputRanges, RandomUtils.instance()); DisjointRanges disjointRanges = new DisjointRanges(); disjointRanges.addRanges(inputRanges); Collection<LongRange> result = disjointRanges.getRanges(); assertTrue(CollectionUtils.isEqualCollection(expectedRanges, result)); } }
@Test public void testUpdateStatusAndReasons() { VdsDynamic before = dao.get(FixturesTool.VDS_GLUSTER_SERVER2); before.setStatus(RandomUtils.instance().nextEnum(VDSStatus.class)); before.setNonOperationalReason(RandomUtils.instance().nextEnum(NonOperationalReason.class)); before.setMaintenanceReason(RandomUtils.instance().nextString(50)); dao.updateStatusAndReasons(before); VdsDynamic after = dao.get(FixturesTool.VDS_GLUSTER_SERVER2); assertEquals(before, after); assertEquals(before.getStatus(), after.getStatus()); assertEquals(before.getNonOperationalReason(), after.getNonOperationalReason()); assertEquals(before.getMaintenanceReason(), after.getMaintenanceReason()); }
private static Role randomRole() { RandomUtils random = RandomUtils.instance(); Role role = new Role(); role.setDescription(random.nextString(10)); role.setId(Guid.newGuid()); role.setName(random.nextString(10)); return role; }
private static StoragePool randomStoragePool() { RandomUtils random = RandomUtils.instance(); StoragePool sp = new StoragePool(); sp.setdescription(random.nextString(10)); sp.setComment(random.nextString(10)); sp.setName(random.nextString(10)); sp.setId(Guid.newGuid()); sp.setIsLocal(random.nextBoolean()); sp.setStatus(random.nextEnum(StoragePoolStatus.class)); return sp; }
private static StorageDomainStatic randomStorageDomainStatic() { RandomUtils random = RandomUtils.instance(); StorageDomainStatic sds = new StorageDomainStatic(); sds.setId(Guid.newGuid()); sds.setStorage(random.nextString(10)); sds.setStorageType(random.nextEnum(StorageType.class)); sds.setStorageName(random.nextString(10)); sds.setDescription(random.nextString(10)); sds.setWarningLowSpaceIndicator(5); sds.setCriticalSpaceActionBlocker(10); return sds; }