本文整理汇总了Java中org.junit.jupiter.params.provider.Arguments类的典型用法代码示例。如果您正苦于以下问题:Java Arguments类的具体用法?Java Arguments怎么用?Java Arguments使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Arguments类属于org.junit.jupiter.params.provider包,在下文中一共展示了Arguments类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nodeProvider
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
static Stream<Arguments> nodeProvider() {
return Stream.of(
new ArcNode(),
new CircleNode(),
new EllipseNode(),
new GroupNode(Collections.singletonList(new TextNode())),
new LineNode(),
new PolygonNode(Arrays.asList(0d, 0d, 20d, 20d, 30d, 30d)),
new PolylineNode(Arrays.asList(0d, 0d, 20d, 20d, 30d, 30d, 0d, 0d)),
new RectangleNode(),
new SVGPathNode(),
new TextNode()
).flatMap(node -> node.propertyBindings()
.entrySet()
.stream()
.map(entry -> Arguments.of(
node,
entry.getKey(),
entry.getValue(),
node.getClass().getSimpleName()
))
);
}
示例2: provideTestTemplateInvocationContexts
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
Method templateMethod = Preconditions.notNull(context.getTestMethod().orElse(null),
"test method must not be null");
AutoTestNameFormatter formatter = createNameFormatter(templateMethod);
AtomicLong invocationCount = new AtomicLong(0L);
return (Stream) findRepeatableAnnotations(templateMethod, ArgumentsSource.class)
.stream()
.map(ArgumentsSource::value)
.map(ReflectionUtils::newInstance)
.map(provider -> AnnotationConsumerInitializer.initialize(templateMethod, provider))
.flatMap(provider -> arguments(provider, context))
.map(Arguments::get)
.map((arguments) -> {
return new AutoTestInvocationContext(formatter, arguments);
})
.peek((invocationContext) -> {
invocationCount.incrementAndGet();
}).onClose(() -> {
Preconditions.condition(invocationCount.get() > 0L, () -> {
return "当使用注解 @" + AutoTest.class.getSimpleName() + " 的时候,测试方法需要至少一个参数";
});
});
}
示例3: typeAndAddressProvider
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
private static Stream<Arguments> typeAndAddressProvider() {
List<Arguments> arguments = new LinkedList<>();
Arrays.asList(
Boolean.class,
Byte.class,
Short.class,
// TODO: enable once Calender in implemented
//Calendar.class,
Float.class,
Integer.class,
String.class)
.forEach(
aClass -> Arrays.asList(
mock(S7Address.class),
mock(S7BitAddress.class),
mock(S7DataBlockAddress.class))
.forEach(s7Address -> arguments.add(Arguments.of(aClass, s7Address)))
);
return arguments.stream();
}
示例4: isDifferentArguments
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
private static Stream<Arguments> isDifferentArguments() {
return Stream.of(
Arguments.of(null, "null"),
Arguments.of("null", null),
Arguments.of("", "A"),
Arguments.of(new int[0], ""),
Arguments.of(new int[]{1}, new int[]{2}),
Arguments.of(new double[]{1.1}, new double[]{1.2}),
Arguments.of(new byte[]{3}, new byte[]{4}),
Arguments.of(new short[]{4}, new short[]{5}),
Arguments.of(new char[]{'a'}, new char[]{'b'}),
Arguments.of(new boolean[]{true}, new boolean[]{false}),
Arguments.of(new float[]{2.2f}, new float[]{2.3f}),
Arguments.of(new Object[]{"Test"}, new Object[]{"Tests"}),
Arguments.of(new int[0], new double[0])
);
}
示例5: responseJoinGameErrorMappings
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
private static Stream<Arguments> responseJoinGameErrorMappings() {
return Stream.of(
of(Sc2Api.ResponseJoinGame.Error.MissingParticipation, MISSING_PARTICIPATION),
of(Sc2Api.ResponseJoinGame.Error.InvalidObservedPlayerId, INVALID_OBSERVED_PLAYER_ID),
of(Sc2Api.ResponseJoinGame.Error.MissingOptions, MISSING_OPTIONS),
of(Sc2Api.ResponseJoinGame.Error.MissingPorts, MISSING_PORTS),
of(Sc2Api.ResponseJoinGame.Error.GameFull, GAME_FULL),
of(Sc2Api.ResponseJoinGame.Error.LaunchError, LAUNCH_ERROR),
of(Sc2Api.ResponseJoinGame.Error.FeatureUnsupported, FEATURE_UNSUPPORTED),
of(Sc2Api.ResponseJoinGame.Error.NoSpaceForUser, NO_SPACE_FOR_USER),
of(Sc2Api.ResponseJoinGame.Error.MapDoesNotExist, MAP_DOES_NOT_EXIST),
of(Sc2Api.ResponseJoinGame.Error.CannotOpenMap, CANNOT_OPEN_MAP),
of(Sc2Api.ResponseJoinGame.Error.ChecksumError, CHECKSUM_ERROR),
of(Sc2Api.ResponseJoinGame.Error.NetworkError, NETWORK_ERROR),
of(Sc2Api.ResponseJoinGame.Error.OtherError, OTHER_ERROR));
}
示例6: data
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
public static Stream<Arguments> data() {
return Stream.of(
ClaimArguments.of(OpenIdStandardClaims::getSub, "sub"),
ClaimArguments.of(OpenIdStandardClaims::getName, "name"),
ClaimArguments.of(OpenIdStandardClaims::getGivenName, "given_name"),
ClaimArguments.of(OpenIdStandardClaims::getFamilyName, "family_name"),
ClaimArguments.of(OpenIdStandardClaims::getMiddleName, "middle_name"),
ClaimArguments.of(OpenIdStandardClaims::getNickname, "nickname"),
ClaimArguments.of(OpenIdStandardClaims::getPreferredUsername, "preferred_username"),
ClaimArguments.of(OpenIdStandardClaims::getProfile, "profile"),
ClaimArguments.of(OpenIdStandardClaims::getPicture, "picture"),
ClaimArguments.of(OpenIdStandardClaims::getWebsite, "website"),
ClaimArguments.of(OpenIdStandardClaims::getEmail, "email"),
ClaimArguments.of(OpenIdStandardClaims::getEmailVerified, "email_verified", true),
ClaimArguments.of(OpenIdStandardClaims::getGender, "gender"),
ClaimArguments.of(OpenIdStandardClaims::getBirthdate, "birthdate"),
ClaimArguments.of(OpenIdStandardClaims::getZoneinfo, "zoneinfo"),
ClaimArguments.of(OpenIdStandardClaims::getLocale, "locale"),
ClaimArguments.of(OpenIdStandardClaims::getPhoneNumber, "phone_number"),
ClaimArguments.of(OpenIdStandardClaims::getPhoneNumberVerified, "phone_number_verified", true),
ClaimArguments.of(OpenIdStandardClaims::getUpdatedAt, "updated_at", 123L));
}
示例7: data
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
public static Stream<? extends Arguments> data(boolean excludeMandatory) {
List<ClaimArguments<OpenIdIdTokenClaims>> getters = new ArrayList<>();
if (!excludeMandatory) {
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getIss, "iss"));
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getSub, "sub"));
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getAud, "aud", Collections.singletonList("aud0")));
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getSingleAud, "aud"));
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getExp, "exp", 123L));
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getIat, "iat", 123L));
}
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getAuthTime, "auth_time", 123L));
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getNonce, "nonce"));
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getAcr, "acr"));
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getNonce, "nonce"));
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getAmr, "amr", Collections.singletonList("amr0")));
getters.add(ClaimArguments.of(OpenIdIdTokenClaims::getAzp, "azp"));
return getters.stream();
}
示例8: provideArguments
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
Sleep sleep = Thread::sleep;
PatientExecutionHandler executionHandler = new SimpleExecutionHandler();
DelaySupplierFactory delaySupplierFactory = new FixedDelaySupplierFactory(Duration.ZERO);
PatientExecutable<Boolean> executable = () -> true;
Predicate<Boolean> filter = bool -> null != bool && bool;
Supplier<String> messageSupplier = () -> "hello";
return Stream.of(Arguments.of(null, Duration.ZERO, Duration.ZERO, executionHandler, delaySupplierFactory, executable, filter, messageSupplier),
Arguments.of(sleep, null, Duration.ZERO, executionHandler, delaySupplierFactory, executable, filter, messageSupplier),
Arguments.of(sleep, Duration.ofMillis(-500), Duration.ZERO, executionHandler, delaySupplierFactory, executable, filter, messageSupplier),
Arguments.of(sleep, Duration.ZERO, null, executionHandler, delaySupplierFactory, executable, filter, messageSupplier),
Arguments.of(sleep, Duration.ZERO, Duration.ofMillis(-500), executionHandler, delaySupplierFactory, executable, filter, messageSupplier),
Arguments.of(sleep, Duration.ZERO, Duration.ZERO, null, delaySupplierFactory, executable, filter, messageSupplier),
Arguments.of(sleep, Duration.ZERO, Duration.ZERO, executionHandler, null, executable, filter, messageSupplier),
Arguments.of(sleep, Duration.ZERO, Duration.ZERO, executionHandler, delaySupplierFactory, null, filter, messageSupplier),
Arguments.of(sleep, Duration.ZERO, Duration.ZERO, executionHandler, delaySupplierFactory, executable, null, messageSupplier),
Arguments.of(sleep, Duration.ZERO, Duration.ZERO, executionHandler, delaySupplierFactory, executable, filter, null));
}
示例9: provideArguments
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
Sleep sleep = Thread::sleep;
PatientExecutionHandler executionHandler = new SimpleExecutionHandler();
DelaySupplierFactory delaySupplierFactory = new FixedDelaySupplierFactory(Duration.ZERO);
PatientExecutable<Boolean> executable = () -> true;
Predicate<Boolean> filter = bool -> null != bool && bool;
Supplier<String> messageSupplier = () -> "hello";
return Stream.of(Arguments.of(null, Duration.ZERO, 0, executionHandler, delaySupplierFactory, executable, filter, messageSupplier),
Arguments.of(sleep, null, 0, executionHandler, delaySupplierFactory, executable, filter, messageSupplier),
Arguments.of(sleep, Duration.ofMillis(-500), 0, executionHandler, delaySupplierFactory, executable, filter, messageSupplier),
Arguments.of(sleep, Duration.ZERO, -1, executionHandler, delaySupplierFactory, executable, filter, messageSupplier),
Arguments.of(sleep, Duration.ZERO, 0, null, delaySupplierFactory, executable, filter, messageSupplier),
Arguments.of(sleep, Duration.ZERO, 0, executionHandler, null, executable, filter, messageSupplier),
Arguments.of(sleep, Duration.ZERO, 0, executionHandler, delaySupplierFactory, null, filter, messageSupplier),
Arguments.of(sleep, Duration.ZERO, 0, executionHandler, delaySupplierFactory, executable, null, messageSupplier),
Arguments.of(sleep, Duration.ZERO, 0, executionHandler, delaySupplierFactory, executable, filter, null));
}
示例10: convertData
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
/**
* Converts the given data for the given test method and converter context.
*
* @param testMethod the original test method for which the data is converted; never {@code null}
* @param data the data to be converted; never {@code null}
* @param context the converter context to be used to do the data conversion; never {@code null}
* @return a {@link Stream} of properly converted arguments; never {@code null}
* @throws NullPointerException if and only if one of the given arguments is {@code null}
*/
protected Stream<? extends Arguments> convertData(Method testMethod, Object data, ConverterContext context) {
checkNotNull(testMethod, "'testMethod' must not be null");
checkNotNull(data, "'data' must not be null");
checkNotNull(context, "'context' must not be null");
return dataConverter.convert(data, testMethod.isVarArgs(), testMethod.getParameterTypes(), context).stream()
.map(objects -> {
Class<?>[] parameterTypes = testMethod.getParameterTypes();
for (int idx = 0; idx < objects.length; idx++) {
// TODO workaround for https://github.com/junit-team/junit5/issues/1092
Class<?> parameterType = parameterTypes[idx];
if (parameterType.isPrimitive()) {
objects[idx] = convertToBoxedTypeAsWorkaroundForNotWorkingWideningAndUnboxingConversion(
objects[idx], parameterType);
}
}
return objects;
}).map(Arguments::of);
}
示例11: provideArguments
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
@Override
public Stream<? extends Arguments> provideArguments(
ExtensionContext context) {
System.out.println("Arguments provider [2] to test "
+ context.getTestMethod().get().getName());
return Stream.of(Arguments.of("more", 3), Arguments.of("arguments", 4));
}
示例12: provideArguments
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
@Override
public Stream<? extends Arguments> provideArguments(
ExtensionContext context) {
System.out.println("Arguments provider [1] to test "
+ context.getTestMethod().get().getName());
return Stream.of(Arguments.of("hello", 1), Arguments.of("world", 2));
}
示例13: openOptionsProvider
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
static Stream<Arguments> openOptionsProvider() {
return Stream.of( //
Arguments.of(Sets.newHashSet(StandardOpenOption.READ), EnumSet.of(OpenFlags.O_RDONLY)), //
Arguments.of(Sets.newHashSet(StandardOpenOption.WRITE), EnumSet.of(OpenFlags.O_WRONLY)), //
Arguments.of(Sets.newHashSet(StandardOpenOption.READ, StandardOpenOption.WRITE), EnumSet.of(OpenFlags.O_RDWR)), //
Arguments.of(Sets.newHashSet(StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING), EnumSet.of(OpenFlags.O_WRONLY, OpenFlags.O_TRUNC)) //
);
}
示例14: argumentsProvider
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
static Stream<Arguments> argumentsProvider() {
return Stream.of( //
Arguments.of(EnumSet.noneOf(TestEnum.class), 0l), //
Arguments.of(EnumSet.of(TestEnum.ONE), 1l), //
Arguments.of(EnumSet.of(TestEnum.TWO), 2l), //
Arguments.of(EnumSet.of(TestEnum.FOUR), 4l), //
Arguments.of(EnumSet.of(TestEnum.ONE, TestEnum.TWO), 3l), //
Arguments.of(EnumSet.allOf(TestEnum.class), 7l) //
);
}
示例15: accessModeProvider
import org.junit.jupiter.params.provider.Arguments; //导入依赖的package包/类
static Stream<Arguments> accessModeProvider() {
return Stream.of( //
Arguments.of(EnumSet.noneOf(AccessMode.class), 0), //
Arguments.of(EnumSet.of(AccessMode.READ), AccessConstants.R_OK), //
Arguments.of(EnumSet.of(AccessMode.WRITE), AccessConstants.W_OK), //
Arguments.of(EnumSet.of(AccessMode.EXECUTE), AccessConstants.X_OK), //
Arguments.of(EnumSet.of(AccessMode.READ, AccessMode.WRITE), AccessConstants.R_OK | AccessConstants.W_OK), //
Arguments.of(EnumSet.allOf(AccessMode.class), AccessConstants.R_OK | AccessConstants.W_OK | AccessConstants.X_OK | AccessConstants.F_OK) //
);
}