@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"); }
@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); }
@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); }
@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()); }
@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()); }
@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.")); }