Skip to content

Commit

Permalink
Stakeholders & Values: Transformations (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-ka authored Aug 15, 2024
1 parent cfe8769 commit e25f5c3
Show file tree
Hide file tree
Showing 40 changed files with 1,615 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.actions

import org.junit.jupiter.api.Test

class StakeholdersActionsTest extends AbstractBoundedContextCodeActionTest {

@Test
def void canOfferActionsOnStakeholder() {
testCodeAction [
model = '''
Stakeholders {
Stakeholder Tester
}
'''
line = 1
expectedCodeActions = '''
command : cml.ar.moveStakeholderToGroup.proxy
title : Move Stakeholder To New Group
args :
file://«this.root»/MyModel.cml,Tester
command : cml.ar.createValueForStakeholder.proxy
title : Create Value For Stakeholder
args :
file://«this.root»/MyModel.cml,Tester
'''
]
}

}
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 @@ -17,10 +17,10 @@ package org.contextmapper.dsl.ide.tests.actions

import org.junit.jupiter.api.Test

class DeriveSubdomainFromUserRequirementsActionTest extends AbstractBoundedContextCodeActionTest {
class UserStoryActionsTest extends AbstractBoundedContextCodeActionTest {

@Test
def void canOfferAction4UserStory() {
def void canOfferActions4UserStories() {
testCodeAction [
model = '''
UserStory TestStory
Expand All @@ -30,6 +30,10 @@ class DeriveSubdomainFromUserRequirementsActionTest extends AbstractBoundedConte
title : Derive Subdomain From User Requirements
args :
file://«this.root»/MyModel.cml,TestStory
command : cml.ar.addEthicalValueAssessment.proxy
title : Add Ethical Value Assessment
args :
file://«this.root»/MyModel.cml,TestStory
'''
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.actions

import org.junit.jupiter.api.Test

class ValueActionsTest extends AbstractBoundedContextCodeActionTest {

@Test
def void canOfferActionsOnValue() {
testCodeAction [
model = '''
ValueRegister TestRegister {
Value TestValue
}
'''
line = 1
expectedCodeActions = '''
command : cml.ar.wrapValueInCluster.proxy
title : Wrap Value In Cluster
args :
file://«this.root»/MyModel.cml,TestValue
'''
]
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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 AddEthicalValueAssessmentCommandTest extends AbstractCMLCommandTest {

@Test
def void testARCommandExecution() {
// given
initializeCommandsDynamically()
val model = '''
UserStory SameDayDelivery_1 {
As a "Shopper" I want to "instantly receive" an "Order" so that "I am efficient"
}
'''
val fileURI = 'test.cml'.writeFile(model)

// when
val refactoringParams = new JsonArray
refactoringParams.add("SameDayDelivery_1")
val result = languageServer.executeCommand(
new ExecuteCommandParams("cml.ar.addEthicalValueAssessment", #[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,49 @@
/*
* 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 CreateValue4StakeholderCommandTest extends AbstractCMLCommandTest {

@Test
def void testARCommandExecution() {
// given
initializeCommandsDynamically()
val model = '''
Stakeholders {
Stakeholder Tester
}
'''
val fileURI = 'test.cml'.writeFile(model)

// when
val refactoringParams = new JsonArray
refactoringParams.add("Tester")
val result = languageServer.executeCommand(
new ExecuteCommandParams("cml.ar.createValueForStakeholder", #[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,49 @@
/*
* 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 MoveStakeholderToGroupCommandTest extends AbstractCMLCommandTest {

@Test
def void testARCommandExecution() {
// given
initializeCommandsDynamically()
val model = '''
Stakeholders {
Stakeholder Tester
}
'''
val fileURI = 'test.cml'.writeFile(model)

// when
val refactoringParams = new JsonArray
refactoringParams.add("Tester")
val result = languageServer.executeCommand(
new ExecuteCommandParams("cml.ar.moveStakeholderToGroup", #[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,49 @@
/*
* 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 WrapValueInClusterCommandTest extends AbstractCMLCommandTest {

@Test
def void testARCommandExecution() {
// given
initializeCommandsDynamically()
val model = '''
ValueRegister TestRegister {
Value TestValue
}
'''
val fileURI = 'test.cml'.writeFile(model)

// when
val refactoringParams = new JsonArray
refactoringParams.add("TestValue")
val result = languageServer.executeCommand(
new ExecuteCommandParams("cml.ar.wrapValueInCluster", #[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 @@ -39,6 +39,10 @@ class SplitStoryByVerbQuickFixTest extends AbstractCMLCommandTest {
expectedCodeActions = '''
command : cml.ar.deriveSubdomainFromURs.proxy
title : Derive Subdomain From User Requirements
args :
file://«this.root»/MyModel.cml,TestStory
command : cml.ar.addEthicalValueAssessment.proxy
title : Add Ethical Value Assessment
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
Expand Up @@ -24,6 +24,8 @@

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.CreateValue4StakeholderAction;
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 All @@ -32,13 +34,15 @@
import org.contextmapper.dsl.ide.actions.impl.ExtractSharedKernelAction;
import org.contextmapper.dsl.ide.actions.impl.MergeAggregatesAction;
import org.contextmapper.dsl.ide.actions.impl.MergeBoundedContextsAction;
import org.contextmapper.dsl.ide.actions.impl.MoveStakeholderToGroupAction;
import org.contextmapper.dsl.ide.actions.impl.SplitAggregateByEntitiesAction;
import org.contextmapper.dsl.ide.actions.impl.SplitBoundedContextByFeaturesAction;
import org.contextmapper.dsl.ide.actions.impl.SplitBoundedContextByOwnerAction;
import org.contextmapper.dsl.ide.actions.impl.SplitSystemIntoSubsystemsAction;
import org.contextmapper.dsl.ide.actions.impl.SuspendPartnershipAction;
import org.contextmapper.dsl.ide.actions.impl.SwitchFromPartnershipToSharedKernelAction;
import org.contextmapper.dsl.ide.actions.impl.SwitchFromSharedKernelToPartnershipAction;
import org.contextmapper.dsl.ide.actions.impl.WrapValueInClusterAction;
import org.contextmapper.dsl.ide.edit.WorkspaceEditRecorder;
import org.contextmapper.dsl.ide.quickfix.QuickfixCommandMapper;
import org.contextmapper.dsl.ide.quickfix.impl.OpenCoordinationInSketchMinerCommandMapper;
Expand Down Expand Up @@ -110,6 +114,10 @@ private List<CMLCodeAction> getAllActions(CMLResource resource, List<EObject> se
codeActions.add(new SuspendPartnershipAction(resource, selectedObjects));
codeActions.add(new SwitchFromPartnershipToSharedKernelAction(resource, selectedObjects));
codeActions.add(new SwitchFromSharedKernelToPartnershipAction(resource, selectedObjects));
codeActions.add(new MoveStakeholderToGroupAction(resource, selectedObjects));
codeActions.add(new CreateValue4StakeholderAction(resource, selectedObjects));
codeActions.add(new AddEthicalValueAssessmentAction(resource, selectedObjects));
codeActions.add(new WrapValueInClusterAction(resource, selectedObjects));

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

0 comments on commit e25f5c3

Please sign in to comment.