Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Domain Insurance {
Subdomain CustomerDomain
Subdomain PolicyDomain
}

BoundedContext CustomerManagement implements CustomerDomain {
Aggregate Customers {
Entity Customer {
aggregateRoot
String firstname
}
}
}

BoundedContext PolicyManagement implements PolicyDomain {
Aggregate Policies {
Entity Policy {
aggregateRoot
String policyNr
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import "./BoundedContexts.cml"

ContextMap InsuranceContextMap {
contains CustomerManagement, PolicyManagement

CustomerManagement [U,OHS,PL] -> [D,ACL] PolicyManagement
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory;
import org.contextmapper.dsl.contextMappingDSL.ContextMappingModel;
import org.contextmapper.dsl.generator.ContextMapGenerator;
import org.contextmapper.dsl.generator.PlantUMLGenerator;
import org.contextmapper.dsl.generator.contextmap.ContextMapFormat;
import org.contextmapper.dsl.refactoring.SplitBoundedContextByOwner;
import org.eclipse.xtext.resource.SaveOptions;
Expand Down Expand Up @@ -138,6 +139,22 @@ public void canGenerateIntoCustomDirectory() {
assertTrue(expectedOutput.exists());
}

@Test
public void canLoadCMLWithImportsViaRelativePathAndCallGenerator() {
// given
StandaloneContextMapperAPI contextMapper = ContextMapperStandaloneSetup.getStandaloneAPI();
CMLResource cml = contextMapper.loadCML("./integ-test-files/standalone/imports/ContextMap.cml");
File expectedOutput = new File("./out/imports/ContextMap_ContextMap.puml");
ensureFileDoesNotExist(expectedOutput);

// when
contextMapper.callGenerator(cml, new PlantUMLGenerator(), "./out/imports");

// then
assertTrue(cml.getURI().isFile());
assertTrue(expectedOutput.exists());
}

@Test
public void canApplyRefactoring() throws IOException {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@ public StandaloneContextMapper() {

@Override
public CMLResource loadCML(String filepath) {
return new CMLResource(new ResourceSetImpl().getResource(URI.createURI(filepath), true));
return new CMLResource(new ResourceSetImpl().getResource(toURI(filepath), true));
}

private URI toURI(String filepath) {
URI uri = URI.createURI(filepath);
// plain file paths (relative or absolute, without scheme) are converted into absolute file URIs;
// otherwise imports cannot be resolved against the URI of the loaded resource (see issue #364)
// a single letter scheme is a Windows drive letter (C:\...)
if (uri.scheme() == null || uri.scheme().length() == 1)
return URI.createFileURI(new File(filepath).getAbsolutePath());
return uri;
}

@Override
Expand Down
Loading