Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Feb 6, 2024
1 parent 0f9514a commit cad52b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions generators/base-application/support/prepare-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,9 @@ function preparePostEntityCommonDerivedPropertiesNotTyped(entity: any) {
entity.persistableOtherEntities = Object.values(relationshipsByOtherEntity).filter(relationships =>
relationships.some(({ persistableRelationship, otherEntity }) => persistableRelationship && otherEntity !== entity),
);
entity.requiredOtherEntities = Object.values(relationshipsByOtherEntity)
.filter(relationships => relationships.some(({ relationshipRequired, id }) => relationshipRequired || id))
.map(relationships => relationships[0].otherEntity);

entity.anyPropertyHasValidation = entity.anyPropertyHasValidation || fields.some(({ fieldValidate }) => fieldValidate);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package <%= entityAbsolutePackage %>.domain;

import <%= entityAbsolutePackage %>.repository.<%= entityClass %>Repository;
<%_ for (const otherEntity of requiredOtherEntities) { _%>
import <%= otherEntity.entityAbsolutePackage %>.domain.<%= otherEntity.persistClass %>IntegrationTestSamplesBuilder;
<%_ } _%>
<%_ if (entityAbsolutePackage !== packageName) { _%>
import <%= packageName %>.domain.IntegrationTestSample;
<%_ } _%>
import java.util.ArrayList;
import java.util.Collections;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
Expand All @@ -20,9 +24,13 @@ public class <%= persistClass %>IntegrationTestSamplesBuilder {
var tearDownCallbacks = new ArrayList<IntegrationTestSample<?>>();
<%_ for (const relationship of relationships.filter(relationship => relationship.relationshipRequired)) { _%>

IntegrationTestSample<<%- relationship.otherEntity.persistClass %>> <%- relationship.relationshipName %>IntegrationTestSample = <%- relationship.otherEntity.persistClass %>TestSamplesBuilder.build<%= relationship.otherEntity.persistClass %>IntegrationTestSample(applicationContext);
IntegrationTestSample<<%- relationship.otherEntity.persistClass %>> <%- relationship.relationshipName %>IntegrationTestSample = <%- relationship.otherEntity.persistClass %>IntegrationTestSamplesBuilder.build<%= relationship.otherEntity.persistClass %>IntegrationTestSample(applicationContext);
tearDownCallbacks.add(<%- relationship.relationshipName %>IntegrationTestSample);
<%_ if (relationship.collection) { _%>
insertable.set<%- relationship.propertyJavaBeanName %>(<%- relationship.relationshipName %>IntegrationTestSample.insert());
<%_ } else { _%>
insertable.set<%- relationship.propertyJavaBeanName %>(Collections.asSet(<%- relationship.relationshipName %>IntegrationTestSample.insert()));
<%_ } _%>
<%_ } _%>

Supplier<<%= persistClass %>> insertCallback = () -> {
Expand Down

0 comments on commit cad52b3

Please sign in to comment.