java.lang.NoSuchMethodError: 'org.springframework.core.annotation.AnnotationAttributes org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(java.lang.reflect.AnnotatedElement, java.lang.String)'
at org.springframework.test.util.MetaAnnotationUtils$AnnotationDescriptor.<init>(MetaAnnotationUtils.java:305)
at org.springframework.test.util.MetaAnnotationUtils$UntypedAnnotationDescriptor.<init>(MetaAnnotationUtils.java:367)
at org.springframework.test.util.MetaAnnotationUtils$UntypedAnnotationDescriptor.<init>(MetaAnnotationUtils.java:362)
at org.springframework.test.util.MetaAnnotationUtils.findAnnotationDescriptorForTypes(MetaAnnotationUtils.java:207)
at org.springframework.test.util.MetaAnnotationUtils.findAnnotationDescriptorForTypes(MetaAnnotationUtils.java:180)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:270)
at org.springframework.test.context.DefaultTestContext.<init>(DefaultTestContext.java:67)
at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:103)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:123)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:114)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:90)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:76)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:49)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:526)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
package br.com.forgeSpring.loja.daos;
import java.math.BigDecimal;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.annotation.Profile;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import br.com.forgeSpring.loja.builders.ProdutoBuilder;
import br.com.forgeSpring.loja.conf.DataSourceConfiguration;
import br.com.forgeSpring.loja.conf.JPAConfiguration;
import br.com.forgeSpring.loja.models.Produto;
import br.com.forgeSpring.loja.models.TipoPreco;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {JPAConfiguration.class,ProdutoDAO.class,DataSourceConfiguration.class})
@Profile("test")
public class ProdutoDAOTest {
private ProdutoDAO produtoDAO;
@Test
@Transactional
public void deveSomarTodosPrecosPorTipoDeLivro() {
ProdutoDAO produtoDao = new ProdutoDAO();
List<Produto> livrosImpressos = ProdutoBuilder
.newProduto(TipoPreco.Impresso, BigDecimal.TEN)
.more(3)
.buildAll();
List<Produto> livrosEbook = ProdutoBuilder
.newProduto(TipoPreco.EBook, BigDecimal.TEN)
.more(3)
.buildAll();
livrosEbook.stream().forEach(produtoDao::gravar);
livrosImpressos.stream().forEach(produtoDao::gravar);
BigDecimal valor = produtoDAO.somaPrecosPorTipo(TipoPreco.EBook);
Assert.assertEquals(new BigDecimal(40).setScale(2),valor);
}
}
O que estou fazendo de errado? Meu teste nem inicia...