1
resposta

Erro ao tentar deletar leilão

Mesmo eu utilizando o código do instrutor estou tomando erro

@Test public void deveInserirLeiloes() { Usuario mauricio = new Usuario(1L, "Mauricio Aniche", "mauricio.aniche@caelum.com.br"); Leilao leiloes = new Leilao(1L, "Geladeira", 800.0, mauricio, false);

    XmlPath retorno =
            given()
                    .header("Accept", "application/xml")
                    .contentType("application/xml")
                    .body(leiloes)
                    .expect()
                    .statusCode(200)
                    .when()
                    .post("/leiloes")
                    .andReturn()
                    .xmlPath();

    Leilao resposta = retorno.getObject("leilao", Leilao.class);

    assertEquals("Geladeira", resposta.getNome());

Quando rodo apresenta o erro ->

java.lang.RuntimeException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions br.com.caelum.leilao.modelo.Leilao não tem um construtor no-arg default. this problem is related to the following location: at br.com.caelum.leilao.modelo.Leilao

at com.jayway.restassured.mapper.factory.DefaultJAXBObjectMapperFactory.create(DefaultJAXBObjectMapperFactory.java:30) at com.jayway.restassured.mapper.factory.DefaultJAXBObjectMapperFactory.create(DefaultJAXBObjectMapperFactory.java:25) at com.jayway.restassured.mapper.factory.ObjectMapperFactory$create.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) at com.jayway.restassured.internal.mapping.JaxbMapper.serialize(JaxbMapper.groovy:46) at com.jayway.restassured.mapper.ObjectMapper$serialize.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at com.jayway.restassured.internal.mapping.ObjectMapping.serializeWithJaxb(ObjectMapping.groovy:172) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:148) at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:99) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:53) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:157) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:169) at com.jayway.restassured.internal.mapping.ObjectMapping.serialize(ObjectMapping.groovy:132) at com.jayway.restassured.internal.mapping.ObjectMapping$serialize.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at com.jayway.restassured.internal.RequestSpecificationImpl.body(RequestSpecificationImpl.groovy:462) at br.com.caelum.leilao.teste.UsuariosWSTest.deveInserirLeiloes(UsuariosWSTest.java:186) Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions br.com.caelum.leilao.modelo.Leilao não tem um construtor no-arg default. this problem is related to the following location: at br.com.caelum.leilao.modelo.Leilao

1 resposta

Amigo coloque a class Leilao, pelo que percebi falta o construtor padrão.

public Leilao(){}