Skip to content

Commit fe81d75

Browse files
committed
Value Impact Map generator
1 parent e9161d2 commit fe81d75

File tree

12 files changed

+595
-32
lines changed

12 files changed

+595
-32
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ValueRegister SD_Values for SameDayDelivery {
2+
3+
Value WorkLifeBalance {
4+
isCore
5+
demonstrator "Drivers value a healthy work-life-balance"
6+
Stakeholder Drivers {
7+
priority HIGH
8+
impact HIGH
9+
consequences
10+
bad "SDD will harm work-life-balance of drivers"
11+
action "hire more drivers" ACT
12+
}
13+
}
14+
15+
}

org.contextmapper.dsl.tests/src/org/contextmapper/dsl/generators/plantuml/PlantUMLGeneratorTest.java

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ void canCreatePlantUMLDiagramFiles() {
6767

6868
// when
6969
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
70-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
70+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
71+
new IGeneratorContextMock());
7172

7273
// then
7374
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_ContextMap.puml"));
@@ -85,7 +86,8 @@ void canCreateBoundedContextClassDiagramsWithoutContextMap() {
8586

8687
// when
8788
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
88-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
89+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
90+
new IGeneratorContextMock());
8991

9092
// then
9193
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_BC_TestContext.puml"));
@@ -108,7 +110,8 @@ void canCreatePlantUMLDiagrmFiles4SubdomainIfEntitiesAvailable() {
108110

109111
// when
110112
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
111-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
113+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
114+
new IGeneratorContextMock());
112115

113116
// then
114117
assertFalse(filesystem.getGeneratedFilesSet().contains("testmodel_SD_TestSubdomain1.puml"));
@@ -118,100 +121,133 @@ void canCreatePlantUMLDiagrmFiles4SubdomainIfEntitiesAvailable() {
118121
@Test
119122
void canCreateStateDiagram4ApplicationFlowIfAvailable() throws IOException {
120123
// given
121-
ContextMappingModel model = getOriginalResourceOfTestCML("state-diagram-generation-flow-test.cml").getContextMappingModel();
124+
ContextMappingModel model = getOriginalResourceOfTestCML("state-diagram-generation-flow-test.cml")
125+
.getContextMappingModel();
122126

123127
// when
124128
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
125-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
129+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
130+
new IGeneratorContextMock());
126131

127132
// then
128-
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_BC_InsuranceQuotes_QuoteFlow_StateDiagram.puml"));
133+
assertTrue(
134+
filesystem.getGeneratedFilesSet().contains("testmodel_BC_InsuranceQuotes_QuoteFlow_StateDiagram.puml"));
129135
}
130136

131137
@Test
132138
void canCreateClass4AggregateIfAvailable() throws IOException {
133139
// given
134-
ContextMappingModel model = getOriginalResourceOfTestCML("class-diagram-generation-aggregate-test-1.cml").getContextMappingModel();
140+
ContextMappingModel model = getOriginalResourceOfTestCML("class-diagram-generation-aggregate-test-1.cml")
141+
.getContextMappingModel();
135142

136143
// when
137144
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
138-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
145+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
146+
new IGeneratorContextMock());
139147

140148
// then
141149
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_BC_InsuranceQuotes_QuoteRequest.puml"));
142150
}
143-
151+
144152
@Test
145153
void canCreateClass4ModuleIfAvailable() throws IOException {
146154
// given
147-
ContextMappingModel model = getOriginalResourceOfTestCML("class-diagram-generation-module-test-1.cml").getContextMappingModel();
155+
ContextMappingModel model = getOriginalResourceOfTestCML("class-diagram-generation-module-test-1.cml")
156+
.getContextMappingModel();
148157

149158
// when
150159
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
151-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
160+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
161+
new IGeneratorContextMock());
152162

153163
// then
154164
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_BC_InsuranceQuotes_QuoteRequest.puml"));
155165
}
156-
166+
157167
@Test
158168
void canCreateStateDiagram4AggregateIfAvailable() throws IOException {
159169
// given
160-
ContextMappingModel model = getOriginalResourceOfTestCML("state-diagram-generation-aggregate-test-1.cml").getContextMappingModel();
170+
ContextMappingModel model = getOriginalResourceOfTestCML("state-diagram-generation-aggregate-test-1.cml")
171+
.getContextMappingModel();
161172

162173
// when
163174
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
164-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
175+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
176+
new IGeneratorContextMock());
165177

166178
// then
167-
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_BC_InsuranceQuotes_QuoteRequest_StateDiagram.puml"));
179+
assertTrue(filesystem.getGeneratedFilesSet()
180+
.contains("testmodel_BC_InsuranceQuotes_QuoteRequest_StateDiagram.puml"));
168181
}
169-
182+
170183
@Test
171184
void canCreateUseCaseDiagram4UseCasesIfAvailable() throws IOException {
172185
// given
173-
ContextMappingModel model = getOriginalResourceOfTestCML("use-case-diagram-generation-test-1.cml").getContextMappingModel();
186+
ContextMappingModel model = getOriginalResourceOfTestCML("use-case-diagram-generation-test-1.cml")
187+
.getContextMappingModel();
174188

175189
// when
176190
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
177-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
191+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
192+
new IGeneratorContextMock());
178193

179194
// then
180195
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_UseCases.puml"));
181196
}
182-
197+
183198
@Test
184199
void canCreateSequenceDiagram4UseCaseInteractionsIfAvailable() throws IOException {
185200
// given
186-
ContextMappingModel model = getOriginalResourceOfTestCML("use-case-diagram-generation-test-1.cml").getContextMappingModel();
201+
ContextMappingModel model = getOriginalResourceOfTestCML("use-case-diagram-generation-test-1.cml")
202+
.getContextMappingModel();
187203

188204
// when
189205
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
190-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
206+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
207+
new IGeneratorContextMock());
191208

192209
// then
193-
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_UseCase_Get_paid_for_car_accident_Interactions.puml"));
210+
assertTrue(filesystem.getGeneratedFilesSet()
211+
.contains("testmodel_UseCase_Get_paid_for_car_accident_Interactions.puml"));
194212
}
195-
213+
196214
@Test
197215
void canCreateStakeholderDiagramsIfStakeholdersAreAvailable() throws IOException {
198216
// given
199-
ContextMappingModel model = getOriginalResourceOfTestCML("stakeholder-diagram-generation-test-1.cml").getContextMappingModel();
200-
201-
217+
ContextMappingModel model = getOriginalResourceOfTestCML("stakeholder-diagram-generation-test-1.cml")
218+
.getContextMappingModel();
219+
202220
// when
203221
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
204-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
205-
222+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
223+
new IGeneratorContextMock());
224+
206225
// then
207226
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_BC_System-of-Interest_StakeholderMap-1.puml"));
208227
}
209228

229+
@Test
230+
void canCreateValueImpactMapDiagramsIfValueRegistersAreAvailable() throws IOException {
231+
// given
232+
ContextMappingModel model = getOriginalResourceOfTestCML("value-impact-map-diagram-generation-test-1.cml")
233+
.getContextMappingModel();
234+
235+
// when
236+
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
237+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
238+
new IGeneratorContextMock());
239+
240+
// then
241+
assertTrue(
242+
filesystem.getGeneratedFilesSet().contains("testmodel_ValueRegister_SD_Values_Value-Impact-Map.puml"));
243+
}
244+
210245
@Test
211246
void expectExceptionForEmptyResource() {
212247
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
213248
assertThrows(GeneratorInputException.class, () -> {
214-
this.generator.doGenerate(new ContextMappingModelResourceMock(null, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
249+
this.generator.doGenerate(new ContextMappingModelResourceMock(null, "testmodel", "cml"), filesystem,
250+
new IGeneratorContextMock());
215251
});
216252
}
217253

@@ -220,7 +256,8 @@ void expectExceptionForEmptyContextMappingModel() {
220256
ContextMappingModel model = ContextMappingDSLFactory.eINSTANCE.createContextMappingModel();
221257
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
222258
assertThrows(GeneratorInputException.class, () -> {
223-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
259+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
260+
new IGeneratorContextMock());
224261
});
225262
}
226263

@@ -232,7 +269,8 @@ void expectExceptionIfThereIsOnlyAnEmptyDomain() {
232269
model.getDomains().add(emptyDomain);
233270
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
234271
assertThrows(GeneratorInputException.class, () -> {
235-
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
272+
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem,
273+
new IGeneratorContextMock());
236274
});
237275
}
238276

org.contextmapper.dsl/src/org/contextmapper/dsl/generator/PlantUMLGenerator.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.contextmapper.dsl.contextMappingDSL.Stakeholders;
2828
import org.contextmapper.dsl.contextMappingDSL.UseCase;
2929
import org.contextmapper.dsl.contextMappingDSL.UserRequirement;
30+
import org.contextmapper.dsl.contextMappingDSL.ValueRegister;
3031
import org.contextmapper.dsl.generator.exception.GeneratorInputException;
3132
import org.contextmapper.dsl.generator.plantuml.PlantUMLAggregateClassDiagramCreator;
3233
import org.contextmapper.dsl.generator.plantuml.PlantUMLBoundedContextClassDiagramCreator;
@@ -38,6 +39,7 @@
3839
import org.contextmapper.dsl.generator.plantuml.PlantUMLSubdomainClassDiagramCreator;
3940
import org.contextmapper.dsl.generator.plantuml.PlantUMLUseCaseDiagramCreator;
4041
import org.contextmapper.dsl.generator.plantuml.PlantUMLUseCaseInteractionsSequenceDiagramCreator;
42+
import org.contextmapper.dsl.generator.plantuml.PlantUMLValueImpactMapGenerator;
4143
import org.contextmapper.tactic.dsl.tacticdsl.StateTransition;
4244
import org.eclipse.emf.common.util.URI;
4345
import org.eclipse.xtext.EcoreUtil2;
@@ -64,6 +66,7 @@ protected void generateFromContextMappingModel(ContextMappingModel model, IFileS
6466
generateUseCaseDiagram(model, fsa, fileName);
6567
generateSequenceDiagramsForUseCases(model, fsa, fileName);
6668
generateStakeholderDiagrams(model, fsa, fileName);
69+
generateValueImpactMapsForValueRegisters(model, fsa, fileName);
6770
}
6871

6972
private void generateStakeholderDiagrams(ContextMappingModel model, IFileSystemAccess2 fsa, String fileName) {
@@ -78,6 +81,18 @@ private void generateStakeholderDiagrams(ContextMappingModel model, IFileSystemA
7881
}
7982
}
8083

84+
private void generateValueImpactMapsForValueRegisters(ContextMappingModel model, IFileSystemAccess2 fsa,
85+
String fileName) {
86+
for (ValueRegister valueRegister : model.getValueRegisters()) {
87+
if (!(valueRegister.getValueClusters().isEmpty() && valueRegister.getValues().isEmpty())) {
88+
fsa.generateFile(
89+
fileName + "_ValueRegister_" + valueRegister.getName() + "_Value-Impact-Map" + "."
90+
+ PLANT_UML_FILE_EXT,
91+
new PlantUMLValueImpactMapGenerator().createDiagram(valueRegister));
92+
}
93+
}
94+
}
95+
8196
private void generateSequenceDiagramsForUseCases(ContextMappingModel model, IFileSystemAccess2 fsa,
8297
String fileName) {
8398
for (UserRequirement userRequirement : model.getUserRequirements()) {
@@ -155,7 +170,8 @@ private void generateComponentDiagramIfContextMapAvailable(ContextMappingModel m
155170
private void checkPreconditions() {
156171
if (this.contextMappingModel.getMap() == null && this.contextMappingModel.getBoundedContexts().isEmpty()
157172
&& !modelHasSubdomainWithEntities() && this.contextMappingModel.getUserRequirements().isEmpty()
158-
&& this.contextMappingModel.getStakeholders().isEmpty())
173+
&& this.contextMappingModel.getStakeholders().isEmpty()
174+
&& this.contextMappingModel.getValueRegisters().isEmpty())
159175
throw new GeneratorInputException(
160176
"Your model does not contain a) a Context Map, b) Bounded Contexts or Subdomains with domain objects (Entities, Value Objects, etc.), c) Use Cases or User Stories, or d) Stakeholders or Value Registers. Create at least one of the mentioned model elements.");
161177
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2024 The Context Mapper Project Team
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.contextmapper.dsl.generator.plantuml;
17+
18+
import org.contextmapper.dsl.contextMappingDSL.ValueRegister;
19+
import org.contextmapper.dsl.generator.plantuml.value_impact_mapping.CML2ValueImpactModelMapper;
20+
import org.contextmapper.dsl.generator.plantuml.value_impact_mapping.ValueImpactMapPumlTextCreator;
21+
22+
public class PlantUMLValueImpactMapGenerator implements PlantUMLDiagramCreator<ValueRegister> {
23+
24+
@Override
25+
public String createDiagram(ValueRegister valueRegister) {
26+
return new ValueImpactMapPumlTextCreator().createText(new CML2ValueImpactModelMapper().map(valueRegister));
27+
}
28+
29+
}

0 commit comments

Comments
 (0)