package com.capgemini.reports.reports.parameters;

import com.capgemini.framework.teamcenter.exceptions.NoTeamcenterConnectionException;
import com.capgemini.framework.teamcenter.policies.PolicyLocation;
import com.capgemini.reports.AbstractTeamcenterTest;
import com.capgemini.reports.exceptions.NotFoundException;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

/**
 * @author JMONTOUT
 */
@Slf4j
public class GenericsTest extends AbstractTeamcenterTest {

    private static final String PRODUCT_97R0 = "97R0";
    private static final String GENERIC_U22 = "U22";
    private static final String GENERIC_EMPTY = "";
    private static final String GENERIC_ASSEMB_22U = "22U";
    private static final String GENERIC_ASSEMB_EMPTY = "";
    private static final int UNIT_520 = 520;

    @Override
    public PolicyLocation getPropertyPolicyIdentifier() {
        return DEFAULT_POLICY;
    }

    @Test
    public void testGeneric() throws NotFoundException, NoTeamcenterConnectionException {
        log.info("testGeneric ....");
        log.info("GENERIC ID {" + GENERIC_U22 + "} AND GENERIC_ASSEMB {" + GENERIC_ASSEMB_EMPTY + "} EMPTY ");
        Generics generic = new Generics(getProductUnit(), GENERIC_U22, GENERIC_ASSEMB_EMPTY);

        log.info("EXPECTED type {" + generic.getType() + "}");
        log.info("EXPECTED ID {" + generic.getID() + "}");
        log.info("EXPECTED BOM line type {" + generic.getType().getBomLinkType() + "}");
        log.info("EXPECTED getItemID {" + generic.getItem(getSession()).get_item_id() + "}");

    }

    @Test
    public void testGenericAssemb() throws NotFoundException, NoTeamcenterConnectionException {
        log.info("testGenericAssemb ....");
        log.info("GENERIC ID {" + GENERIC_EMPTY + "} EMPTY AND GENERIC_ASSEMB {" + GENERIC_ASSEMB_22U + "}");
        Generics genericAssemb = new Generics(getProductUnit(), GENERIC_EMPTY, GENERIC_ASSEMB_22U);

        log.info("EXPECTED type {" + genericAssemb.getType() + "}");
        log.info("EXPECTED ID {" + genericAssemb.getID() + "}");
        log.info("EXPECTED BOM line type {" + genericAssemb.getType().getBomLinkType() + "}");
        log.info("EXPECTED getItemID {" + genericAssemb.getItem(getSession()).get_item_id() + "}");
    }


    private ProductUnit getProductUnit() {
        return new ProductUnit(PRODUCT_97R0, UNIT_520);
    }

}
