Java 类org.junit.platform.commons.support.ReflectionSupport 实例源码

项目:junit-dataprovider    文件:NamedArgumentPlaceholderTest.java   
@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");
}
项目:junit5-conditional-execution-extensions    文件:DisabledWhenExtension.java   
@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);
}
项目:junit5-conditional-execution-extensions    文件:EnabledWhenExtension.java   
@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);
}
项目:junit-dataprovider    文件:CustomConverterDataProviderArgumentProvider.java   
@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());
}
项目:junit-dataprovider    文件:DataProviderTestProvider.java   
@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());
}
项目:junit-dataprovider    文件:CustomResolverUseDataProviderArgumentProvider.java   
@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());
}
项目:junit-dataprovider    文件:UseDataProviderArgumentProvider.java   
@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());
}
项目:junit-dataprovider    文件:StringDataProviderArgumentProvider.java   
@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());
}
项目:junit-dataprovider    文件:CustomConverterDataProviderExtension.java   
@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());
}
项目:junit-dataprovider    文件:CustomPlaceholderDataProviderExtension.java   
@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());
}
项目:junit-dataprovider    文件:DataProviderTestExtension.java   
@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());
}
项目:junit-dataprovider    文件:CustomResolverDataProviderTestExtension.java   
@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());
}
项目:junit-dataprovider    文件:UseDataProviderExtension.java   
@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());
}
项目:junit-dataprovider    文件:DataProviderExtension.java   
@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());
}
项目:junit-dataprovider    文件:NamedArgumentPlaceholderTest.java   
@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."));
}