summaryrefslogtreecommitdiffstats
path: root/sangria-core/src/test
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-09-14 23:26:43 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-09-14 23:26:43 -0400
commitbc1de44c602192e59ff66d1a5d1f1e9cdcc4a2bb (patch)
tree42e6728cb4d92ccd61f552b24ed7515c319549b9 /sangria-core/src/test
parentb5bc672aa1367a34e2939584cdf35964d369cac5 (diff)
downloadsangria-bc1de44c602192e59ff66d1a5d1f1e9cdcc4a2bb.tar.xz
core: Add PotentialAnnotation.from(Key<?>) method.
Diffstat (limited to 'sangria-core/src/test')
-rw-r--r--sangria-core/src/test/java/com/tavianator/sangria/core/PotentialAnnotationTest.java18
1 files changed, 14 insertions, 4 deletions
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
@@ -78,6 +78,16 @@ public class PotentialAnnotationTest {
}
@Test
+ public void testFromKey() {
+ assertThat(PotentialAnnotation.from(new Key<String>() { }),
+ equalTo(none));
+ assertThat(PotentialAnnotation.from(new Key<String>(Simple.class) { }),
+ equalTo(none.annotatedWith(Simple.class)));
+ assertThat(PotentialAnnotation.from(new Key<String>(nameAnnotation) { }),
+ equalTo(none.annotatedWith(nameAnnotation)));
+ }
+
+ @Test
public void testVisitor() {
PotentialAnnotation.Visitor<String> visitor = new PotentialAnnotation.Visitor<String>() {
@Override
@@ -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 <T> Matcher<Key<T>> equalTo(Key<T> key) {
return Matchers.equalTo(key);