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.AbstractNotAnnotatedInSuperclassTest.SubClass; 24 import java.util.List; 25 26 public class AbstractNotAnnotatedInSuperclassTest extends AbstractEventBusTest<SubClass> { 27 abstract static class SuperClass { overriddenInSubclassNowhereAnnotated(Object o)28 public abstract void overriddenInSubclassNowhereAnnotated(Object o); 29 overriddenAndAnnotatedInSubclass(Object o)30 public abstract void overriddenAndAnnotatedInSubclass(Object o); 31 } 32 33 static class SubClass extends SuperClass { 34 final List<Object> overriddenInSubclassNowhereAnnotatedEvents = Lists.newArrayList(); 35 final List<Object> overriddenAndAnnotatedInSubclassEvents = Lists.newArrayList(); 36 37 @Override overriddenInSubclassNowhereAnnotated(Object o)38 public void overriddenInSubclassNowhereAnnotated(Object o) { 39 overriddenInSubclassNowhereAnnotatedEvents.add(o); 40 } 41 42 @Subscribe 43 @Override overriddenAndAnnotatedInSubclass(Object o)44 public void overriddenAndAnnotatedInSubclass(Object o) { 45 overriddenAndAnnotatedInSubclassEvents.add(o); 46 } 47 } 48 testOverriddenAndAnnotatedInSubclass()49 public void testOverriddenAndAnnotatedInSubclass() { 50 assertThat(getSubscriber().overriddenAndAnnotatedInSubclassEvents).contains(EVENT); 51 } 52 testOverriddenInSubclassNowhereAnnotated()53 public void testOverriddenInSubclassNowhereAnnotated() { 54 assertThat(getSubscriber().overriddenInSubclassNowhereAnnotatedEvents).isEmpty(); 55 } 56 57 @Override createSubscriber()58 SubClass createSubscriber() { 59 return new SubClass(); 60 } 61 } 62