下面列出了org.junit.jupiter.params.provider.Arguments#of ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Build the tests argument.
*
* @return test arg
*/
Object build() {
return Arguments.of(
name,
descriptor,
run,
series
);
}
private static <T> Arguments requestDataTest(
final String name,
final Function<ValidatorApiChannel, SafeFuture<Optional<T>>> method,
final String counterName,
final T presentValue) {
return Arguments.of(name, method, counterName, presentValue);
}
private static Arguments extractArguments(
Map<String, String> entry, NetworkType networkType, String addressField) {
String address = entry.get(addressField);
if (address == null) {
return null;
}
return Arguments.of(networkType, entry.get("publicKey"), address);
}
private static Arguments extractArguments(
Map<String, String> entry, NetworkType networkType,
String addressField, String mosaicField) {
String address = entry.get(addressField);
String mosaicId = entry.get(mosaicField);
return Arguments.of(networkType, entry.get("mosaicNonce"), address, mosaicId);
}
private static Arguments createClassNode2()
{
ClassNode node = new ClassNode();
node.moveTo(new Point(10,20));
return Arguments.of(node,
new Rectangle(10, 20, 100, 60)); // Default width and height, translated
}
private static Arguments createClassNode3()
{
ClassNode node = new ClassNode();
node.setName(node.getName() + "NAME");
return Arguments.of(node,
new Rectangle(0, 0, 100, 60)); // Default width and height
}
private static Arguments createClassNode4()
{
ClassNode node = new ClassNode();
node.setName(node.getName() + "NAME");
return Arguments.of(node,
new Rectangle(0, 0, 100, 60)); // Default width and height
}
private static Arguments createClassNode5()
{
ClassNode node = new ClassNode();
node.setName("NAME1\nNAME2\nNAME3\nNAME4");
return Arguments.of(node,
new Rectangle(0, 0, 100, osDependent(70, 65, 65))); // Default width and additional height
}
private static Arguments createClassNode6()
{
ClassNode node = new ClassNode();
node.setMethods("METHODS");
return Arguments.of(node,
new Rectangle(0, 0, 100, 60)); // Default width and height
}
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) throws Exception {
final Arguments completeAsync = Arguments.of(
(BiConsumer<CompletableFuture<?>, AtomicBoolean>) (future, called) -> {
future.completeAsync(() -> {
called.set(true);
return null;
}, MoreExecutors.directExecutor()).exceptionally(cause -> {
called.set(true);
return null;
});
});
return Stream.concat(super.provideArguments(context), Stream.of(completeAsync));
}
public Arguments build() {
Preconditions.checkState(description.isPresent());
Preconditions.checkState(field.isPresent());
Preconditions.checkState(valueToMatch.isPresent());
return Arguments.of(description.get(), field.get(), mimeMessageBuilder, valueToMatch.get());
}
private static Arguments getTestCaseArguments(Map testcase, String idAttributeName) {
List<Map<String, Object>> expected = (List<Map<String, Object>>) testcase.get("contains");
return Arguments.of(
testcase.get("id"),
testcase.get("attribute"),
getRsqlOperator((String) testcase.get("operator")),
testcase.get("value"),
testcase.get("count"),
expected.stream().map(it -> it.get(idAttributeName)).collect(toList()),
testcase.get("comment"));
}
public static Stream<Arguments> params() {
Arguments[] product = new Arguments[REAL_DATA_SETS.length * BITMAP_TYPES.length * BITMAP_IMMUTABILITY.length];
int i = 0;
for (String ds : REAL_DATA_SETS) {
for (String type : BITMAP_TYPES) {
for (boolean mutability : BITMAP_IMMUTABILITY) {
product[i++] = Arguments.of(ds, type, mutability);
}
}
}
return Arrays.stream(product);
}
private static Arguments funcSelectorArgs(String hash, String funcName, String... paramTypes) {
return Arguments.of(hash, funcName, paramTypes);
}
private static Arguments noResponseTest(
final String name, final Consumer<ValidatorApiChannel> method, final String counterName) {
return Arguments.of(name, method, counterName);
}
private static Arguments createClassNode1()
{
return Arguments.of(new ClassNode(),
new Rectangle(0,0, 100, 60)); // Default width and height
}
private static <M extends MonetaryAmount> Arguments of(final Class<M> type, final Configurer configurer) {
return Arguments.of(type, configurer);
}
/**
* Build the tests argument.
*
* @return test arg
*/
Object build() {
return Arguments.of(testName, expectedResult, qualityGateStatus, jobResult);
}