public void testJoinTableAddUniqueConstraint() throws Exception { ICompilationUnit cu = this.createTestAssociationOverrideWithJoinTable(); JavaResourceType resourceType = buildJavaResourceType(cu); AssociationOverrideAnnotation2_0 associationOverride = this.associationOverrideAt(0, resourceType); JoinTableAnnotation table = associationOverride.getJoinTable(); table.addUniqueConstraint(0).addColumnName("FOO"); table.addUniqueConstraint(1); table.addUniqueConstraint(0).addColumnName("BAR"); assertEquals("BAR", table.uniqueConstraintAt(0).columnNameAt(0)); assertEquals("FOO", table.uniqueConstraintAt(1).columnNameAt(0)); assertEquals(0, table.uniqueConstraintAt(2).getColumnNamesSize()); assertSourceContains( "@AssociationOverride(name = \"" + ASSOCIATION_OVERRIDE_NAME + "\", joinTable = @JoinTable(name = \"MY_JOIN_TABLE\", uniqueConstraints = {@UniqueConstraint(columnNames = \"BAR\"),@UniqueConstraint(columnNames = \"FOO\"), @UniqueConstraint}))", cu); }
public void testJoinTableUniqueConstraints2() throws Exception { ICompilationUnit cu = this.createTestAssociationOverrideWithJoinTable(); JavaResourceType resourceType = buildJavaResourceType(cu); AssociationOverrideAnnotation2_0 associationOverride = this.associationOverrideAt(0, resourceType); JoinTableAnnotation table = associationOverride.getJoinTable(); table.addUniqueConstraint(0); table.addUniqueConstraint(1); assertEquals(2, table.getUniqueConstraintsSize()); }