Skip to content

Commit 93d2b85

Browse files
committed
fix: add unit test
1 parent 0c047e7 commit 93d2b85

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

graphql-jpa-query-example-simple/src/main/resources/application.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ spring:
55
open-in-view: false
66
h2:
77
console.enabled: true
8+
datasource:
9+
url: jdbc:h2:mem:starwars
810

911
graphql:
1012
jpa:

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
3939
import com.introproventures.graphql.jpa.query.schema.model.starwars.Character;
4040
import com.introproventures.graphql.jpa.query.schema.model.starwars.Droid;
41+
import com.introproventures.graphql.jpa.query.schema.model.starwars.Human;
4142

4243
@SpringBootTest
4344
@Transactional
@@ -2118,4 +2119,55 @@ public void queryWithInLineExplicitOptionalFalseForSingularAttributeAndWhereSear
21182119
assertThat(result.toString()).isEqualTo(expected);
21192120
}
21202121

2122+
// https://github.com/introproventures/graphql-jpa-query/issues/273
2123+
@Test
2124+
public void testGH273() {
2125+
2126+
//given:
2127+
String query = "{" +
2128+
" Humans(where: {id: {EQ: \"1000\"}}) {" +
2129+
" select {" +
2130+
" id" +
2131+
" name" +
2132+
" }" +
2133+
" }" +
2134+
" " +
2135+
" Human(id: \"1000\" ) {" +
2136+
" id" +
2137+
" name" +
2138+
" }" +
2139+
" " +
2140+
"}";
2141+
2142+
String expected = "{"
2143+
+ "Humans={select=[{id=1000, name=Luke Skywalker}]}, "
2144+
+ "Human={id=1000, name=Luke Skywalker}"
2145+
+ "}";
2146+
2147+
//when:
2148+
Object result = executor.execute(query).getData();
2149+
2150+
//then:
2151+
assertThat(result.toString()).isEqualTo(expected);
2152+
2153+
//and given
2154+
Human human = em.find(Human.class, "1000");
2155+
2156+
human.setName("Luky Skywalker");
2157+
2158+
em.flush();
2159+
2160+
//when
2161+
result = executor.execute(query).getData();
2162+
2163+
String updated = "{"
2164+
+ "Humans={select=[{id=1000, name=Luky Skywalker}]}, "
2165+
+ "Human={id=1000, name=Luky Skywalker}"
2166+
+ "}";
2167+
2168+
//then:
2169+
assertThat(result.toString()).isEqualTo(updated);
2170+
2171+
}
2172+
21212173
}

0 commit comments

Comments
 (0)