• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wmixvideo / nfe / #6668

02 Jun 2016 11:49PM UTC coverage: 79.364% (+3.7%) from 75.706%
#6668

push

travis-ci

fincatto
Atualizado xsd de validacao de envio de lote, que valida as notas com assinatura.
Atualizado para versão 2.0.0-SNAPSHOT, pois o codigo quebrou a compatibilidade.

0 of 1 new or added line in 1 file covered. (0.0%)

349 existing lines in 68 files now uncovered.

4742 of 5975 relevant lines covered (79.36%)

50.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/fincatto/nfe310/webservices/WSNotaConsulta.java
1
package com.fincatto.nfe310.webservices;
2

3
import com.fincatto.nfe310.NFeConfig;
4
import com.fincatto.nfe310.classes.NFAutorizador31;
5
import com.fincatto.nfe310.classes.NFModelo;
6
import com.fincatto.nfe310.classes.nota.consulta.NFNotaConsulta;
7
import com.fincatto.nfe310.classes.nota.consulta.NFNotaConsultaRetorno;
8
import com.fincatto.nfe310.parsers.NotaFiscalChaveParser;
9
import com.fincatto.nfe310.transformers.NFRegistryMatcher;
10
import com.fincatto.nfe310.webservices.gerado.NfeConsulta2Stub;
11
import com.fincatto.nfe310.webservices.gerado.NfeConsulta2Stub.NfeConsultaNF2Result;
12
import org.apache.axiom.om.OMElement;
13
import org.apache.axiom.om.util.AXIOMUtil;
14
import org.simpleframework.xml.core.Persister;
15
import org.simpleframework.xml.stream.Format;
16
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
18

19
import java.math.BigDecimal;
20
import java.rmi.RemoteException;
21

22
class WSNotaConsulta {
23
    private static final String NOME_SERVICO = "CONSULTAR";
24
    private static final String VERSAO_SERVICO = "3.10";
UNCOV
25
    private final static Logger LOGGER = LoggerFactory.getLogger(WSNotaConsulta.class);
×
26
    private final NFeConfig config;
27

28
    WSNotaConsulta(final NFeConfig config) {
×
29
        this.config = config;
×
30
    }
×
31

32
    NFNotaConsultaRetorno consultaNota(final String chaveDeAcesso) throws Exception {
33
        final OMElement omElementConsulta = AXIOMUtil.stringToOM(this.gerarDadosConsulta(chaveDeAcesso).toString());
×
34
        WSNotaConsulta.LOGGER.debug(omElementConsulta.toString());
×
35

36
        final OMElement omElementRetorno = this.efetuaConsulta(omElementConsulta, chaveDeAcesso);
×
37
        WSNotaConsulta.LOGGER.debug(omElementRetorno.toString());
×
38
        return new Persister(new NFRegistryMatcher(), new Format(0)).read(NFNotaConsultaRetorno.class, omElementRetorno.toString());
×
39
    }
40

41
    private OMElement efetuaConsulta(final OMElement omElementConsulta, final String chaveDeAcesso) throws RemoteException {
42
        final NotaFiscalChaveParser notaFiscalChaveParser = new NotaFiscalChaveParser(chaveDeAcesso);
×
43
        final NfeConsulta2Stub.NfeCabecMsg cabec = new NfeConsulta2Stub.NfeCabecMsg();
×
44
        cabec.setCUF(notaFiscalChaveParser.getNFUnidadeFederativa().getCodigoIbge());
×
45
        cabec.setVersaoDados(WSNotaConsulta.VERSAO_SERVICO);
×
46

47
        final NfeConsulta2Stub.NfeCabecMsgE cabecE = new NfeConsulta2Stub.NfeCabecMsgE();
×
48
        cabecE.setNfeCabecMsg(cabec);
×
49

50
        final NfeConsulta2Stub.NfeDadosMsg dados = new NfeConsulta2Stub.NfeDadosMsg();
×
51
        dados.setExtraElement(omElementConsulta);
×
52

53

UNCOV
54
        NFAutorizador31 autorizador = NFAutorizador31.valueOfChaveAcesso(chaveDeAcesso);
×
UNCOV
55
        final String endpoint = NFModelo.NFCE.equals(notaFiscalChaveParser.getModelo()) ? autorizador.getNfceConsultaProtocolo(config.getAmbiente()) : autorizador.getNfeConsultaProtocolo(config.getAmbiente());
×
UNCOV
56
        if (endpoint == null) {
×
57
            throw new IllegalArgumentException("Nao foi possivel encontrar URL para ConsultaProtocolo " + notaFiscalChaveParser.getModelo().name() + ", autorizador " + autorizador.name());
×
58
        }
59

60
        final NfeConsultaNF2Result consultaNF2Result = new NfeConsulta2Stub(endpoint).nfeConsultaNF2(dados, cabecE);
×
61
        return consultaNF2Result.getExtraElement();
×
62
    }
63

64
    private NFNotaConsulta gerarDadosConsulta(final String chaveDeAcesso) {
UNCOV
65
        final NFNotaConsulta notaConsulta = new NFNotaConsulta();
×
UNCOV
66
        notaConsulta.setAmbiente(this.config.getAmbiente());
×
UNCOV
67
        notaConsulta.setChave(chaveDeAcesso);
×
UNCOV
68
        notaConsulta.setServico(WSNotaConsulta.NOME_SERVICO);
×
UNCOV
69
        notaConsulta.setVersao(new BigDecimal(WSNotaConsulta.VERSAO_SERVICO));
×
UNCOV
70
        return notaConsulta;
×
71
    }
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc