public void testAddInverseJoinColumn() throws Exception {
    ICompilationUnit cu = this.createTestAssociationOverrideWithJoinTable();
    JavaResourceType resourceType = buildJavaResourceType(cu);
    AssociationOverrideAnnotation2_0 associationOverride =
        this.associationOverrideAt(0, resourceType);
    JoinTableAnnotation table = associationOverride.getJoinTable();

    table.addInverseJoinColumn(0).setName("FOO");
    table.addInverseJoinColumn(1);
    table.addInverseJoinColumn(0).setName("BAR");

    assertEquals("BAR", table.inverseJoinColumnAt(0).getName());
    assertEquals("FOO", table.inverseJoinColumnAt(1).getName());
    assertNull(table.inverseJoinColumnAt(2).getName());
    assertSourceContains(
        "@AssociationOverride(name = \""
            + ASSOCIATION_OVERRIDE_NAME
            + "\", joinTable = @JoinTable(name = \"MY_JOIN_TABLE\", inverseJoinColumns = {@JoinColumn(name = \"BAR\"),@JoinColumn(name = \"FOO\"), @JoinColumn}))",
        cu);
  }
  public void testJoinTableSetInverseJoinColumnName() throws Exception {
    ICompilationUnit cu = this.createTestAssociationOverrideJoinTableWithInverseJoinColumns();
    JavaResourceType resourceType = buildJavaResourceType(cu);
    AssociationOverrideAnnotation2_0 associationOverride =
        this.associationOverrideAt(0, resourceType);
    JoinTableAnnotation table = associationOverride.getJoinTable();

    assertEquals(2, table.getInverseJoinColumnsSize());

    JoinColumnAnnotation joinColumn = table.inverseJoinColumnAt(0);

    assertEquals("BAR", joinColumn.getName());

    joinColumn.setName("foo");
    assertEquals("foo", joinColumn.getName());

    assertSourceContains(
        "@AssociationOverride(name = \""
            + ASSOCIATION_OVERRIDE_NAME
            + "\", joinTable = @JoinTable(inverseJoinColumns = {@JoinColumn(name = \"foo\"), @JoinColumn}))",
        cu);
  }