package jalf.type;

import static org.junit.Assert.*;
import static jalf.test.fixtures.SuppliersAndParts.*;
import jalf.*;
import static jalf.DSL.*;

import org.junit.Test;

public class TestRelationType {

    RelationType type = RelationType.varargs(SID, String.class);

    @Test
    public void testEquals() {
        // it is equal to itself
        assertTrue(type.equals(type));
        // it is equal to an equivalent
        assertTrue(type.equals(RelationType.varargs(SID, String.class)));
        // it is not equal to another ones
        assertFalse(type.equals(RelationType.varargs()));
        assertFalse(type.equals(RelationType.varargs(SID, String.class, STATUS, Integer.class)));
        assertFalse(type.equals(RelationType.varargs(SID, Integer.class)));
        assertFalse(type.equals(RelationType.varargs(NAME, String.class)));
    }

    @Test
    public void testContains() {
        // it contains a proper relation
        Relation r = relation(tuple(SID, "S1"));
        assertTrue(type.contains(r));

        // it does not contain a non relation
        assertFalse(type.contains(null));
        assertFalse(type.contains(12));
        assertFalse(type.contains(Tuple.varargs(SID, 12)));

        // it does not contain a relation of another type
        r = relation(heading());
        assertFalse(type.contains(r));
        r = relation(tuple(SID, 12));
        assertFalse(type.contains(r));
        r = relation(tuple(SID, "S1", STATUS, 12));
        assertFalse(type.contains(r));
    }

}

@@ -262,24 +262,238 @@
 ng.class);%0A%0A
+    @Test%0A    public void testInfer() %7B%0A        Relation suppliers = suppliers();%0A        RelationType inferred = RelationType.infer(suppliers.stream());%0A        assertEquals(suppliers.getType(), inferred);%0A    %7D%0A%0A
     @Test%0A  
@@ -1731,10 +1731,627 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testProject() %7B%0A        RelationType from = RelationType.varargs(SID, String.class, STATUS, Integer.class);%0A        RelationType actual = from.project(attrs(SID));%0A        RelationType expected = type;%0A        assertEquals(expected, actual);%0A    %7D%0A%0A    @Test%0A    public void testRename() %7B%0A        RelationType from = RelationType.varargs(SID, String.class, STATUS, Integer.class);%0A        RelationType expected = RelationType.varargs(NAME, String.class, STATUS, Integer.class);;%0A        RelationType actual = from.rename(renaming(SID, NAME));%0A        assertEquals(expected, actual);%0A    %7D%0A%0A
 %7D%0A

Add a few unit tests on RelationType.