• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 The Guava Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.common.eventbus.outside;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import com.google.common.collect.Lists;
22 import com.google.common.eventbus.Subscribe;
23 import com.google.common.eventbus.outside.NeitherAbstractNorAnnotatedInSuperclassTest.SubClass;
24 import java.util.List;
25 
26 public class NeitherAbstractNorAnnotatedInSuperclassTest extends AbstractEventBusTest<SubClass> {
27   static class SuperClass {
28     final List<Object> neitherOverriddenNorAnnotatedEvents = Lists.newArrayList();
29     final List<Object> overriddenInSubclassNowhereAnnotatedEvents = Lists.newArrayList();
30     final List<Object> overriddenAndAnnotatedInSubclassEvents = Lists.newArrayList();
31 
neitherOverriddenNorAnnotated(Object o)32     public void neitherOverriddenNorAnnotated(Object o) {
33       neitherOverriddenNorAnnotatedEvents.add(o);
34     }
35 
overriddenInSubclassNowhereAnnotated(Object o)36     public void overriddenInSubclassNowhereAnnotated(Object o) {
37       overriddenInSubclassNowhereAnnotatedEvents.add(o);
38     }
39 
overriddenAndAnnotatedInSubclass(Object o)40     public void overriddenAndAnnotatedInSubclass(Object o) {
41       overriddenAndAnnotatedInSubclassEvents.add(o);
42     }
43   }
44 
45   static class SubClass extends SuperClass {
46     @Override
overriddenInSubclassNowhereAnnotated(Object o)47     public void overriddenInSubclassNowhereAnnotated(Object o) {
48       super.overriddenInSubclassNowhereAnnotated(o);
49     }
50 
51     @Subscribe
52     @Override
overriddenAndAnnotatedInSubclass(Object o)53     public void overriddenAndAnnotatedInSubclass(Object o) {
54       super.overriddenAndAnnotatedInSubclass(o);
55     }
56   }
57 
testNeitherOverriddenNorAnnotated()58   public void testNeitherOverriddenNorAnnotated() {
59     assertThat(getSubscriber().neitherOverriddenNorAnnotatedEvents).isEmpty();
60   }
61 
testOverriddenInSubclassNowhereAnnotated()62   public void testOverriddenInSubclassNowhereAnnotated() {
63     assertThat(getSubscriber().overriddenInSubclassNowhereAnnotatedEvents).isEmpty();
64   }
65 
testOverriddenAndAnnotatedInSubclass()66   public void testOverriddenAndAnnotatedInSubclass() {
67     assertThat(getSubscriber().overriddenAndAnnotatedInSubclassEvents).contains(EVENT);
68   }
69 
70   @Override
createSubscriber()71   SubClass createSubscriber() {
72     return new SubClass();
73   }
74 }
75