package com.capgemini.reports.teamcenter.queries.saved;

import com.capgemini.framework.teamcenter.exceptions.NoTeamcenterConnectionException;
import com.capgemini.framework.teamcenter.policies.PolicyLocation;
import com.capgemini.reports.AbstractTeamcenterTest;
import com.teamcenter.soa.client.model.strong.ItemRevision;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;

import java.util.List;

@Slf4j
public class AllSequencesQueryTest extends AbstractTeamcenterTest {

    @Test
    public void testSearchAllSequancesOfItem() throws NoTeamcenterConnectionException {
        AllSequencesOfItemQuery query = new AllSequencesOfItemQuery(getSession());
        query.searchID("002603");
        List<ItemRevision> result = query.findAll();

        Assert.assertEquals("Check itemRevision existence", result.isEmpty(), false);
        log.info("Query has found {} itemRevision(s)", result.size());

        for (ItemRevision itemRevision : result) {
            log.info("--> found " + itemRevision.get_item_id() + "/" + itemRevision.get_item_revision_id() + "." + itemRevision.get_sequence_id());
        }
    }

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

}
