Capabilities { public static boolean hasCapability(Object item, String capability) { return item != null && capability != null && Capabilities.hasCapability(item.getClass(), capability); }  static boolean hasCapability(Object item, String capability);  }
@Test public void shouldDetectAnnotationsOnBase() { AlphaClass base = new AlphaClass(); assertTrue("should find alpha cap on AlphaClass", Capabilities.hasCapability(base, "alpha")); assertFalse("should not find bravo cap on AlphaClass", Capabilities.hasCapability(base, "bravo")); assertFalse("should not find blahblah cap on AlphaClass", Capabilities.hasCapability(base, "blahblah")); }
@Test public void shouldDetectAnnotationsOnDerivedClasses() { BravoClass bravo = new BravoClass(); CharlieClass charlie = new CharlieClass(); assertTrue("should find bravo cap on BravoClass", Capabilities.hasCapability(bravo, "bravo")); assertFalse("should not find blahblah cap on BravoClass", Capabilities.hasCapability(bravo, "blahblah")); assertTrue("should find charlie cap on CharlieClass", Capabilities.hasCapability(charlie, "charlie")); assertFalse("should not find blahblah cap on CharlieClass", Capabilities.hasCapability(charlie, "blahblah")); }
@Test public void shouldInheritCapabilities() { BravoClass bravo = new BravoClass(); CharlieClass charlie = new CharlieClass(); assertTrue("should find alpha cap on BravoClass", Capabilities.hasCapability(bravo, "alpha")); assertTrue("should find alpha cap on CharlieClass", Capabilities.hasCapability(charlie, "alpha")); }
@Test public void shouldNotFailWhenAnnotationMissing() { Capabilities.hasCapability(new BaseClass(), "anything"); }