Skip to content

Instantly share code, notes, and snippets.

View Kotlin-Native's full-sized avatar

Pierre Liebsch Kotlin-Native

View GitHub Profile
// The Annotation
@InterceptorBinding
@Retention(RetentionPolicy.RUNTIME)
@Target({FIELD, METHOD, PARAMETER, TYPE})
@Qualifier
public @interface RunInRequestScope {
}
// The Interceptor for the annotation
@RequestScoped
public class MyCdiBean {
private boolean flag = true;
@Inject
private MyService service;
public void doSomething() {
if (!flag) {
service.callMethod();
List list = Arrays.asList("foo", "bar");
assertThat(list, is(not(empty())));
assertThat(list.get(0), is("foo"));
assertThat(list, hasItem("bar"));
assertThat(list, hasItem("baz"));
assertThat(myObject.getBar(), is(nullValue()));
assertThat(myObject.isBar(), is(true));
assertThat(myObject, hasProperty("bar", is(true)));
assertThat(myObject).isBar();
assertThatNot(myObject).isBar();
import static org.junit.Assert.assertEquals;
import java.lang.reflect.Method;
import org.hamcrest.Matcher;
import org.hamcrest.MatcherAssert;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.InvocationHandler;