Skip to content

Commit

Permalink
Some more transformations
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-ka committed Aug 20, 2024
1 parent b43b0db commit c0e9920
Show file tree
Hide file tree
Showing 40 changed files with 1,038 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class DeriveFrontendAndBackendSystemFromFeatureBCActionTest extends AbstractBoun
title : Derive Frontend And Backend System From Feature BC
args :
file://«this.root»/MyModel.cml,TestFeatureContext
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,TestFeatureContext
'''
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class ExtractAggregatesByCohesionActionTest extends AbstractBoundedContextCodeAc
title : Extract Aggregates By Cohesion
args :
file://«this.root»/MyModel.cml,TestContext,TestAggregate1,TestAggregate2
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,TestContext
'''
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class ExtractAggregatesByVolatilityActionTest extends AbstractBoundedContextCode
title : Extract Aggregates By Cohesion
args :
file://«this.root»/MyModel.cml,TestContext,TestAggregate1,TestAggregate2
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,TestContext
'''
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class MergeBoundedContextsActionTest extends AbstractBoundedContextCodeActionTes
title : Merge Bounded Contexts
args :
file://«this.root»/MyModel.cml,TestContext1,TestContext2
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,TestContext1
'''
]
}
Expand All @@ -49,6 +53,10 @@ class MergeBoundedContextsActionTest extends AbstractBoundedContextCodeActionTes
line = 1
column = 12
expectedCodeActions = '''
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,
title : Create a Bounded Context named 'SomeContext'.
kind : quickfix
command :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class SplitBoundedContextByFeaturesActionTest extends AbstractBoundedContextCode
title : Extract Aggregates By Cohesion
args :
file://«this.root»/MyModel.cml,TestContext,TestAggregate1,TestAggregate2
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,TestContext
'''
]
}
Expand All @@ -68,6 +72,10 @@ class SplitBoundedContextByFeaturesActionTest extends AbstractBoundedContextCode
title : Extract Aggregates By Cohesion
args :
file://«this.root»/MyModel.cml,TestContext,TestAggregate1,TestAggregate2
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,TestContext
'''
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class SplitBoundedContextByOwnerActionTest extends AbstractBoundedContextCodeAct
title : Merge Bounded Contexts
args :
file://«this.root»/MyModel.cml,TestContext,Team2,Team1
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,TestContext
'''
]
}
Expand Down Expand Up @@ -76,6 +80,10 @@ class SplitBoundedContextByOwnerActionTest extends AbstractBoundedContextCodeAct
title : Merge Bounded Contexts
args :
file://«this.root»/MyModel.cml,TestContext,Team1
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,TestContext
'''
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class SplitSystemContextIntoSubsystemsActionTest extends AbstractBoundedContextC
title : Split System Context Into Subsystems
args :
file://«this.root»/MyModel.cml,TestSystemContext
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,TestSystemContext
'''
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,43 @@ class UserStoryActionsTest extends AbstractBoundedContextCodeActionTest {
]
}

@Test
def void canOfferAction2CreateStakeholderIfRoleIsDefined() {
testCodeAction [
model = '''
UserStory SampleStory1 {
As a "SampleUserOfFutureSystem"
I want to "manipulate" a "BusinessObject" with its "property1", "property2"
so that "I am more efficient"
}
'''
expectedCodeActions = '''
command : cml.ar.deriveSubdomainFromURs.proxy
title : Derive Subdomain From User Requirements
args :
file://«this.root»/MyModel.cml,SampleStory1
command : cml.ar.addEthicalValueAssessment.proxy
title : Add Ethical Value Assessment
args :
file://«this.root»/MyModel.cml,SampleStory1
command : cml.ar.createStakeholderForUserStoryRole.proxy
title : Create Stakeholder For User Story Role
args :
file://«this.root»/MyModel.cml,SampleStory1
title : Split Story by Verb/Operation
kind : quickfix
command : Command [
title = "Split Story by Verb/Operation"
command = "cml.quickfix.command.splitStoryByVerb.proxy"
arguments = LinkedList (
"file://«this.root»/MyModel.cml",
"SampleStory1"
)
]
codes : split-feature-by-verb-suggestion
edit :
'''
]
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2024 The Context Mapper Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.contextmapper.dsl.ide.tests.commands.refactoring

import com.google.gson.JsonArray
import com.google.gson.JsonPrimitive
import org.contextmapper.dsl.ide.commands.CMLCommandService
import org.contextmapper.dsl.ide.tests.commands.AbstractCMLCommandTest
import org.eclipse.lsp4j.ExecuteCommandParams
import org.junit.jupiter.api.Test

class CreateStakeholderForUserStoryRoleCommandTest extends AbstractCMLCommandTest {

@Test
def void testARCommandExecution() {
// given
initializeCommandsDynamically()
val model = '''
UserStory TestStory {
As a "Tester" I want to "create" an "Test" so that ""
}
'''
val fileURI = 'test.cml'.writeFile(model)

// when
val refactoringParams = new JsonArray
refactoringParams.add("TestStory")
val result = languageServer.executeCommand(
new ExecuteCommandParams("cml.ar.createStakeholderForUserStoryRole",
#[new JsonPrimitive(fileURI), refactoringParams]))
val resultVal = result.get as String

// then
CMLCommandService.COMMAND_EXECUTED_RETURN_VALUE.assertEquals(resultVal)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2024 The Context Mapper Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.contextmapper.dsl.ide.tests.commands.refactoring

import com.google.gson.JsonArray
import com.google.gson.JsonPrimitive
import org.contextmapper.dsl.ide.commands.CMLCommandService
import org.contextmapper.dsl.ide.tests.commands.AbstractCMLCommandTest
import org.eclipse.lsp4j.ExecuteCommandParams
import org.junit.jupiter.api.Test

class CreateValueRegisterForBoundedContextCommandTest extends AbstractCMLCommandTest {

@Test
def void testARCommandExecution() {
// given
initializeCommandsDynamically()
val model = '''
BoundedContext TestContext
'''
val fileURI = 'test.cml'.writeFile(model)

// when
val refactoringParams = new JsonArray
refactoringParams.add("TestContext")
val result = languageServer.executeCommand(
new ExecuteCommandParams("cml.ar.createValueRegisterForBoundedContext",
#[new JsonPrimitive(fileURI), refactoringParams]))
val resultVal = result.get as String

// then
CMLCommandService.COMMAND_EXECUTED_RETURN_VALUE.assertEquals(resultVal)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class ExtractIDValueObjectQuickFixTest extends AbstractCMLLanguageServerTest {
}
'''
expectedCodeActions = '''
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,TestContext
title : Extract Value Object
kind : quickfix
command :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class OpenCoordinationInBPMNSketchMinerActionTest extends AbstractCMLCommandTest
}
'''
expectedCodeActions = '''
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,ContextA
title : Open coordination in BPMN Sketch Miner
kind : quickfix
command : Command [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class OpenFlowInBPMNSketchMinerActionTest extends AbstractCMLCommandTest {
}
'''
expectedCodeActions = '''
command : cml.ar.createValueRegisterForBoundedContext.proxy
title : Create Value Register For Bounded Context
args :
file://«this.root»/MyModel.cml,ContextA
title : Open flow in BPMN Sketch Miner
kind : quickfix
command : Command [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class SplitStoryByVerbQuickFixTest extends AbstractCMLCommandTest {
file://«this.root»/MyModel.cml,TestStory
command : cml.ar.addEthicalValueAssessment.proxy
title : Add Ethical Value Assessment
args :
file://«this.root»/MyModel.cml,TestStory
command : cml.ar.createStakeholderForUserStoryRole.proxy
title : Create Stakeholder For User Story Role
args :
file://«this.root»/MyModel.cml,TestStory
title : Split Story by Verb/Operation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 The Context Mapper Project Team
* Copyright 2020-2024 The Context Mapper Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,9 @@
import org.contextmapper.dsl.cml.CMLResource;
import org.contextmapper.dsl.exception.ContextMapperApplicationException;
import org.contextmapper.dsl.ide.actions.impl.AddEthicalValueAssessmentAction;
import org.contextmapper.dsl.ide.actions.impl.CreateStakeholderForUserStoryRoleAction;
import org.contextmapper.dsl.ide.actions.impl.CreateValue4StakeholderAction;
import org.contextmapper.dsl.ide.actions.impl.CreateValueRegisterForBoundedContextAction;
import org.contextmapper.dsl.ide.actions.impl.DeriveBoundedContextFromSubdomainsAction;
import org.contextmapper.dsl.ide.actions.impl.DeriveFrontendAndBackendFromFeatureBCAction;
import org.contextmapper.dsl.ide.actions.impl.DeriveSubdomainFromUserRequirementsAction;
Expand Down Expand Up @@ -118,6 +120,8 @@ private List<CMLCodeAction> getAllActions(CMLResource resource, List<EObject> se
codeActions.add(new CreateValue4StakeholderAction(resource, selectedObjects));
codeActions.add(new AddEthicalValueAssessmentAction(resource, selectedObjects));
codeActions.add(new WrapValueInClusterAction(resource, selectedObjects));
codeActions.add(new CreateStakeholderForUserStoryRoleAction(resource, selectedObjects));
codeActions.add(new CreateValueRegisterForBoundedContextAction(resource, selectedObjects));

return Lists.newLinkedList(codeActions);
}
Expand Down
Loading

0 comments on commit c0e9920

Please sign in to comment.