Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.8 kB
3
Indexable
Never
package br.com.senior.erpxcomven.pedido.converter.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import org.junit.Before;
import org.junit.Test;

import br.com.senior.erpxcomven.pedido.E120imdEntity;
import br.com.senior.erpxcomven.pedido.E120imiEntity;
import br.com.senior.erpxcomven.pedido.Tax;

public class ConvertTaxTest {

    private ConvertTax convertTax;

    @Before
    public void setUp() {
        convertTax = new ConvertTax();
    }

    @Test
    public void testConvertE120imiEntity() {
        E120imiEntity e120imi = new E120imiEntity();
        e120imi.setBasImp(10.0);
        e120imi.setAliImp(5.0);
        e120imi.setTipImp("ICMS");
        e120imi.setVlrImp(50.0);

        Tax tax = convertTax.convert(e120imi);

        assertEquals(Double.valueOf(10.0), tax.getBasis());
        assertEquals(Double.valueOf(5.0), tax.getRate());
        assertEquals("ICMS", tax.getType());
        assertEquals(Double.valueOf(50.0), tax.getValue());
    }

    @Test
    public void testConvertE120imdEntity() {
        E120imdEntity e120imd = new E120imdEntity();
        e120imd.setBasImp(10.0);
        e120imd.setTipImp("PIS");
        e120imd.setVlrImp(2.0);

        Tax tax = convertTax.convert(e120imd);

        assertEquals(Double.valueOf(10.0), tax.getBasis());
        assertNull(tax.getRate());
        assertEquals("PIS", tax.getType());
        assertEquals(Double.valueOf(2.0), tax.getValue());
    }

    @Test
    public void testConvertNullE120imiEntity() {
        Tax tax = convertTax.convert(null);

        assertNull(tax);
    }

    @Test
    public void testConvertNullE120imdEntity() {
        Tax tax = convertTax.convert(null);

        assertNull(tax);
    }

}