package com.capgemini.reports.users;

import com.capgemini.framework.teamcenter.exceptions.NoTeamcenterConnectionException;
import com.capgemini.framework.teamcenter.policies.PolicyLocation;
import com.capgemini.framework.teamcenter.queries.saved.modelobject.ItemRevisionQuery;
import com.capgemini.reports.AbstractTeamcenterTest;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.strong.ItemRevision;
import com.teamcenter.soa.client.model.strong.Person;
import com.teamcenter.soa.client.model.strong.User;
import org.junit.Assert;
import org.junit.Test;


public class SnecmaPersonTest extends AbstractTeamcenterTest {

    /**
     * JUnit test.
     * @throws NoTeamcenterConnectionException Should not happen
     */
    @Test
    public void testBuild() throws NoTeamcenterConnectionException {
        ItemRevision result = new ItemRevisionQuery(getSession()).searchIDAndRevision("INITB0204", "A").findAll().get(0);
        Assert.assertNotNull(result);

        User user = (User) result.get_owning_user();
        Assert.assertNotNull(user);

        ModelObject personObject = user.get_person();
        Assert.assertNotNull(personObject);

        SnecmaPerson person = new SnecmaPerson((Person) personObject);
        Assert.assertNotNull(person);
        Assert.assertEquals("sp0mig11", person.getPersonName());
    }

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