[cdi-dev] Expected value of getType() for the injection point of an Instance object

Matej Novotny manovotn at redhat.com
Mon Sep 11 07:56:30 EDT 2017


Hi John,

not sure I grasp your question, but the test line Martin pointed you to:

> assertEquals(bar.getFoo().getInjectionPoint().getType(), Foo.class);

makes it IMO pretty clear.

In case of @Inject Instance<Foo>, the expected result in the test is `Foo.class`.
You need to make use of the InjectionPoint in order to be able to retrieve this information.
There is no way to directly call getType() on Instance - there is no such method. 
However, you can make use of the InjectionPoint; in this case the IP is Instance<Foo>.

Hope this is what you were after.

Matej

----- Original Message -----
> From: "John Ament" <john.ament at spartasystems.com>
> To: "cdi-dev" <cdi-dev at lists.jboss.org>
> Sent: Monday, September 11, 2017 1:25:27 PM
> Subject: Re: [cdi-dev] Expected value of getType() for the injection point of an Instance object
> 
> 
> 
> Martin,
> 
> 
> 
> 
> Sorry, but I'm looking for a concrete answer. The tests you point to never
> test when the injection point is an Instance<> or Provider<>, e.g. the CDI
> built in beans.
> 
> 
> 
> 
> What I'm looking for would be something like "It should be a
> ParameterizedType impl that represents Instance<Foo>" or "It should be the
> class Foo.class" or something else along those lines.
> 
> 
> 
> 
> Thanks,
> 
> 
> 
> 
> John
> 
> 
> 
> 
> 
> 
> From: Martin Kouba <mkouba at redhat.com>
> Sent: Monday, September 11, 2017 7:00 AM
> To: John Ament; cdi-dev
> Subject: Re: [cdi-dev] Expected value of getType() for the injection point of
> an Instance object
> Hi John,
> 
> I believe it should be the required type of the injected Instance (which
> is the type parameter specified at the injection point - defined in
> "5.6.1. The Instance interface" and "5.5.7. Injection point metadata")
> unless you modify the type using Instance.select().
> 
> getType() is tested in:
> https://github.com/cdi-spec/cdi-tck/blob/master/impl/src/main/java/org/jboss/cdi/tck/tests/lookup/injectionpoint/dynamic/DynamicInjectionPointTest.java#L74
> 
> and line 75
> 
> getQualifiers():
> https://github.com/cdi-spec/cdi-tck/blob/master/impl/src/main/java/org/jboss/cdi/tck/tests/lookup/injectionpoint/dynamic/DynamicInjectionPointTest.java#L86
> 
> and line 87
> 
> Martin
> 
> Dne 11.9.2017 v 12:40 John Ament napsal(a):
> > Hi,
> > 
> > 
> > I found a small issue within OWB. The closest found TCK test (found by
> > Romain) is
> > https://github.com/cdi-spec/cdi-tck/blob/master/impl/src/main/java/org/jboss/cdi/tck/tests/lookup/injectionpoint/dynamic/DynamicInjectionPointTest.java#L99
> > which
> 
> > tests the Instance type, but not the value of InjectionPoint.getType().
> > What should be the return value of getType() here?
> > 
> > 
> > John
> > 
> > 
> > ------------------------------------------------------------------------
> > NOTICE: This e-mail message and any attachments may contain
> > confidential, proprietary, and/or privileged information which should be
> > treated accordingly. If you are not the intended recipient, please
> > notify the sender immediately by return e-mail, delete this message, and
> > destroy all physical and electronic copies. Thank you.
> > 
> > 
> > _______________________________________________
> > cdi-dev mailing list
> > cdi-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/cdi-dev
> 
> > 
> > Note that for all code provided on this list, the provider licenses the
> > code under the Apache License, Version 2 (
> > http://www.apache.org/licenses/LICENSE-2.0.html ). For all other ideas
> > provided on this list, the provider waives all patent and other
> > intellectual property rights inherent in such information.
> 
> > 
> 
> --
> Martin Kouba
> Senior Software Engineer
> Red Hat, Czech Republic
> 
> NOTICE: This e-mail message and any attachments may contain confidential,
> proprietary, and/or privileged information which should be treated
> accordingly. If you are not the intended recipient, please notify the sender
> immediately by return e-mail, delete this message, and destroy all physical
> and electronic copies. Thank you.
> 
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
> 
> Note that for all code provided on this list, the provider licenses the code
> under the Apache License, Version 2
> (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
> provided on this list, the provider waives all patent and other intellectual
> property rights inherent in such information.


More information about the cdi-dev mailing list