package com.capgemini.reports.reports.parameters.checker;

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


@Slf4j
public class GenericExistenceCheckTest extends AbstractTeamcenterTest {

    private static final String PRODUCT_ID_FOR_GENERIC_ASSEMB = "97R0";
    private static final String UNIT_FOR_GENERIC_ASSEMB = "520";
    private static final String GENERIC_ASSEMB_ID = "22U";

    private static final String PRODUCT_ID_FOR_GENERIC = "65A1";
    private static final String GENERIC_ID = "A29";
    private static final String UNIT_FOR_GENERIC = "20";

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

    /**
     * JUnit Test.
     * 
     * @throws InvalidUserInputException should not happen
     * @throws NoTeamcenterConnectionException should not happen
     */
    @Test
    public void checkTest() throws InvalidUserInputException, NoTeamcenterConnectionException {
        log.info("Checking Product-Unit Alone...");
        ProductUnit productUnitAlone = new ProductUnit(PRODUCT_ID_FOR_GENERIC, UNIT_FOR_GENERIC);
        Generics productAlone = new Generics(productUnitAlone, null, null);
        new GenericExistenceChecker(productAlone).check(getSession());
        log.info("         Product-Unit Alone OK");

        log.info("Checking Generic Assemb...");
        ProductUnit productUnitForGenericAssemb = new ProductUnit(PRODUCT_ID_FOR_GENERIC_ASSEMB, UNIT_FOR_GENERIC_ASSEMB);
        Generics genericAssemb = new Generics(productUnitForGenericAssemb, null, GENERIC_ASSEMB_ID);
        new GenericExistenceChecker(genericAssemb).check(getSession());
        log.info("         Generic Assemb OK");

        log.info("Checking Generic...");
        ProductUnit productUnitForGeneric = new ProductUnit(PRODUCT_ID_FOR_GENERIC, UNIT_FOR_GENERIC);
        Generics generic = new Generics(productUnitForGeneric, GENERIC_ID, null);
        new GenericExistenceChecker(generic).check(getSession());
        log.info("         Generic OK");
    }
}
