public void testJoinTableMoveInverseJoinColumn2() throws Exception { ICompilationUnit cu = this.createTestAssociationOverrideJoinTableWithInverseJoinColumns(); JavaResourceType resourceType = buildJavaResourceType(cu); AssociationOverrideAnnotation2_0 associationOverride = this.associationOverrideAt(0, resourceType); JoinTableAnnotation table = associationOverride.getJoinTable(); table.addInverseJoinColumn(1).setName("FOO"); Iterator<JoinColumnAnnotation> inverseJoinColumns = table.getInverseJoinColumns().iterator(); assertEquals("BAR", inverseJoinColumns.next().getName()); assertEquals("FOO", inverseJoinColumns.next().getName()); assertNull(inverseJoinColumns.next().getName()); table.moveInverseJoinColumn(0, 2); inverseJoinColumns = table.getInverseJoinColumns().iterator(); assertNull(inverseJoinColumns.next().getName()); assertEquals("BAR", inverseJoinColumns.next().getName()); assertEquals("FOO", inverseJoinColumns.next().getName()); assertSourceContains( "@AssociationOverride(name = \"" + ASSOCIATION_OVERRIDE_NAME + "\", joinTable = @JoinTable(inverseJoinColumns = {@JoinColumn, @JoinColumn(name = \"BAR\"), @JoinColumn(name = \"FOO\")}))", cu); }
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 testInverseJoinColumns2() throws Exception { ICompilationUnit cu = this.createTestAssociationOverrideWithJoinTable(); JavaResourceType resourceType = buildJavaResourceType(cu); AssociationOverrideAnnotation2_0 associationOverride = this.associationOverrideAt(0, resourceType); JoinTableAnnotation table = associationOverride.getJoinTable(); table.addInverseJoinColumn(0); table.addInverseJoinColumn(1); assertEquals(2, table.getInverseJoinColumnsSize()); }