/*
 * Arrebol Consultancy copyright.
 * 
 * This code belongs to Arrebol Consultancy
 * its use, redistribution or modification are prohibited 
 * without written authorization from Arrebol Consultancy.
 */
package com.arrebol.taxiservicios.controller.admin;

import com.arrebol.taxiservicios.model.admin.ExpenseCompany;
import com.arrebol.taxiservicios.model.core.User;
import com.arrebol.taxiservicios.model.enums.BasicType;
import com.arrebol.taxiservicios.model.enums.ExpenseCompanyType;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Before;

/**
 *
 * @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
 */
public class ExpenseCompanyControllerTest {

    private Date startDate;
    private Date endDate;
    private ExpenseCompanyType typeIn;
    private ExpenseCompanyType typeOut;
    private String idToUpdate;
    private BasicType status;
    private ExpenseCompanyController controller;
    private User lastUpdatedBy;

    public ExpenseCompanyControllerTest() {
    }

    @Before
    public void setUp() {
        controller = new ExpenseCompanyController();
        Calendar start = Calendar.getInstance();
        Calendar end = Calendar.getInstance();

        //2019-03-07 09:07:04
        start.set(2021, 2, 13, 9, 7, 4);
        //2019-03-07 21:07:04
        end.set(2021, 2, 13, 21, 7, 4);
        startDate = start.getTime();
        endDate = end.getTime();
        typeIn = ExpenseCompanyType.PAYMENT_IN;
        typeOut = ExpenseCompanyType.PAYMENT_OUT;
        idToUpdate = "0831c148-8441-11eb-9e53-4ffafbf7e69b";
        status = BasicType.ENEBLED;
        lastUpdatedBy = new User("09ea84b8-b9d1-4a71-adfe-db653b2a9982", "");
    }

    //@Test
    public void findExpenseCompanyBetweenDatesIn() {
        try {
            List<ExpenseCompany> results = controller.findExpenseCompanyByTypeAndBetweenDates(typeIn, startDate, endDate,"");

            results.forEach(System.out::println);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //@Test
    public void findExpenseCompanyBetweenDatesOut() {
        try {
            List<ExpenseCompany> results = controller.findExpenseCompanyByTypeAndBetweenDates(typeOut, startDate, endDate,"");

            results.forEach(System.out::println);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void updateExpenseCompanyStatus() {
        try {
            assertTrue(controller.updateExpenseCompanyStatus(idToUpdate, status, lastUpdatedBy));

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
