Skip to content

Commit 484bee7

Browse files
committed
Refactor updater factory and add combined evaluation assertions
1 parent c26a34e commit 484bee7

38 files changed

Lines changed: 1243 additions & 709 deletions

‎ref-code-adaptation/REQUIREMENTS.md‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,39 +50,41 @@ Last updated: 15.06.2026
5050
be injectable through the `adapt` entry point so Spoon can be replaced by
5151
another updater implementation without changing the adapter orchestration.
5252
- Implemented: [ ]
53-
- Addressed: [ ]
54-
- Notes: Spoon remains the default implementation, but callers should be able
55-
to provide an updater through an interface-based parameter.
53+
- Addressed: [x]
54+
- Notes: Spoon remains the default implementation. `CodeAdapter` now accepts a
55+
`CodeUpdaterFactory` through its `adapt` entry points, and every isolated
56+
mapping/incarnation run receives a fresh updater instance.
5657

57-
- [ ] R-006: Document evaluation test cases
58+
- [x] R-006: Document evaluation test cases
5859
- Source/date: 15.06.2026
5960
- Details: Add `evaluation.md` documentation that explains the purpose,
60-
inputs, mappings, expected behavior, and known limitations of the evaluation
61-
test cases.
62-
- Implemented: [ ]
63-
- Addressed: [ ]
64-
- Notes: The documentation should include testcase 1 and explain why it is
65-
currently expected to report an error.
61+
inputs, mappings, expected behavior of all testcases in the codeAdaptation resources, that are not in the subdirectories (13 test classes).
62+
- Implemented: [x]
63+
- Addressed: [x]
64+
- Notes: `evaluation.md` documents the 13 numbered evaluation resource cases.
65+
Testcase 1 is documented with the current post-R-007 behavior: it is
66+
expected to run successfully, not report the former association-role
67+
conflict.
6668

67-
- [ ] R-007: Make evaluation testcase 1 functional
69+
- [x] R-007: Make evaluation testcase 1 functional
6870
- Source/date: 15.06.2026
6971
- Details: Testcase 1 should be converted from an error-only expectation into
7072
a functioning evaluation test case, or the underlying modeling/adaptation
7173
conflict should be resolved so the case can run successfully.
72-
- Implemented: [ ]
73-
- Addressed: [ ]
74+
- Implemented: [x]
75+
- Addressed: [x]
7476
- Notes: Current analysis target: testcase 1 reports an association-role field
7577
conflict because role-derived fields from the Observer/Observable mappings
7678
are ambiguous for the manual adaptation path.
7779

78-
- [ ] R-008: Introduce a central CD lookup/index structure
80+
- [x] R-008: Introduce a central CD lookup/index structure
7981
- Source/date: 15.06.2026
8082
- Details: Add a central class or data structure, comparable to the
8183
preprocessing/index approach in cd4analysis, that traverses each class
8284
diagram AST once and stores frequently used type/member relationships in
8385
maps.
84-
- Implemented: [ ]
85-
- Addressed: [ ]
86+
- Implemented: [x]
87+
- Addressed: [x]
8688
- Notes: Adaptation code should look up CD types, attributes, methods, and
8789
associations from this index instead of repeatedly iterating the whole AST
8890
or resolving through utility methods such as `CDUtil`/`CDDiffUtil` at every

‎ref-code-adaptation/evaluation.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Ref-Code-Adaptation Evaluation Cases
2+
3+
This document describes the numbered evaluation resources under
4+
`src/test/resources/de/monticore/codeAdaption/evaluation`. Each case contains a
5+
reference CD, a concrete CD, and either adapter handwritten code, concrete
6+
handwritten code, or both.
7+
8+
## Case Overview
9+
10+
| Case | Purpose | Inputs | Mappings | Expected behavior | Test coverage |
11+
| --- | --- | --- | --- | --- | --- |
12+
| `testcase_1` | University/user-role case with two mappings over shared concrete types. | `Reference.cd`, `Concrete.cd`, `reference/` | `stud`, `prof` | Adapts both mappings successfully. The former association-role conflict is resolved by treating roles as generated fields owned by the opposite association side. | `CodeAdapterTestCase1` |
13+
| `testcase_2_cd4code` | CD4Code user-role case with generated follow-up code. | `Reference.cd`, `Concrete.cd`, `hwc/` | `stud` | Adapts the reference handwritten code to `Student`/`HiwiRole` and then runs Java generation for the concrete CD. | `CodeAdapterTestCase2a` |
14+
| `testcase_6_builder_pattern` | Builder pattern expansion for multiple concrete target types. | `Reference.cd`, `Concrete.cd`, `adapter/`, `concrete/` | `buildPat` | Creates `PersonBuilder` and `TaskBuilder`, adapts setters/build methods, and keeps existing concrete classes. | `BuilderPatternAdapterTest` |
15+
| `testcase_7_controller_worker_observer` | Combined builder and observer adaptation where workers are observers. | `Reference.cd`, `Concrete.cd`, `adapter/`, `concrete/` | `buildPat`, `observer` | Generates/adapts controller and worker builder/observer code while preserving concrete worker classes. | `ControllerWorkerAdapterTest` |
16+
| `testcase_8_controller_worker_observer_reversed` | Variant of controller/worker observer adaptation with reversed observer modelling. | `Reference.cd`, `Concrete.cd`, `adapter/`, `concrete/` | `buildPat`, `observer` | Adapts the same pattern combination when the observer interface/class relation is represented differently. | `ControllerWorkerAdapterReversedTest` |
17+
| `testcase_9_strategy_pattern` | Strategy pattern adaptation. | `Reference.cd`, `Concrete.cd`, `adapter/`, `concrete/` | `strategy` | Adapts context and strategy types/methods to payment processing classes and strategies. | `StrategyAdapterTest` |
18+
| `testcase_10_singleton_pattern` | Singleton pattern adaptation for multiple concrete singleton classes. | `Reference.cd`, `Concrete.cd`, `adapter/`, `concrete/` | `singleton` | Produces singleton-style code for `DatabaseConnection` and `Logger` and preserves the application code. | `SingletonAdapterTest` |
19+
| `testcase_11_template_method_pattern` | Template method adaptation with several concrete processors. | `Reference.cd`, `Concrete.cd`, `adapter/`, `concrete/` | `template` | Adapts the abstract template and concrete processor methods for CSV, JSON, and XML processors. | `TemplateMethodAdapterTest` |
20+
| `testcase_12_strategy_singleton_pattern` | Combined singleton and strategy adaptation. | `Reference.cd`, `Concrete.cd`, `adapter/`, `concrete/` | `singleton`, `strategy` | Adapts configuration manager singleton behavior and storage strategy variants. | `StrategySingletonAdapterTest` |
21+
| `testcase_13_template_observer_pattern` | Combined template method and observer adaptation. | `Reference.cd`, `Concrete.cd`, `adapter/`, `concrete/` | `template`, `observer` | Adapts data pipeline template methods and observer notification/update code. | `TemplateObserverAdapterTest` |
22+
| `testcase_14_adapter_factory_combined` | Combined adapter and factory pattern resource case. | `Reference.cd`, `Concrete.cd`, `adapter/`, `concrete/` | `adapter`, `factory` | Adapts a shipping port/carrier adapter with factory creation. | `CombinedPatternEvaluationTest` |
23+
| `testcase_15_composite_decorator_combined` | Combined composite and decorator pattern resource case. | `Reference.cd`, `Concrete.cd`, `adapter/`, `concrete/` | `composite`, `decorator` | Adapts renderable components, groups, and decorators. | `CombinedPatternEvaluationTest` |
24+
| `testcase_16_observer_command_combined` | Combined observer and command pattern resource case. | `Reference.cd`, `Concrete.cd`, `adapter/`, `concrete/` | `observer`, `command` | Adapts event bus observers that are also workflow commands and a command queue invoker. | `CombinedPatternEvaluationTest` |
25+
26+
## Notes
27+
28+
- Cases 6 through 13 are covered by pattern-focused JUnit tests in the main
29+
`de.monticore.codeAdaption` test package.
30+
- Cases 14 through 16 are covered by executable wrappers in
31+
`CombinedPatternEvaluationTest`.

0 commit comments

Comments
 (0)