Skip to content

Commit

Permalink
entity changelog fixes 4
Browse files Browse the repository at this point in the history
  • Loading branch information
seed-master committed Sep 26, 2023
1 parent a14b70f commit 81abde8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ private void addRelationConstraints(EntityRelation relation) {
addJoinConstraintChange.setBaseTableName(getTableName(relation, false));
addJoinConstraintChange.setBaseColumnNames(relation.getJoinColumnName());
addJoinConstraintChange.setReferencedColumnNames(SystemField.ID.columName);
addJoinConstraintChange.setReferencedTableName(relation.getEntity().getEffectiveTableName());
addJoinConstraintChange.setReferencedTableName(relation.getEntityTableName());
addChange(addJoinConstraintChange);

// inverse join column fk
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/org/seed/core/entity/EntityRelation.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,28 +162,28 @@ public EntityRelation createDescendantRelation(Entity descendantEntity) {
return createRelation(descendantEntity, relatedEntity);
}

void setDerivedEntity(Entity derivedEntity) {
this.derivedEntity = derivedEntity;
}

private Entity getDerivedEntity() {
Assert.stateAvailable(derivedEntity, "derived entity");

return derivedEntity;
}

boolean isEntityAudited() {
return entity.isGeneric()
? getDerivedEntity().isAudited()
: entity.isAudited();
}

private String getEntityTableName() {
String getEntityTableName() {
return entity.isGeneric()
? getDerivedEntity().getEffectiveTableName()
: entity.getEffectiveTableName();
}

void setDerivedEntity(Entity derivedEntity) {
this.derivedEntity = derivedEntity;
}

private Entity getDerivedEntity() {
Assert.stateAvailable(derivedEntity, "derived entity");

return derivedEntity;
}

private static EntityRelation createRelation(Entity entity, Entity relatedEntity) {
final var relation = new EntityRelation();
relation.setEntity(entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,18 @@ void testAddFieldConstraint() {
saveEntity(tabpanel);
}

@Test
@Order(6)
void testAddRelation() {
WebElement tabpanel = showEntity("generictest");
assertEquals("Beziehungen", findTab(tabpanel, "relations").getText());
clickTab(tabpanel, "relations");
WebElement tabpanelRelations = findTabpanel(tabpanel, "relations");
clickButton(tabpanelRelations, "new");

findOptionCombobox(tabpanelRelations, "relationentity").sendKeys("TransferableTest");
clickTab(tabpanel, "relations"); // lose focus
saveEntity(tabpanel);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ void testRemoveFieldGroup() {

@Test
@Order(12)
void testRemoveGenericRelation() {
WebElement tabpanel = showEntity("generictest");
assertEquals("Entitäten: GenericTest", findTab("entitaeten").getText());
clickTab(tabpanel, "relations");
WebElement tabpanelRelations = findTabpanel(tabpanel, "relations");
clickListItem(tabpanelRelations, "transferabletest");
clickButton(tabpanelRelations, "remove");
saveEntity(tabpanel);
}

@Test
@Order(13)
void testDeleteDerivedEntity() {
WebElement tabpanel = showEntity("derivedtest");
assertEquals("Entitäten: DerivedTest", findTab("entitaeten").getText());
Expand All @@ -178,7 +190,7 @@ void testDeleteDerivedEntity() {
}

@Test
@Order(13)
@Order(14)
void testDeleteGenericEntity() {
WebElement tabpanel = showEntity("generictest");
assertEquals("Entitäten: GenericTest", findTab("entitaeten").getText());
Expand All @@ -190,7 +202,7 @@ void testDeleteGenericEntity() {
}

@Test
@Order(14)
@Order(15)
void testDeleteTransferableEntity() {
WebElement tabpanel = showEntity("transferabletestnew");
assertEquals("Entitäten: TransferableTestNew", findTab("entitaeten").getText());
Expand All @@ -202,7 +214,7 @@ void testDeleteTransferableEntity() {
}

@Test
@Order(15)
@Order(16)
void testDeleteNestedEntity() {
WebElement tabpanel = showEntity("nestedtest");
assertEquals("Entitäten: NestedTest", findTab("entitaeten").getText());
Expand All @@ -214,7 +226,7 @@ void testDeleteNestedEntity() {
}

@Test
@Order(16)
@Order(17)
void testDeleteEntity() {
WebElement tabpanel = showEntity("integrationtest");
assertEquals("Entitäten: IntegrationTest", findTab("entitaeten").getText());
Expand Down

0 comments on commit 81abde8

Please sign in to comment.