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.strong.ItemRevision;
import com.teamcenter.soa.client.model.strong.User;
import org.junit.Assert;
import org.junit.Test;


public class SnecmaUserTest 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 userObject = (User) result.get_owning_user();
        Assert.assertNotNull(userObject);

        SnecmaUser user = new SnecmaUser(getSession(), userObject);
        Assert.assertNotNull(user);
        Assert.assertEquals("sp0mig11", user.getUserId());
        Assert.assertEquals("sp0mig11", user.getName());
        Assert.assertNotNull(user.getPerson());
    }

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