forked from Samuel-Oliveira/Java_NFe
-
Notifications
You must be signed in to change notification settings - Fork 0
[SKYW-1751]-Atualizar biblioteca Java_NFe para a versao mais recente #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
stephanhugo
merged 10 commits into
release
from
SKYW-1751-Atualizar-biblioteca-Java_NFe-para-a-versao-mais-recente
Apr 10, 2026
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3f0c775
Correcao Impressao Observacoes
Samuel-Oliveira 3f3c3c2
Ajustes Impressao
Samuel-Oliveira 1625d18
Adicionado Novo cacert
Samuel-Oliveira b47d980
Adicionado Novo cacert
Samuel-Oliveira ab247aa
Merge branch 'release/4.00.51' into master
Samuel-Oliveira 52658a4
Correcao de IBSCBS Test
Samuel-Oliveira e957127
Merge branch 'release/4.00.51' into master
Samuel-Oliveira 65691bf
Merge branch 'master' into SKYW-1751-Atualizar-biblioteca-Java_NFe-pa…
Jair-Diniz 9d684f4
[SKYW-1751] Update to version 4.00.51
Jair-Diniz ec2aca7
[SKYW-1751] XSD file update
Jair-Diniz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,5 @@ target/ | |
| .idea/ | ||
| *.iml | ||
| /target/ | ||
| /.github/*.md | ||
| show, | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
src/test/java/br/com/swconsultoria/nfe/CancelarTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| package br.com.swconsultoria.nfe; | ||
|
|
||
| import br.com.swconsultoria.nfe.dom.ConfiguracoesNfe; | ||
| import br.com.swconsultoria.nfe.dom.Evento; | ||
| import br.com.swconsultoria.nfe.dom.enuns.AmbienteEnum; | ||
| import br.com.swconsultoria.nfe.dom.enuns.AssinaturaEnum; | ||
| import br.com.swconsultoria.nfe.dom.enuns.DocumentoEnum; | ||
| import br.com.swconsultoria.nfe.dom.enuns.EstadosEnum; | ||
| import br.com.swconsultoria.nfe.exception.NfeException; | ||
| import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TEnvEvento; | ||
| import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TRetEnvEvento; | ||
| import br.com.swconsultoria.nfe.util.CancelamentoUtil; | ||
| import br.com.swconsultoria.nfe.util.StubUtil; | ||
| import br.com.swconsultoria.nfe.wsdl.NFeRecepcaoEvento.NFeRecepcaoEvento4Stub; | ||
| import mockit.Mock; | ||
| import mockit.MockUp; | ||
| import org.apache.axiom.om.util.AXIOMUtil; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
|
||
| class CancelarTest { | ||
|
|
||
| private static final String RET_EVENTO_XML = | ||
| "<retEnvEvento versao=\"1.00\" xmlns=\"http://www.portalfiscal.inf.br/nfe\">" + | ||
| "<idLote>1</idLote><tpAmb>2</tpAmb><verAplic>TESTE</verAplic>" + | ||
| "<cOrgao>91</cOrgao><cStat>128</cStat>" + | ||
| "<xMotivo>Lote de Evento Processado</xMotivo>" + | ||
| "</retEnvEvento>"; | ||
|
|
||
| private ConfiguracoesNfe config; | ||
| private TEnvEvento enviEvento; | ||
|
|
||
| @BeforeEach | ||
| void setUp() throws NfeException { | ||
| config = new ConfiguracoesNfe(); | ||
| config.setEstado(EstadosEnum.SP); | ||
| config.setAmbiente(AmbienteEnum.HOMOLOGACAO); | ||
| config.setEncode("UTF-8"); | ||
|
|
||
| config.setZoneId(java.time.ZoneId.of("America/Sao_Paulo")); | ||
|
|
||
| Evento evento = new Evento(); | ||
| evento.setChave("52230309158456000159550010000731791567812345"); | ||
| evento.setCnpj("09158456000159"); | ||
| evento.setProtocolo("352230000123456"); | ||
| evento.setMotivo("Cancelamento por erro na emissao do documento fiscal"); | ||
| evento.setDataEvento(java.time.LocalDateTime.of(2024, 1, 15, 10, 0, 0)); | ||
| enviEvento = CancelamentoUtil.montaCancelamento(evento, config); | ||
| } | ||
|
|
||
| private void mockStubUtil() { | ||
| new MockUp<StubUtil>() { | ||
| @Mock | ||
| public void configuraHttpClient(org.apache.axis2.client.Stub stub, | ||
| ConfiguracoesNfe cfg, String url) { } | ||
| }; | ||
| } | ||
|
|
||
| private void mockAssinar() { | ||
| new MockUp<Assinar>() { | ||
| @Mock | ||
| public String assinaNfe(ConfiguracoesNfe cfg, String xml, | ||
| AssinaturaEnum tipo) throws NfeException { | ||
| return xml; | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| private void mockEventosStub() { | ||
| new MockUp<NFeRecepcaoEvento4Stub>() { | ||
| @Mock | ||
| public void $init(String endpoint) { } | ||
|
|
||
| @Mock | ||
| public NFeRecepcaoEvento4Stub.NfeResultMsg nfeRecepcaoEvento( | ||
| NFeRecepcaoEvento4Stub.NfeDadosMsg data) throws Exception { | ||
| NFeRecepcaoEvento4Stub.NfeResultMsg result = new NFeRecepcaoEvento4Stub.NfeResultMsg(); | ||
| result.setExtraElement(AXIOMUtil.stringToOM(RET_EVENTO_XML)); | ||
| return result; | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| @Test | ||
| void eventoCancelamento_semValidacao_retornaEvento() throws NfeException { | ||
| mockStubUtil(); | ||
| mockAssinar(); | ||
| mockEventosStub(); | ||
|
|
||
| TRetEnvEvento ret = Cancelar.eventoCancelamento(config, enviEvento, false, DocumentoEnum.NFE); | ||
|
|
||
| assertNotNull(ret); | ||
| assertEquals("128", ret.getCStat()); | ||
| } | ||
|
|
||
| @Test | ||
| void eventoCancelamento_retornaLoteProcessado() throws NfeException { | ||
| mockStubUtil(); | ||
| mockAssinar(); | ||
| mockEventosStub(); | ||
|
|
||
| TRetEnvEvento ret = Cancelar.eventoCancelamento(config, enviEvento, false, DocumentoEnum.NFE); | ||
|
|
||
| assertEquals("Lote de Evento Processado", ret.getXMotivo()); | ||
| } | ||
|
|
||
| @Test | ||
| void eventoCancelamento_retornaAmbienteHomologacao() throws NfeException { | ||
| mockStubUtil(); | ||
| mockAssinar(); | ||
| mockEventosStub(); | ||
|
|
||
| TRetEnvEvento ret = Cancelar.eventoCancelamento(config, enviEvento, false, DocumentoEnum.NFE); | ||
|
|
||
| assertEquals("2", ret.getTpAmb()); | ||
| } | ||
| } |
119 changes: 119 additions & 0 deletions
119
src/test/java/br/com/swconsultoria/nfe/CartaCorrecaoTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| package br.com.swconsultoria.nfe; | ||
|
|
||
| import br.com.swconsultoria.nfe.dom.ConfiguracoesNfe; | ||
| import br.com.swconsultoria.nfe.dom.Evento; | ||
| import br.com.swconsultoria.nfe.dom.enuns.AmbienteEnum; | ||
| import br.com.swconsultoria.nfe.dom.enuns.AssinaturaEnum; | ||
| import br.com.swconsultoria.nfe.dom.enuns.EstadosEnum; | ||
| import br.com.swconsultoria.nfe.exception.NfeException; | ||
| import br.com.swconsultoria.nfe.schema.envcce.TEnvEvento; | ||
| import br.com.swconsultoria.nfe.schema.envcce.TRetEnvEvento; | ||
| import br.com.swconsultoria.nfe.util.CartaCorrecaoUtil; | ||
| import br.com.swconsultoria.nfe.util.StubUtil; | ||
| import br.com.swconsultoria.nfe.wsdl.NFeRecepcaoEvento.NFeRecepcaoEvento4Stub; | ||
| import mockit.Mock; | ||
| import mockit.MockUp; | ||
| import org.apache.axiom.om.util.AXIOMUtil; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
|
||
| class CartaCorrecaoTest { | ||
|
|
||
| private static final String RET_EVENTO_XML = | ||
| "<retEnvEvento versao=\"1.00\" xmlns=\"http://www.portalfiscal.inf.br/nfe\">" + | ||
| "<idLote>1</idLote><tpAmb>2</tpAmb><verAplic>TESTE</verAplic>" + | ||
| "<cOrgao>91</cOrgao><cStat>128</cStat>" + | ||
| "<xMotivo>Lote de Evento Processado</xMotivo>" + | ||
| "</retEnvEvento>"; | ||
|
|
||
| private ConfiguracoesNfe config; | ||
| private TEnvEvento enviEvento; | ||
|
|
||
| @BeforeEach | ||
| void setUp() throws NfeException { | ||
| config = new ConfiguracoesNfe(); | ||
| config.setEstado(EstadosEnum.SP); | ||
| config.setAmbiente(AmbienteEnum.HOMOLOGACAO); | ||
| config.setEncode("UTF-8"); | ||
|
|
||
| config.setZoneId(java.time.ZoneId.of("America/Sao_Paulo")); | ||
|
|
||
| Evento evento = new Evento(); | ||
| evento.setChave("52230309158456000159550010000731791567812345"); | ||
| evento.setCnpj("09158456000159"); | ||
| evento.setMotivo("Correcao no campo de endereco do destinatario da nota fiscal"); | ||
| evento.setSequencia(1); | ||
| evento.setDataEvento(java.time.LocalDateTime.of(2024, 3, 10, 9, 0, 0)); | ||
| enviEvento = CartaCorrecaoUtil.montaCCe(evento, config); | ||
| } | ||
|
|
||
| private void mockStubUtil() { | ||
| new MockUp<StubUtil>() { | ||
| @Mock | ||
| public void configuraHttpClient(org.apache.axis2.client.Stub stub, | ||
| ConfiguracoesNfe cfg, String url) { } | ||
| }; | ||
| } | ||
|
|
||
| private void mockAssinar() { | ||
| new MockUp<Assinar>() { | ||
| @Mock | ||
| public String assinaNfe(ConfiguracoesNfe cfg, String xml, | ||
| AssinaturaEnum tipo) throws NfeException { | ||
| return xml; | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| private void mockEventosStub() { | ||
| new MockUp<NFeRecepcaoEvento4Stub>() { | ||
| @Mock | ||
| public void $init(String endpoint) { } | ||
|
|
||
| @Mock | ||
| public NFeRecepcaoEvento4Stub.NfeResultMsg nfeRecepcaoEvento( | ||
| NFeRecepcaoEvento4Stub.NfeDadosMsg data) throws Exception { | ||
| NFeRecepcaoEvento4Stub.NfeResultMsg result = new NFeRecepcaoEvento4Stub.NfeResultMsg(); | ||
| result.setExtraElement(AXIOMUtil.stringToOM(RET_EVENTO_XML)); | ||
| return result; | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| @Test | ||
| void eventoCCe_semValidacao_retornaEvento() throws NfeException { | ||
| mockStubUtil(); | ||
| mockAssinar(); | ||
| mockEventosStub(); | ||
|
|
||
| TRetEnvEvento ret = CartaCorrecao.eventoCCe(config, enviEvento, false); | ||
|
|
||
| assertNotNull(ret); | ||
| assertEquals("128", ret.getCStat()); | ||
| } | ||
|
|
||
| @Test | ||
| void eventoCCe_retornaLoteProcessado() throws NfeException { | ||
| mockStubUtil(); | ||
| mockAssinar(); | ||
| mockEventosStub(); | ||
|
|
||
| TRetEnvEvento ret = CartaCorrecao.eventoCCe(config, enviEvento, false); | ||
|
|
||
| assertEquals("Lote de Evento Processado", ret.getXMotivo()); | ||
| } | ||
|
|
||
| @Test | ||
| void eventoCCe_retornaAmbienteHomologacao() throws NfeException { | ||
| mockStubUtil(); | ||
| mockAssinar(); | ||
| mockEventosStub(); | ||
|
|
||
| TRetEnvEvento ret = CartaCorrecao.eventoCCe(config, enviEvento, false); | ||
|
|
||
| assertEquals("2", ret.getTpAmb()); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PII
More Details
Sampled Examples
To ignore this finding as an exception, reply to this conversation with
#wiz_ignore reasonIf you'd like to ignore this finding in all future scans, add an exception in the .wiz file (learn more) or create an Ignore Rule (learn more).
To get more details on how to remediate this issue using AI, reply to this conversation with
#wiz remediate