github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/bb/request_test.go (about)

     1  package bb
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  const requestExpected = `
    10   ## SOAPACTION:registrarBoleto
    11   ##	Authorization:Bearer {{.Authentication.AuthorizationToken}}
    12   ## Content-Type:text/xml; charset=utf-8
    13  
    14   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.tibco.com/schemas/bws_registro_cbr/Recursos/XSD/Schema.xsd">
    15   <soapenv:Header/>
    16   <soapenv:Body>
    17  <sch:requisicao>
    18   <sch:numeroConvenio>{{.Agreement.AgreementNumber}}</sch:numeroConvenio>
    19   <sch:numeroCarteira>17</sch:numeroCarteira>
    20   <sch:numeroVariacaoCarteira>{{.Agreement.WalletVariation}}</sch:numeroVariacaoCarteira>
    21   <sch:codigoModalidadeTitulo>1</sch:codigoModalidadeTitulo>
    22   <sch:dataEmissaoTitulo>{{replace (today | brdate) "/" "."}}</sch:dataEmissaoTitulo>
    23   <sch:dataVencimentoTitulo>{{replace (.Title.ExpireDateTime | brdate) "/" "."}}</sch:dataVencimentoTitulo>
    24   <sch:valorOriginalTitulo>{{toFloatStr .Title.AmountInCents}}</sch:valorOriginalTitulo>
    25   <sch:codigoTipoDesconto>0</sch:codigoTipoDesconto> 
    26   <sch:codigoTipoMulta>0</sch:codigoTipoMulta> 
    27   <sch:codigoAceiteTitulo>N</sch:codigoAceiteTitulo>
    28   <sch:codigoTipoTitulo>{{.Title.BoletoTypeCode}}</sch:codigoTipoTitulo>
    29   <sch:textoDescricaoTipoTitulo></sch:textoDescricaoTipoTitulo>
    30   <sch:indicadorPermissaoRecebimentoParcial>N</sch:indicadorPermissaoRecebimentoParcial>
    31   <sch:textoNumeroTituloBeneficiario>{{.Title.DocumentNumber}}</sch:textoNumeroTituloBeneficiario>
    32   <sch:textoNumeroTituloCliente>000{{padLeft (toString .Agreement.AgreementNumber) "0" 7}}{{padLeft (toString .Title.OurNumber) "0" 10}}</sch:textoNumeroTituloCliente>
    33   <sch:textoMensagemBloquetoOcorrencia>Pagamento disponível até a data de vencimento</sch:textoMensagemBloquetoOcorrencia>
    34   <sch:codigoTipoInscricaoPagador>{{docType .Buyer.Document}}</sch:codigoTipoInscricaoPagador>
    35   <sch:numeroInscricaoPagador>{{clearString (truncate .Buyer.Document.Number 15)}}</sch:numeroInscricaoPagador>
    36   <sch:nomePagador>{{clearString (truncate .Buyer.Name 60)}}</sch:nomePagador>
    37   <sch:textoEnderecoPagador>{{clearString (truncate .Buyer.Address.Street 60)}}</sch:textoEnderecoPagador>
    38   <sch:numeroCepPagador>{{extractNumbers .Buyer.Address.ZipCode}}</sch:numeroCepPagador>
    39   <sch:nomeMunicipioPagador>{{clearString (truncate .Buyer.Address.City 20)}}</sch:nomeMunicipioPagador>
    40   <sch:nomeBairroPagador>{{clearString (truncate .Buyer.Address.District 20)}}</sch:nomeBairroPagador>
    41   <sch:siglaUfPagador>{{clearString (truncate .Buyer.Address.StateCode 2)}}</sch:siglaUfPagador> 
    42   <sch:codigoChaveUsuario>1</sch:codigoChaveUsuario>
    43   <sch:codigoTipoCanalSolicitacao>5</sch:codigoTipoCanalSolicitacao>
    44   </sch:requisicao>
    45   </soapenv:Body>
    46  </soapenv:Envelope>
    47   `
    48  
    49  func Test_GivenTheGetRequestMethodWasCalled_ThenItShouldCorrectlyGetTheRequestTemplate(t *testing.T) {
    50  	result := getRequest()
    51  
    52  	assert.Equal(t, requestExpected, result, "Deve trazer corretamente o template de request")
    53  }