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

wmixvideo / nfe / #6671

20 Nov 2015 08:23PM UTC coverage: 79.804% (+2.4%) from 77.372%
#6671

push

travis-ci

fincatto
Corrigido teste atrelado a classe de info de partilha de icms

4394 of 5506 relevant lines covered (79.8%)

50.76 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 java.math.BigDecimal;
4
import java.rmi.RemoteException;
5

6
import org.apache.axiom.om.OMElement;
7
import org.apache.axiom.om.util.AXIOMUtil;
8
import org.apache.axis2.AxisFault;
9
import org.apache.log4j.Logger;
10
import org.simpleframework.xml.core.Persister;
11
import org.simpleframework.xml.stream.Format;
12

13
import com.fincatto.nfe310.NFeConfig;
14
import com.fincatto.nfe310.classes.NFAutorizador31;
15
import com.fincatto.nfe310.classes.nota.consulta.NFNotaConsulta;
16
import com.fincatto.nfe310.classes.nota.consulta.NFNotaConsultaRetorno;
17
import com.fincatto.nfe310.parsers.NotaFiscalChaveParser;
18
import com.fincatto.nfe310.transformers.NFRegistryMatcher;
19
import com.fincatto.nfe310.webservices.gerado.NfeConsulta2Stub;
20
import com.fincatto.nfe310.webservices.gerado.NfeConsulta2Stub.NfeConsultaNF2Result;
21

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

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

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

36
        final OMElement omElementRetorno = this.efetuaConsulta(omElementConsulta, chaveDeAcesso);
×
37
        WSNotaConsulta.LOG.info(omElementRetorno);
×
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 AxisFault, 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
        final NfeConsultaNF2Result consultaNF2Result = new NfeConsulta2Stub(NFAutorizador31.valueOfChaveAcesso(chaveDeAcesso).getNfeConsultaProtocolo(this.config.getAmbiente())).nfeConsultaNF2(dados, cabecE);
×
53
        return consultaNF2Result.getExtraElement();
×
54
    }
55

56
    private NFNotaConsulta gerarDadosConsulta(final String chaveDeAcesso) {
57
        final NFNotaConsulta notaConsulta = new NFNotaConsulta();
×
58
        notaConsulta.setAmbiente(this.config.getAmbiente());
×
59
        notaConsulta.setChave(chaveDeAcesso);
×
60
        notaConsulta.setServico(WSNotaConsulta.NOME_SERVICO);
×
61
        notaConsulta.setVersao(new BigDecimal(WSNotaConsulta.VERSAO_SERVICO));
×
62
        return notaConsulta;
×
63
    }
64
}
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