/** * Randomize a valid entity name. * * @param length * The requested length of the string. */ public String nextPropertyString(int length) { return nextString(length, LEGAL_PROPERTY_CHARS); }
/** * Randomize a printable {@code String}. * * @param length * The requested length of the string. */ public String nextString(int length) { return nextString(length, true); }
/** * Randomize a {@code String} of a length in the given range [min, max]. * * @param printable * Whether or not, the string should contain only printable characters. */ public String nextString(int min, int max, boolean printable) { return nextString(nextInt(min, max), printable); }
/** * Randomize a printable {@code String} of a length in the given range [min, max]. */ public String nextString(int min, int max) { return nextString(nextInt(min, max), true); }
@Override protected void updateExistingEntity() { existingEntity.setName(RandomUtils.instance().nextString(15)); }
@Override protected void updateExistingEntity() { existingEntity.setDescription(RandomUtils.instance().nextString(1000)); }
@Override protected void updateExistingEntity() { existingEntity.setName(RandomUtils.instance().nextString(15)); }
@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)); }
@Override protected DiskLunMapId generateNonExistingId() { return new DiskLunMapId(Guid.newGuid(), RandomUtils.instance().nextString(10)); }
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; }
/** * 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()); }
/** * 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()); }
@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)); }
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; }
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; }
@Test public void testAddingNewUnsuccessfulBackupEvent() { EngineBackupLog engineBackupLog = new EngineBackupLog(); engineBackupLog.setScope(SCOPE); engineBackupLog.setDoneAt(Calendar.getInstance().getTime()); engineBackupLog.setPassed(false); engineBackupLog.setOutputMessage("backup failed"); engineBackupLog.setFqdn(RandomUtils.instance().nextString(20)); engineBackupLog.setLogPath(RandomUtils.instance().nextString(20)); dao.save(engineBackupLog); EngineBackupLog entry = dao.getLastSuccessfulEngineBackup(SCOPE); assertNotNull(entry); assertEquals(entry, existingEngineBackupLog); }
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; }
/** * Construct a new POJO initialized with random values. */ public JsonSerializablePojo() { integer = RandomUtils.instance().nextInt(); setGuid(Guid.newGuid()); setString(RandomUtils.instance().nextString(100, 100000)); setObject(Guid.newGuid()); }
@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()); }