A simple SubscriberEvent mock that records Strings. For testing fun, also includes a landmine method that Bus tests are required not to call (#methodWithoutAnnotation(String)).
| 14 | * required <em>not</em> to call ({@link #methodWithoutAnnotation(String)}). |
| 15 | */ |
| 16 | public class StringCatcher { |
| 17 | private List<String> events = new ArrayList<String>(); |
| 18 | |
| 19 | @Subscribe |
| 20 | public void hereHaveAString(String string) { |
| 21 | events.add(string); |
| 22 | } |
| 23 | |
| 24 | public void methodWithoutAnnotation(String string) { |
| 25 | Assert.fail("Event bus must not call methods without @Subscribe!"); |
| 26 | } |
| 27 | |
| 28 | public List<String> getEvents() { |
| 29 | return events; |
| 30 | } |
| 31 | } |
nothing calls this directly
no outgoing calls
no test coverage detected