Skip to content

Commit fb45d23

Browse files
chanhengseang3igdianov
authored andcommitted
#102 fix NullPointerException when searching for Transient annotation (#106)
* #102 fix NullPointerException when searching for Transient annotation properties * #102 add setSth() method to test schema build * #102 Change test
1 parent 2d2f5d1 commit fb45d23

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/IntrospectionUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public boolean isAnnotationPresent(Class<? extends Annotation> annotation) {
8484
.isAnnotationPresent(annotation);
8585

8686
} catch (NoSuchFieldException e) {
87+
if(delegate.getReadMethod() == null) return false;
8788
answer = delegate.getReadMethod()
8889
.isAnnotationPresent(annotation);
8990
}

graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/StarwarsSchemaBuildTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,14 @@ public void correctlyDerivesSchemaDescriptionsFromGivenEntities() {
182182
.describedAs( "Ensure that CodeList.parent has the expected description")
183183
.isEqualTo("The CodeList's parent CodeList");
184184
}
185+
186+
@Test
187+
public void testBuildSchema(){
188+
//given
189+
GraphQLSchema schema = builder.build();
190+
191+
//then
192+
assertThat(schema).isNotNull();
193+
}
185194

186195
}

graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/impl/IntrospectionUtilsTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ public void testNotTransientFields() throws Exception {
5050
assertThat(IntrospectionUtils.isTransient(entity, "info")).isFalse();
5151
assertThat(IntrospectionUtils.isTransient(entity, "title")).isFalse();
5252
}
53-
54-
53+
54+
@Test
55+
public void testByPassSetMethod() throws Exception {
56+
// given
57+
Class<CalculatedEntity> entity = CalculatedEntity.class;
58+
59+
// then
60+
assertThat(IntrospectionUtils.isTransient(entity,"something")).isFalse();
61+
}
5562
}

graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/model/calculated/CalculatedEntity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ public boolean isCustomLogic() {
4545
public String getHideFieldFunction() {
4646
return "getHideFieldFunction";
4747
}
48+
49+
public void setSomething(int a){}
4850
}

0 commit comments

Comments
 (0)