package dst.ass1.jpa.tests;

import static org.junit.Assert.assertTrue;

import org.junit.Rule;
import org.junit.Test;

import dst.ass1.jpa.ORMService;
import dst.ass1.jpa.util.Constants;

/**
 * Tests the ICoursePlatform name unique constraint.
 */
public class Ass1_1_1_02Test {

    @Rule
    public ORMService orm = new ORMService();

    @Test
    public void testConstraint() {
        new UniqueConstraintTester<>(() -> orm.getModelFactory().createCoursePlatform(), e -> e.setName("uniquevalue"))
                .run(orm.getEntityManager());
    }

    @Test
    public void testConstraintJdbc() {
        assertTrue(orm.getDatabaseGateway().isIndex(Constants.T_COURSEPLATFORM, Constants.M_COURSEPLATFORM_NAME, false));
        assertTrue(orm.getDatabaseGateway().isNullable(Constants.T_COURSEPLATFORM, Constants.M_COURSEPLATFORM_NAME));
    }

}
