/*
 * 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.apc.controller.system.employee;

import com.arrebol.apc.model.admin.Bonus;
import com.arrebol.apc.model.core.HumanResource;
import com.arrebol.apc.model.core.HumanResourceByOffice;
import com.arrebol.apc.model.core.Office;
import com.arrebol.apc.model.enums.ApplicationOwner;
import com.arrebol.apc.model.enums.HumanResourceStatus;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
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 EmployeeControllerTest {

    private EmployeeController controller;
    private String JANITZIO = "13c588a6-7d1b-11ea-af3e-28f659da398e";
    private String RUBEN = "0dc7c246-7db8-11ea-9b1f-500320958bf8";
    private String DIRECCION_JANITZIO = "5751074e-7d1b-11ea-af3e-28f659da398e";
    private String OFFICE_TEPIC = "caef3a64-7d1f-11ea-af3e-28f659da398e";
    private String OFFICE_GDL = "e0f1a2fc-7d1f-11ea-af3e-28f659da398e";

    public EmployeeControllerTest() {
    }

    @Before
    public void init() {
        controller = new EmployeeController();
    }

    //@Test
    public void findEmployeesByType() {
        try {
            List<HumanResource> result = controller.findEmployeesByType(
                    new Office(OFFICE_GDL),
                    HumanResourceStatus.ENEBLED,
                    JANITZIO
            );

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

            assertFalse(result.isEmpty());
        } catch (Exception e) {
            assertFalse(true);
        }
    }

    //@Test
    public void findEmployeesInType() {
        try {
            List<HumanResourceStatus> resourceStatuses = new ArrayList<>();

            resourceStatuses.add(HumanResourceStatus.ENEBLED);
            resourceStatuses.add(HumanResourceStatus.DISABLED);

            List<HumanResource> result = controller.findEmployeesInType(
                    new Office(OFFICE_GDL),
                    resourceStatuses,
                    JANITZIO
            );

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

            assertFalse(result.isEmpty());
        } catch (Exception e) {
            assertFalse(true);
        }
    }

    //@Test
    public void saveHRController() {
        try {
            HumanResource hr = new HumanResource();
            hr.setId(UUID.randomUUID().toString());
            hr.setFirstName("Empleado 1");
            hr.setSecondName("Empleado 1");
            hr.setLastName("Paterno 1");
            hr.setMiddleName("Materno 2");
            hr.setAvatar("images/avatar.png");
            //hr.setHumanResourceType(HumanResourceType.ADVISER);
            hr.setHumanResourceStatus(HumanResourceStatus.ENEBLED);
            hr.setCreatedBy(DIRECCION_JANITZIO);

            HumanResourceByOffice humanResourceByOffice = new HumanResourceByOffice(
                    new Office(OFFICE_GDL),
                    DIRECCION_JANITZIO,
                    new Date(),
                    ApplicationOwner.APP_USER
            );

            assertTrue(controller.saveHRController(humanResourceByOffice, hr));

        } catch (Exception e) {
            assertFalse(true);
        }
    }

    @Test
    public void findAllActiveBonus() {
        try {
            List<Bonus> bonuses = controller.findAllActiveBonus(OFFICE_TEPIC);

            assertTrue(bonuses.isEmpty());
        } catch (Exception e) {
            assertFalse(true);
        }
    }
}
