Skip to content

Commit 209fe38

Browse files
committed
add tests
1 parent eeb3f9f commit 209fe38

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

src/test/java/graphql/annotations/processor/retrievers/fieldBuilders/DeprecateBuilderTest.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import graphql.annotations.annotationTypes.GraphQLDeprecate;
1818
import org.testng.annotations.Test;
1919

20+
import java.lang.reflect.Field;
2021
import java.lang.reflect.Method;
2122

2223
import static org.testng.AssertJUnit.assertEquals;
@@ -43,6 +44,14 @@ public int testMethod4() {
4344
return 1;
4445
}
4546

47+
@GraphQLDeprecate("test field deprecated")
48+
public String testField;
49+
50+
@GraphQLDeprecate
51+
public String testField1;
52+
53+
public String testField2;
54+
4655
@Test
4756
public void build_graphQLDeprecateAnnotationExistsWithValue_returnAnnotationValue() throws NoSuchMethodException {
4857
// arrange
@@ -56,7 +65,6 @@ public void build_graphQLDeprecateAnnotationExistsWithValue_returnAnnotationValu
5665
assertEquals(deprecate, "test deprecated");
5766
}
5867

59-
6068
@Test
6169
public void build_graphQLDeprecateAnnotationExistsWithNoValue_returnEmptyString() throws NoSuchMethodException {
6270
// arrange
@@ -95,4 +103,43 @@ public void build_noDeprecatedAnnotation_returnNull() throws NoSuchMethodExcepti
95103
// assert
96104
assertNull(deprecate);
97105
}
106+
107+
@Test
108+
public void build_deprecatedAnnotationExistsOnField_returnNull() throws NoSuchFieldException {
109+
// arrange
110+
Field field = getClass().getField("testField2");
111+
DeprecateBuilder deprecateBuilder = new DeprecateBuilder(field);
112+
113+
// act
114+
String deprecate = deprecateBuilder.build();
115+
116+
// assert
117+
assertNull(deprecate);
118+
}
119+
120+
@Test
121+
public void build_graphQLDeprecateAnnotationExistsOnFieldWithNoValue_returnEmptyString() throws NoSuchFieldException {
122+
// arrange
123+
Field field = getClass().getField("testField1");
124+
DeprecateBuilder deprecateBuilder = new DeprecateBuilder(field);
125+
126+
// act
127+
String deprecate = deprecateBuilder.build();
128+
129+
// assert
130+
assertEquals(deprecate, "Deprecated");
131+
}
132+
133+
@Test
134+
public void build_graphQLDeprecateAnnotationExistsOnFieldWithValue_returnAnnotationValue() throws NoSuchFieldException {
135+
// arrange
136+
Field field = getClass().getField("testField");
137+
DeprecateBuilder deprecateBuilder = new DeprecateBuilder(field);
138+
139+
// act
140+
String deprecate = deprecateBuilder.build();
141+
142+
// assert
143+
assertEquals(deprecate, "test field deprecated");
144+
}
98145
}

0 commit comments

Comments
 (0)