graphql-spring-boot icon indicating copy to clipboard operation
graphql-spring-boot copied to clipboard

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

Open himanshs opened this issue 7 months ago • 0 comments

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)

himanshs avatar Nov 27 '23 14:11 himanshs