hosea commented on PR #1310:
URL: https://github.com/apache/wicket/pull/1310#issuecomment-3581424582
Hi @martin-g ,
I do not agree. These classes were designed only for being used inside
AnnotProxyFieldValueFactoryTest.
A simple class, just to define a type without any properties and methods for
exactly on testclass like
static class Bean{
}
should always be a inner class of the testcalss.
And have a look at the classes SpringBeanInjectable and the (same-structure)
JakartaInjectInjectable:
public static class SpringBeanInjectable {
private Bean nobean;
@SpringBean
private Bean beanByClass;
@SpringBean(name = "somebean")
private Bean beanByName;
@SpringBean(required = false)
private Bean optional;
@Override
public String toString() {
return "SpringBeanInjectable";
}
}
It is exactly build for AnnotProxyFieldValueFactoryTest. From
AnnotProxyFieldValueFactoryTest:
obj.getClass().getDeclaredField("nobean");
obj.getClass().getDeclaredField("beanByClass");
obj.getClass().getDeclaredField("beanByName");
springBeanInjectable.getClass().getDeclaredField("optional");
So this classes should also be inner classes in my opinion.
The Marker-Interface Injectable and the testclasses
JakartaInjectAnnotProxyFieldValueFactoryTest and
SpringBeanAnnotProxyFieldValueFactoryTest could be removed, because I
integrated using @ParameterizedTest (test Jakarta-Inject and Spring-Bean-Inject
with same @ParameterizedTest)
Just not: The real diff in implementation ist not very much. This is just
adding one functionality and a small refactoring:
1. move the "isPrimary"-loop out in a a loop with a Predicate
2. move the "isFieldname"-Rule out in a method
3. Add implementation for "isDefaultCandidate"
But the test is massivley improved:
I replaced the 3 small and not very detailed methods "testFactory",
"testCache" and "testFailsIfBeanWithIdIsNotFound" with a bunch of methods
testing a lot a scenarios:
- shouldCreateProxyForBeanName
- shouldThrowExceptionIfBeanNameNotFound
- shouldCreateProxyForClass
- shouldThrowException_beanNameAmbiguous
- shouldCreateProxyForUniquePrimary_beanNameAmbiguous
- shouldCreateProxyForUniqueDefaultCandidate_beanNameAmbiguous
- shouldCreateProxyForFieldname_beanNameAmbiguous
- shouldIgnoreUnannotatedFields
- required
- optional
- testCacheForClass
- testCacheForBeanName
Kind regards
Hans
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]