public void testJoinTableMoveJoinColumn2() throws Exception { ICompilationUnit cu = this.createTestAssociationOverrideJoinTableWithJoinColumns(); JavaResourceType resourceType = buildJavaResourceType(cu); AssociationOverrideAnnotation2_0 associationOverride = this.associationOverrideAt(0, resourceType); JoinTableAnnotation table = associationOverride.getJoinTable(); JoinColumnAnnotation joinColumn = table.joinColumnAt(0); joinColumn.setReferencedColumnName("REF_NAME"); joinColumn.setUnique(Boolean.FALSE); joinColumn.setNullable(Boolean.FALSE); joinColumn.setInsertable(Boolean.FALSE); joinColumn.setUpdatable(Boolean.FALSE); joinColumn.setColumnDefinition("COLUMN_DEF"); joinColumn.setTable("TABLE"); table.addJoinColumn(0).setName("FOO"); assertSourceContains( "@AssociationOverride(name = \"" + ASSOCIATION_OVERRIDE_NAME + "\", joinTable = @JoinTable(joinColumns = {@JoinColumn(name = \"FOO\"), @JoinColumn(name = \"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn}))", cu); table.moveJoinColumn(0, 2); assertNull(table.joinColumnAt(0).getName()); assertEquals("FOO", table.joinColumnAt(1).getName()); assertEquals("BAR", table.joinColumnAt(2).getName()); assertEquals(3, table.getJoinColumnsSize()); assertSourceContains( "@AssociationOverride(name = \"" + ASSOCIATION_OVERRIDE_NAME + "\", joinTable = @JoinTable(joinColumns = {@JoinColumn, @JoinColumn(name = \"FOO\"), @JoinColumn(name = \"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\")}))", cu); }
public void testJoinTableSetJoinColumnName() throws Exception { ICompilationUnit cu = this.createTestAssociationOverrideJoinTableWithJoinColumns(); JavaResourceType resourceType = buildJavaResourceType(cu); AssociationOverrideAnnotation2_0 associationOverride = this.associationOverrideAt(0, resourceType); JoinTableAnnotation table = associationOverride.getJoinTable(); assertEquals(2, table.getJoinColumnsSize()); JoinColumnAnnotation joinColumn = table.joinColumnAt(0); assertEquals("BAR", joinColumn.getName()); joinColumn.setName("foo"); assertEquals("foo", joinColumn.getName()); assertSourceContains( "@AssociationOverride(name = \"" + ASSOCIATION_OVERRIDE_NAME + "\", joinTable = @JoinTable(joinColumns = {@JoinColumn(name = \"foo\"), @JoinColumn}))", cu); }