本文整理匯總了Java中org.junit.platform.commons.support.ReflectionSupport類的典型用法代碼示例。如果您正苦於以下問題:Java ReflectionSupport類的具體用法?Java ReflectionSupport怎麽用?Java ReflectionSupport使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ReflectionSupport類屬於org.junit.platform.commons.support包,在下文中一共展示了ReflectionSupport類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testProcessToDoShouldReplaceSingleValueRangeSubscriptArgumentPlaceholderUsingOnlyNegativeIndices
import org.junit.platform.commons.support.ReflectionSupport; //導入依賴的package包/類
@Test
void testProcessToDoShouldReplaceSingleValueRangeSubscriptArgumentPlaceholderUsingOnlyNegativeIndices() {
// Given:
final Method testMethod = ReflectionSupport
.findMethod(Assertions.class, "assertTrue", new Class<?>[] { boolean.class })
.orElseThrow(() -> new IllegalStateException("Could not find method"));
final List<Object> arguments = list('x');
ReplacementData data = ReplacementData.of(testMethod, 0, arguments);
// When:
String result = underTest.process(data, "%na[0]");
// Then:
assertThat(result).isEqualTo("arg0=x");
assertThat(getTestCapturedLog()).containsPattern(
"WARNING: Parameter names on method '.*' are not available. To store formal parameter names, compile the source file with the '-parameters' option");
}
示例2: evaluateExecutionCondition
import org.junit.platform.commons.support.ReflectionSupport; //導入依賴的package包/類
@Override
public ConditionEvaluationResult evaluateExecutionCondition(final ExtensionContext context) {
return context.getElement()
.flatMap(annotatedElement -> findAnnotation(annotatedElement, DisabledWhen.class))
.map(DisabledWhen::value)
.map(supplierClass -> ReflectionSupport.newInstance(supplierClass))
.map(Supplier::get)
.map(result -> Objects.requireNonNull(result, "Supplier result must not be null"))
.map(shouldDisable -> shouldDisable
? disabled(DisabledWhen.class + " evaluated to true")
: enabled(DisabledWhen.class + " evaluated to false"))
.orElse(DEFAULT);
}
示例3: evaluateExecutionCondition
import org.junit.platform.commons.support.ReflectionSupport; //導入依賴的package包/類
@Override
public ConditionEvaluationResult evaluateExecutionCondition(final ExtensionContext context) {
return context.getElement()
.flatMap(annotatedElement -> findAnnotation(annotatedElement, EnabledWhen.class))
.map(EnabledWhen::value)
.map(supplierClass -> ReflectionSupport.newInstance(supplierClass))
.map(Supplier::get)
.map(result -> Objects.requireNonNull(result, "Result must not be null"))
.map(shouldEnable -> shouldEnable
? enabled(EnabledWhen.class + " evaluated to false")
: disabled(EnabledWhen.class + " evaluated to true"))
.orElse(DEFAULT);
}
示例4: getConverterContext
import org.junit.platform.commons.support.ReflectionSupport; //導入依賴的package包/類
@Override
protected ConverterContext getConverterContext(CustomConverterDataProvider annotation) {
return new ConverterContext(ReflectionSupport.newInstance(annotation.objectArrayConverter()),
ReflectionSupport.newInstance(annotation.singleArgConverter()),
ReflectionSupport.newInstance(annotation.stringConverter()), annotation.splitBy(),
annotation.convertNulls(), annotation.trimValues(), annotation.ignoreEnumCase());
}
示例5: getConverterContext
import org.junit.platform.commons.support.ReflectionSupport; //導入依賴的package包/類
@Override
protected ConverterContext getConverterContext(DataProvider dataProvider) {
return new ConverterContext(ReflectionSupport.newInstance(dataProvider.objectArrayConverter()),
ReflectionSupport.newInstance(dataProvider.singleArgConverter()),
ReflectionSupport.newInstance(dataProvider.stringConverter()), dataProvider.splitBy(),
dataProvider.convertNulls(), dataProvider.trimValues(), dataProvider.ignoreEnumCase());
}
示例6: setup
import org.junit.platform.commons.support.ReflectionSupport; //導入依賴的package包/類
@BeforeEach
void setup() {
tenParamMethod = ReflectionSupport
.findMethod(getClass(), "tenParamMethod",
new Class<?>[] { char.class, int.class, long.class, double.class, String.class, char.class,
int.class, long.class, double.class, float.class })
.orElseThrow(
() -> new IllegalStateException("Could not find method having ten parameters for testing."));
}