Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

[Erro] - ConsultaControllerTest ... Failed to load ApplicationContext

Ao rodar o teste recebo o seguinte log de erro, inclusive no projeto final disponibilizado pelo professor.

Alguém pode me ajudar?

Nota: Meu application.properties tem a linha "api.securanca.token.secret=${JWT_SECRET}"


java.lang.IllegalStateException: Failed to load ApplicationContext for [WebMergedContextConfiguration@74159dc9 testClass = br.com.alura.med.voll.api.controller.ConsultaControllerTest, locations = [], classes = [br.com.alura.med.voll.api.ApiApplication], contextInitializerClasses = [], activeProfiles = [], propertySourceDescriptors = [], propertySourceProperties = ["org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true"], contextCustomizers = [[ImportsContextCustomizer@53086bdc key = [org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration, 
...
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'autenticacaoController': Unsatisfied dependency expressed through field 'manager': Error creating bean with name 'segurancaConfigurations': Unsatisfied dependency expressed through field 'segurancaFilter': Error creating bean with name 'segurancaFilter': Unsatisfied dependency expressed through field 'tokenService': Error creating bean with name 'tokenService': Injection of autowired dependencies failed
...

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'segurancaConfigurations': Unsatisfied dependency expressed through field 'segurancaFilter': Error creating bean with name 'segurancaFilter': Unsatisfied dependency expressed through field 'tokenService': Error creating bean with name 'tokenService': Injection of autowired dependencies failed
...

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'segurancaFilter': Unsatisfied dependency expressed through field 'tokenService': Error creating bean with name 'tokenService': Injection of autowired dependencies failed
    at ....

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'JWT_SECRET' in value "${JWT_SECRET}"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:180)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
    at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:239)
    at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210)
    at org.springframework.core.env.AbstractPropertyResolver.resolveNestedPlaceholders(AbstractPropertyResolver.java:230)
1 resposta
solução!

Resolvido

Coloquei a variável de ambiente JWT_SECRET na run config do teste