hi stephen, in your case: #1: mockManager.addMock(dependentBean, new NamedLiteral()); #2: Assert.assertEquals(new Integer(21), BeanProvider.getContextualReference(ConsumesBeans.class).multiply());
regards, gerhard 2018-04-14 1:41 GMT+02:00 Stephen More <stephen.m...@gmail.com>: > Thanks gerhard, can you elaborate on how to accomplish #1 and #2 ? > > > > On Fri, Apr 13, 2018 at 6:34 PM, Gerhard Petracek < > gerhard.petra...@gmail.com> wrote: > > > hi stephen, > > > > #1 you need to register your mock correctly (in your case with > > NamedLiteral, since you are using @Named) > > #2 dependent-scoped beans are a bit special. if you are using a dynamic > > lookup via BeanProvider#getContextualReference in your test, the > instance > > gets created/injected after you registered your mock > > -> with that your test passes > > > > regards, > > gerhard > > > > http://www.irian.at > > > > Your JavaEE powerhouse - > > JavaEE Consulting, Development and > > Courses in English and German > > > > Professional Support for Apache > > MyFaces, DeltaSpike and OpenWebBeans > > > > > > > > 2018-04-12 22:27 GMT+02:00 Stephen More <stephen.m...@gmail.com>: > > > > > My real problem turns out to be an issue with Injecting Mock Dependent > > > Beans.... > > > > > > I made a fork of: > > > https://github.com/os890/javase-cdi-ds-project- > > template/tree/mock-demo > > > which can be found here: > > > > > > https://github.com/mores/javase-cdi-ds-project- > > > template/tree/mockingInterface > > > > > > ApplicationScopedBean == 14 > > > DependentBean == 2 > > > > > > SimpleTest == 28 = 14 x 2 ----- all is good > > > > > > Now lets mock it up.... > > > ApplicationScopedBean == 7 > > > DependentBean == 3 > > > > > > SimpleMockTest > > > I want 21 = 7 * 3 > > > > > > But I get 14 = 7 * 2 ( mocked DependentBean client is ONLY > > > SimpleMockTest ) > > > > > > > > > What is the proper way to inject and mock a Dependent Bean ? > > > > > > -Thanks > > > > > >