package com.capgemini.reports;

import com.capgemini.framework.teamcenter.object.types.SnecmaObjectTypes;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;


@Slf4j
public class TeamcenterTypeObjectsTest {


  @Test
    public void testIsPart() {
        log.info("Testing pattern: '{}'", SnecmaObjectTypes.PART_REVISION_PATTERN.pattern());

        // Success
        Assert.assertTrue(SnecmaObjectTypes.isPartRevision("Alternate Revision"));
        Assert.assertTrue(SnecmaObjectTypes.isPartRevision("DET Revision"));
        Assert.assertTrue(SnecmaObjectTypes.isPartRevision("Part Aero Revision"));
        Assert.assertTrue(SnecmaObjectTypes.isPartRevision("Part Assemb Revision"));
        Assert.assertTrue(SnecmaObjectTypes.isPartRevision("Part Mat Revision"));
        Assert.assertTrue(SnecmaObjectTypes.isPartRevision("Part No Aero Revision"));
        Assert.assertTrue(SnecmaObjectTypes.isPartRevision("Standard Revision"));

        // Fails
        Assert.assertFalse(SnecmaObjectTypes.isPartRevision(SnecmaObjectTypes.GENERIC_REVISION));
        Assert.assertFalse(SnecmaObjectTypes.isPartRevision("Altrnate Revision")); // misspelled on purpose
        Assert.assertFalse(SnecmaObjectTypes.isPartRevision("Alternate")); // Item
        Assert.assertFalse(SnecmaObjectTypes.isPartRevision("Alternate Revision Master")); // Master
    }


  @Test
    public void testIsAltOrDet() {
        log.info("Testing pattern: '{}'", SnecmaObjectTypes.ALT_OR_DET_PATTERN.pattern());

        // Success
        Assert.assertTrue(SnecmaObjectTypes.isAltOrDet("Alternate Revision"));
        Assert.assertTrue(SnecmaObjectTypes.isAltOrDet("DET Revision"));

        // Fails
        Assert.assertFalse(SnecmaObjectTypes.isAltOrDet("Part Aero Revision"));
        Assert.assertFalse(SnecmaObjectTypes.isAltOrDet("Part Assemb Revision"));
        Assert.assertFalse(SnecmaObjectTypes.isAltOrDet("Part Mat Revision"));
        Assert.assertFalse(SnecmaObjectTypes.isAltOrDet("Part No Aero Revision"));
        Assert.assertFalse(SnecmaObjectTypes.isAltOrDet("Standard Revision"));
        Assert.assertFalse(SnecmaObjectTypes.isAltOrDet(SnecmaObjectTypes.GENERIC_REVISION));
        Assert.assertFalse(SnecmaObjectTypes.isAltOrDet("Altrnate Revision")); // misspelled on purpose
        Assert.assertFalse(SnecmaObjectTypes.isAltOrDet("Alternate")); // Item
        Assert.assertFalse(SnecmaObjectTypes.isAltOrDet("Alternate Revision Master")); // Master
    }


  @Test
    public void testIsA() {
        log.info("Testing pattern: '{}'", SnecmaObjectTypes.PART_REVISION_PATTERN.pattern());

        // Success
        Assert.assertTrue(SnecmaObjectTypes.isA("Alternate Revision", SnecmaObjectTypes.ALTERNATE_REVISION));
        Assert.assertTrue(SnecmaObjectTypes.isA("Alternate Revision", SnecmaObjectTypes.ALTERNATE_REVISION,
                SnecmaObjectTypes.PART_AERO_REVISION, SnecmaObjectTypes.PART_NO_AERO_REVISION, SnecmaObjectTypes.PART_ASSEMB_REVISION,
                SnecmaObjectTypes.PART_MAT_REVISION, SnecmaObjectTypes.DET_REVISION, SnecmaObjectTypes.STANDARD_REVISION));
        Assert.assertTrue(SnecmaObjectTypes.isA("Part Aero Revision", SnecmaObjectTypes.ALTERNATE_REVISION,
                SnecmaObjectTypes.PART_AERO_REVISION, SnecmaObjectTypes.PART_NO_AERO_REVISION, SnecmaObjectTypes.PART_ASSEMB_REVISION,
                SnecmaObjectTypes.PART_MAT_REVISION, SnecmaObjectTypes.DET_REVISION, SnecmaObjectTypes.STANDARD_REVISION));

        // Fails
        Assert.assertFalse(SnecmaObjectTypes.isA("Altrnate Revision", SnecmaObjectTypes.ALTERNATE_REVISION)); // misspelled on purpose
        Assert.assertFalse(SnecmaObjectTypes.isA("Alternate Revision Master", SnecmaObjectTypes.ALTERNATE_REVISION)); // master
        Assert.assertFalse(SnecmaObjectTypes.isA("Alternate Master", SnecmaObjectTypes.ALTERNATE_REVISION)); // master
        Assert.assertFalse(SnecmaObjectTypes.isA("Alternate", SnecmaObjectTypes.ALTERNATE_REVISION)); // item
        Assert.assertFalse(SnecmaObjectTypes.isA("Alternate Revision", SnecmaObjectTypes.PART_AERO_REVISION,
                SnecmaObjectTypes.PART_NO_AERO_REVISION, SnecmaObjectTypes.PART_ASSEMB_REVISION, SnecmaObjectTypes.PART_MAT_REVISION,
                SnecmaObjectTypes.DET_REVISION, SnecmaObjectTypes.STANDARD_REVISION)); // alt is not there
    }

}
