diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/IntrospectionUtils.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/IntrospectionUtils.java index ebb2341cd..1cc9098f3 100644 --- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/IntrospectionUtils.java +++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/IntrospectionUtils.java @@ -84,6 +84,7 @@ public boolean isAnnotationPresent(Class annotation) { .isAnnotationPresent(annotation); } catch (NoSuchFieldException e) { + if(delegate.getReadMethod() == null) return false; answer = delegate.getReadMethod() .isAnnotationPresent(annotation); } diff --git a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/StarwarsSchemaBuildTest.java b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/StarwarsSchemaBuildTest.java index c5bb3738d..1295514fc 100644 --- a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/StarwarsSchemaBuildTest.java +++ b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/StarwarsSchemaBuildTest.java @@ -182,5 +182,14 @@ public void correctlyDerivesSchemaDescriptionsFromGivenEntities() { .describedAs( "Ensure that CodeList.parent has the expected description") .isEqualTo("The CodeList's parent CodeList"); } + + @Test + public void testBuildSchema(){ + //given + GraphQLSchema schema = builder.build(); + + //then + assertThat(schema).isNotNull(); + } } \ No newline at end of file diff --git a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/impl/IntrospectionUtilsTest.java b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/impl/IntrospectionUtilsTest.java index 0510e9db1..ef172d009 100644 --- a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/impl/IntrospectionUtilsTest.java +++ b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/impl/IntrospectionUtilsTest.java @@ -50,6 +50,13 @@ public void testNotTransientFields() throws Exception { assertThat(IntrospectionUtils.isTransient(entity, "info")).isFalse(); assertThat(IntrospectionUtils.isTransient(entity, "title")).isFalse(); } - - + + @Test + public void testByPassSetMethod() throws Exception { + // given + Class entity = CalculatedEntity.class; + + // then + assertThat(IntrospectionUtils.isTransient(entity,"something")).isFalse(); + } } diff --git a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/model/calculated/CalculatedEntity.java b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/model/calculated/CalculatedEntity.java index e312c7bfa..8e26134f9 100644 --- a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/model/calculated/CalculatedEntity.java +++ b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/model/calculated/CalculatedEntity.java @@ -45,4 +45,6 @@ public boolean isCustomLogic() { public String getHideFieldFunction() { return "getHideFieldFunction"; } + + public void setSomething(int a){} }