vendredi 2 février 2018

How I create a Sql mock unit test Grails

I'm Trying test this code with a unit test Grails:

def getMarca(CrDocumento crDocumento) {
    if (!crDocumento) {
        return null
    }
    String sql = ""

    sql = "select marca.id as marca_id from cr_documento, matricula, cr_renegoc_boleto, oferta_polo_turma, oferta_polo, oferta, marca where cr_documento.id = cr_renegoc_boleto.cr_documento_id and cr_documento.matricula_id = matricula.id and matricula.oferta_polo_turma_id = oferta_polo_turma.id and oferta_polo_turma.oferta_polo_id = oferta_polo.id and oferta_polo.oferta_id = oferta.id and oferta.marca_id = marca.id and cr_documento.id = $crDocumento.id"

    def sqlGroovy = new Sql(dataSource)
    def marcaId = sqlGroovy.firstRow(sql)?.marca_id
    return Marca.findById(marcaId)
}

but I can't mock Sql Class and show this error: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method groovy.sql.Sql#. Cannot resolve which method to invoke for [null] due to overlapping prototypes between: [interface java.sql.Connection] [interface javax.sql.DataSource]

Aucun commentaire:

Enregistrer un commentaire