Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Erro: Caused by: java.lang.AssertionError - Falaha ao executar o teste em MedicoRepositoryTest

Spring version: 3.3.6 MySql 8.0

github: https://github.com/ricardoguntzell/clinica-medica

Estou tomando o erro abaixo ao executar a classe de teste do repositorio medico. Conseguem me auxiliar?

java.lang.IllegalStateException: Failed to load ApplicationContext for [MergedContextConfiguration@2faae7f6 testClass = br.com.guntz.clinica.medica.api.domain.repository.MedicoRepositoryTest, locations = [], classes = [br.com.guntz.clinica.medica.ClinicaMedicaApiApplication], contextInitializerClasses = [], activeProfiles = ["test"], propertySourceDescriptors = [], propertySourceProperties = ["org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true"], contextCustomizers = [[ImportsContextCustomizer@673a5aa7 key = [org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration, org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcClientAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@3b6d844d, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@730d2164, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.reactor.netty.DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory$DisableReactorResourceFactoryGlobalResourcesContextCustomizerCustomizer@41488b16, org.springframework.boot.test.autoconfigure.OnFailureConditionReportContextCustomizerFactory$OnFailureConditionReportContextCustomizer@7ac296f6, org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@54e041a4, org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@1f, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@34be3d80, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@d5f370a3, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizer@6f8e8894, org.springframework.boot.test.context.SpringBootTestAnnotation@94342d41], contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null]

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pacienteRepository' defined in br.com.guntz.clinica.medica.api.domain.repository.PacienteRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: null

Caused by: java.lang.AssertionError at org.hibernate.query.sqm.tree.predicate.SqmBooleanExpressionPredicate.(SqmBooleanExpressionPredicate.java:42)

4 respostas

Oi!

Veja se é sobre essa questão: https://cursos.alura.com.br/course/spring-boot-3-documente-teste-prepare-api-deploy/task/137693

OLá!

Não seria essa questão. No meu caso o método funciona perfeitamente, porém, na execução dos testes(MedicoRepositoyTest), ocorre o erro mencionado acima, parece que ele não está conseguindo reconhecer essa classe de teste como um Repository...

Qualquer coisa deixei o link do meu github, caso queira baixar ai para testar

solução!

Nas suas classes Medico e Paciente o atributo ativo está como integer, ao invés de boolean e por isso acontece o problema, pois os repository estão tratando como boolean esse atributo.

Deu certo, Rodrigo!

Alterei e funionou.

Obrigado!