@Stereotype @Alternative @Retention(value=RUNTIME) @Target(value={FIELD,METHOD}) public @interface OverrideBean
@OverrideBean is, strictly speaking, an always enabled alternative stereotype.
It is typically used along with @javax.enterprise.inject.Produces.
It "overrides a bean" that may otherwise be included in the container by providing a new bean (via producer) and
selecting it.
Here is how such a usage can look like:
@EnableAutoWeld
@AddPackages(Foo.class) // this brings in the *original* Foo impl you want to override
class OverrideFooTest {
@Produces
@OverrideBean
Foo fakeFoo = new Foo("non-baz");
@Test
void test(Foo myFoo) {
assertNotNull(myFoo);
assertEquals(myFoo.getBar(), "non-baz");
}
}
Copyright © 2018. All rights reserved.