graphql-java-kickstart / graphql-spring-boot

GraphQL and GraphiQL Spring Framework Boot Starters - Forked from oembedler/graphql-spring-boot due to inactivity.
https://www.graphql-java-kickstart.com/spring-boot/
MIT License
1.5k stars 325 forks source link

No qualifying bean of type 'com.graphql.spring.boot.test.GraphQLTestTemplate' available : graphql-spring-boot-starter-test:jar:15.0.0 #978

Open himanshs opened 1 year ago

himanshs commented 1 year ago

Hi,

we are upgrading our project to spring boot 3 and as part of that we have upgraded graphql-spring-boot to 15.0.0. After this upgraded we are getting issue for GraphQlTestTemplate in Junit.

@GraphQLTest @ContextConfiguration(classes = {TestConfig.class, MessagesConfig.class}) @RunWith(SpringRunner.class) public class QueryTest {

@Autowired
private GraphQLTestTemplate graphQLTestTemplate;

@MockBean
private TicketTicketentityServiceApiMock ticketTicketentityServiceApiMock;

@Inject
private GraphqlUtils graphqlUtils;

@Autowired
private IHeadersAccessor headersAccessor;

@Autowired
@Qualifier("asyncExecutor")
public AsyncTaskExecutor executor;

@Test
public void searchTickets() throws IOException {
    GraphQLResponse response = graphQLTestTemplate.postForResource(TestConstants.SEARCH_TICKET_QUERY_FILE);
    String str = getStringFromJson(TestConstants.SEARCH_TICKET_GRAPH_RES);
    assertNotNull(response);
    assertTrue(response.isOk());
    assertEquals(str, response.getRawResponse().getBody());
}

}

Below stack trace of the exception.

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.graphql.spring.boot.test.GraphQLTestTemplate' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1824) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1383) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:713)