-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Recurse through @DeepPlanningCloned classes to discover all @Dee…
…pPlanningCloned classes (#1237) The `GizmoSolutionClonerImplementor` requires a set of all `@DeepPlanningCloned` classes so it can create cloners for all of them. `GizmoCloningUtils.getDeepClonedClasses` incorrectly assume all `@DeepPlanningCloned classes` are directly accessible from either the `@PlanningSolution` class or an `@PlanningEntity` class. However, a `@DeepPlanningCloned` class might be referenced from another `@DeepPlanningCloned` class, which would not be detected. In order to detect all `@DeepPlanningCloned` classes, when a class that is `@DeepPlanningCloned` is found and was not processed yet, it is added to the to process queue. Fixes #1208.
- Loading branch information
1 parent
ee760ca
commit 28201ef
Showing
7 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...java/ai/timefold/solver/core/impl/domain/solution/cloner/gizmo/GizmoCloningUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ai.timefold.solver.core.impl.domain.solution.cloner.gizmo; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import ai.timefold.solver.core.impl.testdata.domain.clone.deepcloning.AnnotatedTestdataVariousTypes; | ||
import ai.timefold.solver.core.impl.testdata.domain.clone.deepcloning.ExtraDeepClonedObject; | ||
import ai.timefold.solver.core.impl.testdata.domain.clone.deepcloning.TestdataDeepCloningEntity; | ||
import ai.timefold.solver.core.impl.testdata.domain.clone.deepcloning.TestdataVariousTypes; | ||
import ai.timefold.solver.core.impl.testdata.domain.clone.deepcloning.field.TestdataFieldAnnotatedDeepCloningEntity; | ||
import ai.timefold.solver.core.impl.testdata.domain.clone.deepcloning.field.TestdataFieldAnnotatedDeepCloningSolution; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class GizmoCloningUtilsTest { | ||
|
||
@Test | ||
void getDeepClonedClasses() { | ||
assertThat(GizmoCloningUtils.getDeepClonedClasses( | ||
TestdataFieldAnnotatedDeepCloningSolution.buildSolutionDescriptor(), | ||
List.of(TestdataDeepCloningEntity.class))) | ||
.containsExactlyInAnyOrder( | ||
TestdataDeepCloningEntity.class, | ||
ExtraDeepClonedObject.class, | ||
TestdataFieldAnnotatedDeepCloningEntity.class, | ||
AnnotatedTestdataVariousTypes.class, | ||
TestdataFieldAnnotatedDeepCloningSolution.class, | ||
TestdataVariousTypes.class, | ||
List.class, | ||
Map.class); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ai/timefold/solver/core/impl/testdata/domain/clone/deepcloning/ExtraDeepClonedObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ai.timefold.solver.core.impl.testdata.domain.clone.deepcloning; | ||
|
||
import ai.timefold.solver.core.api.domain.solution.cloner.DeepPlanningClone; | ||
|
||
@DeepPlanningClone | ||
public class ExtraDeepClonedObject { | ||
public String id; | ||
|
||
public ExtraDeepClonedObject() { | ||
} | ||
|
||
public ExtraDeepClonedObject(String id) { | ||
this.id = id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters