Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule for coordination between services of different contexts #348

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
45bb0bc
chore: update gitignore
mLeveIST Jul 5, 2023
2719cf7
add mappings between bounded contexts
ritosilva Aug 30, 2023
9f0f718
fix
ritosilva Aug 30, 2023
076274a
define mappings directly
ritosilva Aug 30, 2023
e8efcd9
Add functionality representation in CML
mLeveIST Aug 31, 2023
c756755
Merge pull request #1 from socialsoftware/feature/add-mappings
mLeveIST Aug 31, 2023
067e844
Merge branch 'develop' into feature/cml-saga-concept
mLeveIST Aug 31, 2023
e6ec8a9
fix functionality step validation
mLeveIST Aug 31, 2023
589bc05
Add ';' to end of functionality step syntax
mLeveIST Aug 31, 2023
1e256d2
Add scope reduction for functionality steps
mLeveIST Sep 7, 2023
b2a3164
Add format rules for functionalities
mLeveIST Sep 7, 2023
1b78af6
Remove 'uses' syntax from branch
mLeveIST Sep 13, 2023
2d156f1
Refactor term 'Functionality' to 'Coordination'
mLeveIST Sep 13, 2023
716052d
Refactor Coordination validation
mLeveIST Sep 15, 2023
7a86561
Add CML tests for Coordination construct
mLeveIST Sep 15, 2023
f596f76
Add BPMN generator for Coordinations
mLeveIST Sep 15, 2023
fc38a85
Add Coordination sketchminer converter
mLeveIST Sep 15, 2023
533522e
Fix "::" notation conflict with sketchminer syntax
mLeveIST Sep 15, 2023
25916d2
Add quickfix to open Coordination in skechminer
mLeveIST Sep 15, 2023
384a52a
Merge branch 'master' into feature/cml-saga-concept
mLeveIST Sep 15, 2023
c7a58c3
Fix copyright notice year on new classes
mLeveIST Oct 10, 2023
b9176d1
Remove excess of new lines
mLeveIST Oct 10, 2023
50804fa
Fix possible resolving of unrelated upstream BCs
mLeveIST Oct 10, 2023
128a066
Split coordination validator into multiple checks
mLeveIST Oct 11, 2023
59f7924
Add additional tests
mLeveIST Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ plugin.xml_gen
.gradle/
build/

# MacOS
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,34 @@ class SketchMinerGeneratorCommandTest extends AbstractCMLCommandTest {
srcGenFolder.exists.assertTrue
new File(srcGenFolder, "test_BC_TestContext_TestFlow.sketch_miner").exists.assertTrue
}

@Test
def void testSketchMinerGeneratorCommandExecutionOnCoordination() {
// given
initializeCommandsDynamically()
val model = '''
BoundedContext ContextA {
Application {
Coordination TestCoordination {
ContextA::TestService::testOperation;
}
Service TestService {
testOperation;
}
}
}
'''
val fileURI = 'test.cml'.writeFile(model)

// when
val result = languageServer.executeCommand(
new ExecuteCommandParams("cml.generate.sketchminer", #[new JsonPrimitive(fileURI)]))
val resultVal = result.get as String

// then
CMLCommandService.COMMAND_EXECUTED_RETURN_VALUE.assertEquals(resultVal)
srcGenFolder.exists.assertTrue
new File(srcGenFolder, "coordinations/test_BC_ContextA_TestCoordination.sketch_miner").exists.assertTrue
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2023 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.quickfixes

import org.contextmapper.dsl.ide.tests.commands.AbstractCMLCommandTest
import org.junit.jupiter.api.Test

class OpenCoordinationInBPMNSketchMinerActionTest extends AbstractCMLCommandTest {

@Test
def void canOfferCodeAction() {
testCodeAction [
model = '''
BoundedContext ContextA {
Application {
Coordination TestCoordination {
ContextA::TestService::testOperation;
}
Service TestService {
testOperation;
}
}
}
'''
expectedCodeActions = '''
title : Open coordination in BPMN Sketch Miner
kind : quickfix
command : Command [
title = "Open coordination in BPMN Sketch Miner"
command = "cml.coordination.open.sketch.miner"
arguments = LinkedList (
"https://www.bpmn-sketch-miner.ai/index.html#EYBwNgdgXAbgjAKALRIQYQPYQC4FMAe2AglAggM64BOMAlgMa4AEAKrudgMrV2MB0eDgHkQ1AIbZaWMkA"
)
]
codes : open-coordination-in-sketch-miner
edit :
'''
]
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
import org.contextmapper.dsl.ide.actions.impl.SwitchFromSharedKernelToPartnershipAction;
import org.contextmapper.dsl.ide.edit.WorkspaceEditRecorder;
import org.contextmapper.dsl.ide.quickfix.QuickfixCommandMapper;
import org.contextmapper.dsl.ide.quickfix.impl.OpenCoordinationInSketchMinerCommandMapper;
import org.contextmapper.dsl.ide.quickfix.impl.OpenFlowInSketchMinerCommandMapper;
import org.contextmapper.dsl.ide.quickfix.impl.SplitStoryByVerbCommandMapper;
import org.contextmapper.dsl.quickfixes.CMLQuickFix;
import org.contextmapper.dsl.quickfixes.CreateMissingBoundedContextQuickFix;
import org.contextmapper.dsl.quickfixes.SplitStoryByVerb;
import org.contextmapper.dsl.quickfixes.tactic.ExtractIDValueObjectQuickFix;
import org.contextmapper.dsl.validation.ApplicationCoordinationSemanticsValidator;
import org.contextmapper.dsl.validation.ApplicationFlowSemanticsValidator;
import org.contextmapper.dsl.validation.DomainObjectValidator;
import org.contextmapper.dsl.validation.UserRequirementsValidator;
Expand Down Expand Up @@ -119,6 +121,7 @@ private void registerAllQuickFixes() {
registerActionQuickFix(DomainObjectValidator.ID_IS_PRIMITIVE_CODE, new ExtractIDValueObjectQuickFix());
registerCommandQuickFix(UserRequirementsValidator.ID_SPLIT_FEATURE_BY_VERB_SUGGESTION, new SplitStoryByVerbCommandMapper(new SplitStoryByVerb()));
registerCommandQuickFix(ApplicationFlowSemanticsValidator.SKETCH_MINER_INFO_ID, new OpenFlowInSketchMinerCommandMapper());
registerCommandQuickFix(ApplicationCoordinationSemanticsValidator.SKETCH_MINER_INFO_ID, new OpenCoordinationInSketchMinerCommandMapper());
}

public List<? extends Command> getApplicableActionCommands(CMLResource resource, List<EObject> selectedObjects) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2023 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.quickfix.impl;

import java.util.Arrays;

import org.contextmapper.dsl.cml.CMLResource;
import org.contextmapper.dsl.contextMappingDSL.Coordination;
import org.contextmapper.dsl.generator.sketchminer.SketchMinerLinkCreator;
import org.contextmapper.dsl.ide.quickfix.QuickfixCommandMapper;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.lsp4j.CodeAction;
import org.eclipse.lsp4j.CodeActionKind;
import org.eclipse.lsp4j.Command;

import com.google.common.collect.Lists;

public class OpenCoordinationInSketchMinerCommandMapper implements QuickfixCommandMapper {

@Override
public CodeAction getCodeAction(CMLResource cmlResource, EObject selectedObject) {
Coordination coordination = (Coordination) selectedObject;
CodeAction action = new CodeAction("Open coordination in BPMN Sketch Miner");
action.setKind(CodeActionKind.QuickFix);
Command command = new Command("Open coordination in BPMN Sketch Miner", "cml.coordination.open.sketch.miner");
command.setArguments(Lists.newLinkedList(Arrays.asList(new String[] { new SketchMinerLinkCreator().createSketchMinerLink(coordination) })));
action.setCommand(command);
return action;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ContextMap InsuranceMap {
contains UserContext
contains InsuranceQuotes

InsuranceQuotes <- UserContext
}

BoundedContext UserContext {

Application {
Service UserService {
void submitRequest(@Request request);
}
}
}

BoundedContext InsuranceQuotes {

Application {
Coordination QuoteRequestAcceptedCoordination {
UserContext::UserService::submitRequest;
InsuranceQuotes::QuoteRequestService::checkRequest;
InsuranceQuotes::QuoteRequestService::receiveAndCheckQuote;
InsuranceQuotes::QuoteRequestService::accept;
}

Service QuoteRequestService {
void checkRequest(@Request request);
void receiveAndCheckQuote(@Request request);
void reject(@Request request);
void accept(@Request request);
}
}

Aggregate QuoteRequest {
Entity Request {
aggregateRoot
}

enum RequestState {
aggregateLifecycle
SUBMITTED, RECEIVED, REJECTED, ACCEPTED, EXPIRED, POLICY_CREATED
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

BoundedContext EmptyContext // ignored
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

ContextMap TestMap {
contains ContextA
contains ContextB

ContextA <- ContextB
}

BoundedContext ContextA {
Application {
Coordination TestCoordination {
ContextA::ServiceA::operationA;
ContextB::ServiceB::operationB;
}
Service ServiceA {
operationA;
}
}
}

BoundedContext ContextB {
Application {
Service ServiceB {
operationB;
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

ContextMap TestMap {
contains ContextA
contains ContextB
contains ContextC

ContextA <- ContextB
ContextA <- ContextC
}

BoundedContext ContextA {
Application {
Coordination TestCoordination {
ContextA::ServiceA::operationA1;
ContextB::ServiceB::operationB;
ContextA::ServiceA::operationA2;
ContextC::ServiceC::operationC;
}
Service ServiceA {
operationA1;
operationA2;
}
}
}

BoundedContext ContextB {
Application {
Service ServiceB {
operationB;
}
}
}

BoundedContext ContextC {
Application {
Service ServiceC {
operationC;
}
}
}

Loading