use of io.smallrye.graphql.client.impl.ResponseImpl in project smallrye-graphql by smallrye.
the class ResponseReaderTest method testGetObjectWrongField.
@Test
public void testGetObjectWrongField() {
ResponseImpl response = ResponseReader.readFrom(EXAMPLE_RESPONSE_ONE_ITEM, null);
try {
response.getObject(Person.class, "WRONG_FIELD");
fail("Expected an exception");
} catch (NoSuchElementException e) {
assertTrue(e.getMessage().contains("people"), "Exception should tell what fields are available in the response");
}
}
use of io.smallrye.graphql.client.impl.ResponseImpl in project smallrye-graphql by smallrye.
the class ResponseReaderTest method testGetListWrongField.
@Test
public void testGetListWrongField() {
ResponseImpl response = ResponseReader.readFrom(EXAMPLE_RESPONSE_TWO_ITEMS, null);
try {
response.getList(Person.class, "WRONG_FIELD");
fail("Expected an exception");
} catch (NoSuchElementException e) {
assertTrue(e.getMessage().contains("people"), "Exception should tell what fields are available in the response");
}
}
use of io.smallrye.graphql.client.impl.ResponseImpl in project smallrye-graphql by smallrye.
the class ResponseReaderTest method nullPathInError.
@Test
public void nullPathInError() {
String responseString = "{\"errors\":[{\"message\":\"blabla\"," + "\"path\": null}]}";
ResponseImpl response = ResponseReader.readFrom(responseString, Collections.emptyMap());
assertNull(response.getErrors().get(0).getPath());
}
use of io.smallrye.graphql.client.impl.ResponseImpl in project smallrye-graphql by smallrye.
the class ResponseReaderTest method testGetObjectWhenDataIsNull.
@Test
public void testGetObjectWhenDataIsNull() {
ResponseImpl response = ResponseReader.readFrom(EXAMPLE_RESPONSE_NULL_DATA, null);
assertNull(response.getObject(Person.class, "people"));
}
use of io.smallrye.graphql.client.impl.ResponseImpl in project smallrye-graphql by smallrye.
the class ResponseReaderTest method testGetList.
@Test
public void testGetList() {
ResponseImpl response = ResponseReader.readFrom(EXAMPLE_RESPONSE_TWO_ITEMS, null);
List<Person> list = response.getList(Person.class, "people");
assertEquals(2, list.size());
}
Aggregations