@Before
 public void setUp() throws Exception {
   MockitoAnnotations.initMocks(this);
   subject = new GlobalAlternativeSelector();
   subject.loadApplicationAlternatives(bbd);
   ccl = Thread.currentThread().getContextClassLoader();
   when(pat.getAnnotatedType()).thenReturn(at);
 }
 @Test
 public void testWatchAlternatives_noGlobalAlternative() throws Exception {
   // prepare, no global alternative
   when(at.isAnnotationPresent(Priority.class)).thenReturn(false);
   // act
   subject.watchAlternatives(pat);
   // assert, not vetoed
   verify(pat, times(0)).veto();
 }
 @Test
 public void testWatchAlternatives_disabledAlternativeClass() throws Exception {
   // prepare, global alternative
   when(at.isAnnotationPresent(Priority.class)).thenReturn(true);
   when(at.getJavaClass()).thenReturn(DisabledAlternativeClass.class);
   // act
   subject.watchAlternatives(pat);
   // assert, vetoed
   verify(pat).veto();
 }
 @Test
 public void testWatchAlternatives_unstereotypedField_veto() throws Exception {
   // prepare, global alternative
   when(at.isAnnotationPresent(Priority.class)).thenReturn(true);
   when(at.isAnnotationPresent(TestStereotype.class)).thenReturn(false);
   when(at.getJavaClass()).thenReturn(UnstereotypedField.class);
   // act
   subject.watchAlternatives(pat);
   // assert, vetoed
   verify(pat).veto();
 }
 @Test
 public void testWatchAlternatives_stereotypedClass_enable() throws Exception {
   // prepare, global alternative
   when(at.isAnnotationPresent(Priority.class)).thenReturn(true);
   when(at.isAnnotationPresent(TestStereotype.class)).thenReturn(true);
   when(at.getJavaClass()).thenReturn(StereotypedClass.class);
   // act
   subject.watchAlternatives(pat);
   // assert, not vetoed
   verify(pat, times(0)).veto();
 }
 @Test
 public void testWatchAlternatives_stereotypedField_enable() throws Exception {
   // prepare, global alternative
   when(at.isAnnotationPresent(Priority.class)).thenReturn(true);
   final Set<Annotated> annotated = asAnnotatedSet(StereotypedField.class.getDeclaredFields());
   when(at.getFields()).thenReturn(annotated);
   when(at.getJavaClass()).thenReturn(StereotypedField.class);
   // act
   subject.watchAlternatives(pat);
   // assert, not vetoed
   verify(pat, times(0)).veto();
 }
 @Test(expected = IllegalStateException.class)
 public void testLoadApplicationAlternatives_CCL_noBeansXml() throws Exception {
   final ClassLoader cl = mock(ClassLoader.class);
   Thread.currentThread().setContextClassLoader(cl);
   subject.loadApplicationAlternatives(bbd);
 }
 @Test
 public void testAfterTypeDiscovery() throws Exception {
   // no assertion, the method should just not throw an exception as it performs logging only
   subject.afterTypeDiscovery(atd);
 }