Skip to content

Commit

Permalink
auto-detect inject method parameter types
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-qnz authored and manovotn committed Mar 4, 2024
1 parent b2c1c6f commit ae37349
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static void scanForRequiredBeanClasses(List<Class<?>> testClasses, Weld weld, bo
.forEach(cls -> addClassesToProcess(classesToProcess, cls));

AnnotationSupport.findAnnotatedMethods(currClass, Inject.class, HierarchyTraversalMode.BOTTOM_UP).stream()
.map(Method::getReturnType)
.flatMap(method -> getExecutableParameterTypes(method, explicitInjection).stream())
.forEach(cls -> addClassesToProcess(classesToProcess, cls));

findFirstAnnotatedConstructor(currClass, Inject.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.jboss.weld.junit5.auto;

import static org.junit.jupiter.api.Assertions.assertNotNull;

import jakarta.enterprise.context.Dependent;
import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;

@EnableAutoWeld
class InjectMethodParamTest {

@Dependent
static class Foo {
}

private Foo foo;

@Inject
private void setFoo(Foo foo) {
this.foo = foo;
}

@Test
void testInjectMethodParametersAreAddedToContainerWithNoConfiguration() {
assertNotNull(foo);
}

}

0 comments on commit ae37349

Please sign in to comment.