-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from wmixvideo/dev
Limpeza de projeto e cobertura de testes
- Loading branch information
Showing
5 changed files
with
114 additions
and
138 deletions.
There are no files selected for viewing
68 changes: 0 additions & 68 deletions
68
src/main/java/com/fincatto/nfe310/classes/NFChaveInterpretador.java
This file was deleted.
Oops, something went wrong.
This file contains 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
68 changes: 0 additions & 68 deletions
68
src/main/java/com/fincatto/nfe310/validadores/xsd/ErroHandler.java
This file was deleted.
Oops, something went wrong.
This file contains 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
87 changes: 87 additions & 0 deletions
87
src/test/java/com/fincatto/nfe310/parsers/NotaFiscalChaveParserTest.java
This file contains 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,87 @@ | ||
package com.fincatto.nfe310.parsers; | ||
|
||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.fincatto.nfe310.classes.NFTipoEmissao; | ||
import com.fincatto.nfe310.classes.NFUnidadeFederativa; | ||
|
||
public class NotaFiscalChaveParserTest { | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void naoDevePermitirChaveDeTamanhoInvalido() { | ||
try { | ||
new NotaFiscalChaveParser(null); | ||
Assert.fail(); | ||
} catch (final IllegalArgumentException e) { | ||
|
||
} | ||
try { | ||
new NotaFiscalChaveParser("1734119042676883974264088457913359614139959"); | ||
Assert.fail(); | ||
} catch (final IllegalArgumentException e) { | ||
new NotaFiscalChaveParser("173411904267688397426408845791335961413995927"); | ||
Assert.fail(); | ||
} | ||
} | ||
|
||
@Test | ||
public void deveObterUFDeChave() { | ||
Assert.assertEquals(NFUnidadeFederativa.SC, new NotaFiscalChaveParser("42341190426768839742640884579133596141399591").getNFUnidadeFederativa()); | ||
} | ||
|
||
@Test | ||
public void deveObterDataDeEmissaoDaChave() throws ParseException { | ||
final Date dataEsperada = new SimpleDateFormat("yyyy/MM").parse("2015/11"); | ||
Assert.assertEquals(dataEsperada, new NotaFiscalChaveParser("42151190426768839742640884579133596141399591").getDataEmissao()); | ||
} | ||
|
||
@Test | ||
public void deveObterCNPJEmitenteDaChave() { | ||
Assert.assertEquals("03918609000132", new NotaFiscalChaveParser("42151103918609000132640884579133596141399591").getCnpjEmitente()); | ||
} | ||
|
||
@Test | ||
public void deveObterSerieDaChave() { | ||
Assert.assertEquals("088", new NotaFiscalChaveParser("42151103918609000132640884579133596141399591").getSerie()); | ||
} | ||
|
||
@Test | ||
public void deveObterNumeroDaChave() { | ||
Assert.assertEquals("457913359", new NotaFiscalChaveParser("42151103918609000132640884579133596141399591").getNumero()); | ||
} | ||
|
||
@Test | ||
public void deveObterFormaEmissaoDaChave() { | ||
Assert.assertEquals(NFTipoEmissao.EMISSAO_NORMAL, new NotaFiscalChaveParser("42151103918609000132640884579133591141399591").getFormaEmissao()); | ||
} | ||
|
||
@Test | ||
public void deveObterCodigoNumericoDaChave() { | ||
Assert.assertEquals("14139959", new NotaFiscalChaveParser("42151103918609000132640884579133591141399591").getCodigoNumerico()); | ||
} | ||
|
||
@Test | ||
public void deveObterDivisorDaChave() { | ||
Assert.assertEquals("1", new NotaFiscalChaveParser("42151103918609000132640884579133591141399591").getDV()); | ||
} | ||
|
||
@Test | ||
public void naoDeveSerNotaEmitidaEmContigencia() { | ||
Assert.assertFalse(new NotaFiscalChaveParser("42151103918609000132640884579133596141399591").isEmitidaContingenciaSCAN()); | ||
} | ||
|
||
@Test | ||
public void deveSerNotaEmitidaEmContigencia() { | ||
Assert.assertTrue(new NotaFiscalChaveParser("42151103918609000132649884579133596141399591").isEmitidaContingenciaSCAN()); | ||
} | ||
|
||
@Test | ||
public void deveFormatarChave() { | ||
Assert.assertEquals("4215 1103 9186 0900 0132 6408 8457 9133 5961 4139 9591", new NotaFiscalChaveParser("42151103918609000132640884579133596141399591").getFormatado()); | ||
} | ||
} |