本文整理汇总了Java中io.github.benas.randombeans.api.Randomizer.getRandomValue方法的典型用法代码示例。如果您正苦于以下问题:Java Randomizer.getRandomValue方法的具体用法?Java Randomizer.getRandomValue怎么用?Java Randomizer.getRandomValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.github.benas.randombeans.api.Randomizer
的用法示例。
在下文中一共展示了Randomizer.getRandomValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateField
import io.github.benas.randombeans.api.Randomizer; //导入方法依赖的package包/类
void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException {
Randomizer<?> randomizer = getRandomizer(field);
if (randomizer instanceof SkipRandomizer) {
return;
}
context.pushStackItem(new RandomizationContextStackItem(target, field));
if(!context.hasExceededRandomizationDepth()) {
Object value;
if (randomizer != null) {
value = randomizer.getRandomValue();
} else {
try {
value = generateRandomValue(field, context);
} catch (ObjectGenerationException e) {
String exceptionMessage = String.format("Unable to create type: %s for field: %s of class: %s",
field.getType().getName(), field.getName(), target.getClass().getName());
throw new ObjectGenerationException(exceptionMessage, e);
}
}
setProperty(target, field, value);
}
context.popStackItem();
}
示例2: generatedNumberShouldNotBeNull
import io.github.benas.randombeans.api.Randomizer; //导入方法依赖的package包/类
@TestTemplate
@UseDataProvider("generateRandomizers")
public void generatedNumberShouldNotBeNull(Randomizer<?> randomizer) {
// when
Object randomNumber = randomizer.getRandomValue();
then(randomNumber).isNotNull();
}
示例3: shouldGenerateTheSameValueForTheSameSeed
import io.github.benas.randombeans.api.Randomizer; //导入方法依赖的package包/类
@TestTemplate
@UseDataProvider("generateSeededRandomizersAndTheirExpectedValues")
public void shouldGenerateTheSameValueForTheSameSeed(Randomizer<?> randomizer, Object expected) {
//when
Object actual = randomizer.getRandomValue();
then(actual).isEqualTo(expected);
}
示例4: generatedTimeShouldNotBeNull
import io.github.benas.randombeans.api.Randomizer; //导入方法依赖的package包/类
@TestTemplate
@UseDataProvider("generateRandomizers")
public void generatedTimeShouldNotBeNull(Randomizer<?> randomizer) {
// when
Object randomNumber = randomizer.getRandomValue();
then(randomNumber).isNotNull();
}
示例5: generatedCollectionShouldNotBeNull
import io.github.benas.randombeans.api.Randomizer; //导入方法依赖的package包/类
@TestTemplate
@UseDataProvider("generateCollectionRandomizers")
public <T> void generatedCollectionShouldNotBeNull(Randomizer<Collection<T>> collectionRandomizer) {
// when
Collection<T> randomCollection = collectionRandomizer.getRandomValue();
then(randomCollection).isNotNull();
}
示例6: generatedCollectionSizeShouldBeEqualToTheSpecifiedSize
import io.github.benas.randombeans.api.Randomizer; //导入方法依赖的package包/类
@TestTemplate
@UseDataProvider("generateCollectionRandomizersWithSpecificSize")
public <T> void generatedCollectionSizeShouldBeEqualToTheSpecifiedSize(Randomizer<Collection<T>> collectionRandomizer) {
// when
Collection<T> randomCollection = collectionRandomizer.getRandomValue();
then(randomCollection).hasSize(collectionSize);
}
示例7: shouldAllowGeneratingEmptyCollections
import io.github.benas.randombeans.api.Randomizer; //导入方法依赖的package包/类
@TestTemplate
@UseDataProvider("generateCollectionRandomizersForEmptyCollections")
public <T> void shouldAllowGeneratingEmptyCollections(Randomizer<Collection<T>> collectionRandomizer) {
// when
Collection<T> randomCollection = collectionRandomizer.getRandomValue();
then(randomCollection).isEmpty();
}
示例8: generatedValueShouldNotBeNull
import io.github.benas.randombeans.api.Randomizer; //导入方法依赖的package包/类
@TestTemplate
@UseDataProvider("generateRandomizers")
public void generatedValueShouldNotBeNull(Randomizer<?> randomizer) {
// when
Object value = randomizer.getRandomValue();
then(value).isNotNull();
}
示例9: shouldGenerateTheSameValueForTheSameSeedForSameLocale
import io.github.benas.randombeans.api.Randomizer; //导入方法依赖的package包/类
@TestTemplate
@UseDataProvider("generateSeededRandomizersWithLocaleAndTheirExpectedValues")
public void shouldGenerateTheSameValueForTheSameSeedForSameLocale(Randomizer<?> randomizer, Object expected) {
//when
Object actual = randomizer.getRandomValue();
then(actual).isEqualTo(expected);
}
示例10: shouldGenerateValuesBetweenMinAndMax
import io.github.benas.randombeans.api.Randomizer; //导入方法依赖的package包/类
@TestTemplate
@UseDataProvider("generateRandomizersAndMinMax")
@SuppressWarnings({ "rawtypes", "unchecked" })
public void shouldGenerateValuesBetweenMinAndMax(Randomizer<Comparable> randomizer, Comparable min, Comparable max) {
// when
Comparable randomValue = randomizer.getRandomValue();
then(randomValue).isBetween(min, max);
}