From bc1de44c602192e59ff66d1a5d1f1e9cdcc4a2bb Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 14 Sep 2014 23:26:43 -0400 Subject: core: Add PotentialAnnotation.from(Key) method. --- .../sangria/core/PotentialAnnotationTest.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'sangria-core/src/test') diff --git a/sangria-core/src/test/java/com/tavianator/sangria/core/PotentialAnnotationTest.java b/sangria-core/src/test/java/com/tavianator/sangria/core/PotentialAnnotationTest.java index c4ccc36..4c53ef4 100644 --- a/sangria-core/src/test/java/com/tavianator/sangria/core/PotentialAnnotationTest.java +++ b/sangria-core/src/test/java/com/tavianator/sangria/core/PotentialAnnotationTest.java @@ -36,7 +36,7 @@ import static org.junit.Assert.*; * Tests for {@link PotentialAnnotation}s. * * @author Tavian Barnes (tavianator@tavianator.com) - * @version 1.1 + * @version 1.2 * @since 1.1 */ public class PotentialAnnotationTest { @@ -63,8 +63,8 @@ public class PotentialAnnotationTest { @Test(expected = CreationException.class) public void testInvalidAnnotatedWithInstance() { - none.annotatedWith(Names.named("name")) - .annotatedWith(Names.named("name")); + none.annotatedWith(nameAnnotation) + .annotatedWith(nameAnnotation); } @Test @@ -77,6 +77,16 @@ public class PotentialAnnotationTest { equalTo(new Key(nameAnnotation) { })); } + @Test + public void testFromKey() { + assertThat(PotentialAnnotation.from(new Key() { }), + equalTo(none)); + assertThat(PotentialAnnotation.from(new Key(Simple.class) { }), + equalTo(none.annotatedWith(Simple.class))); + assertThat(PotentialAnnotation.from(new Key(nameAnnotation) { }), + equalTo(none.annotatedWith(nameAnnotation))); + } + @Test public void testVisitor() { PotentialAnnotation.Visitor visitor = new PotentialAnnotation.Visitor() { @@ -114,7 +124,7 @@ public class PotentialAnnotationTest { } /** - * Needed to avoid compilation error to to inferred type being anonymous class. + * Needed to avoid compilation error due to inferred type being anonymous class. */ private static Matcher> equalTo(Key key) { return Matchers.equalTo(key); -- cgit v1.2.3