Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Generic Junit Injection #462

Merged
merged 4 commits into from
Nov 28, 2023
Merged

Fix Generic Junit Injection #462

merged 4 commits into from
Nov 28, 2023

Conversation

SentryMan
Copy link
Collaborator

  • Fix situations where generic types were not being properly injected into certain types of test
  • Adds new default methods to make retrieving a generic bean more intuitive

resolves #461

Copy link
Contributor

@rbygrave rbygrave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still reviewing ...

@Test
void test() {
assertThat(intymcintface).isNotNull();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert on stringy too

@@ -49,7 +50,7 @@ static class HelloBean {

static class MyPlugin implements Plugin {

public boolean forType(Class<?> type) {
public boolean forType(Type type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation, format only

* Return a single bean given its type and generic components.
*
* <pre>{@code
* Map<String, CoffeeMaker> coffeeMaker = beanScope.get(Map.class, String.class, CoffeeMaker.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like extra functionality and not part of the bug fix?

Improve this example

* @throws java.util.NoSuchElementException When no matching bean is found
*/
default <T> T get(@Nullable String name, Type type, Type... types) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace formatting
This looks like extra functionality unrelated to the bug fix.

@@ -196,6 +197,12 @@ private <D> BeanScopeBuilder.ForTesting spy(Class<D> type, @Nullable String name
return this;
}

private <D> BeanScopeBuilder.ForTesting spy(
Type type, @Nullable String name, @Nullable Consumer<D> consumer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

private final Type rawType;
public final Type[] typeArguments;

public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove public modifier

}

/** Returns an array type whose elements are all instances of {@code componentType}. */
public static GenericArrayType arrayOf(Type elementType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove public modifier

* Returns a new parameterized type, applying {@code typeArguments} to {@code rawType}. Use this
* method if {@code rawType} is not enclosed in another type.
*/
public static ParameterizedType newParameterizedType(Type rawType, Type... typeArguments) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove public modifier


} else if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

return rawType(((WildcardType) type).getUpperBounds()[0]);

} else {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

@rbygrave rbygrave merged commit 6a91cfc into avaje:master Nov 28, 2023
4 checks passed
@rbygrave rbygrave added this to the 9.10 milestone Nov 28, 2023
@rbygrave rbygrave added the bug Something isn't working label Nov 28, 2023
@SentryMan SentryMan deleted the generic branch November 28, 2023 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Injection of parameterized types doesn't work as expected
2 participants