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.ProductUnit;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;

/**
 * JUnit test class.
 */
@Slf4j
public class ProductUnitCheckTest extends AbstractTeamcenterTest {

    private static final String PRODUCT_ID_FOR_GENERIC_ASSEMB = "97R0";
    private static final String UNIT_FOR_GENERIC_ASSEMB_STR = "520";
    private static final int UNIT_FOR_GENERIC_ASSEMB = 520;

    @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 existence of product Id=" + PRODUCT_ID_FOR_GENERIC_ASSEMB);
        ProductUnit productUnit = new ProductUnit(PRODUCT_ID_FOR_GENERIC_ASSEMB, UNIT_FOR_GENERIC_ASSEMB_STR);
        new ProductUnitChecker(productUnit).check(getSession());
        Assert.assertEquals(UNIT_FOR_GENERIC_ASSEMB, productUnit.getUnit());
    }
}
