use of org.contextmapper.dsl.contextMappingDSL.Subdomain in project context-mapper-dsl by ContextMapper.
the class DeriveBoundedContextFromSubdomains method collectSubdomains.
private Set<Subdomain> collectSubdomains() {
Set<Subdomain> allSubdomains = Sets.newHashSet();
for (Domain domain : getAllDomains()) {
allSubdomains.addAll(domain.getSubdomains());
}
Set<Subdomain> subdomains = Sets.newHashSet();
for (String subdomainId : subdomainIds) {
Optional<Subdomain> optSubdomain = allSubdomains.stream().filter(sd -> subdomainId.equals(sd.getName())).findFirst();
if (optSubdomain.isPresent())
subdomains.add(optSubdomain.get());
}
return subdomains;
}
use of org.contextmapper.dsl.contextMappingDSL.Subdomain in project context-mapper-dsl by ContextMapper.
the class DeriveSubdomainFromUserRequirementsTest method canIgnoreEmptyReferences.
@ParameterizedTest
@ValueSource(strings = { "derive-subdomain-from-user-story-test-10-input.cml", "derive-subdomain-from-user-story-test-11-input.cml" })
public void canIgnoreEmptyReferences(String inputFile) throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML(inputFile);
// when
Set<String> userStories = Sets.newHashSet(Arrays.asList(new String[] { "US1_Create" }));
DeriveSubdomainFromUserRequirements ar = new DeriveSubdomainFromUserRequirements("InsuranceDomain", "Customers", userStories);
ar.refactor(input);
// then
ContextMappingModel model = reloadResource(input).getContextMappingModel();
Subdomain subdomain = model.getDomains().get(0).getSubdomains().get(0);
assertNotNull(subdomain);
Entity customerEntity = subdomain.getEntities().stream().filter(e -> e.getName().equals("Customer")).findFirst().get();
assertNotNull(customerEntity);
assertEquals(0, customerEntity.getReferences().size());
}
use of org.contextmapper.dsl.contextMappingDSL.Subdomain in project context-mapper-dsl by ContextMapper.
the class PlantUMLSubdomainClassDiagramCreatorTest method canCreateClasses4Entities.
@Test
public void canCreateClasses4Entities() {
// given
Subdomain subdomain = ContextMappingDSLFactory.eINSTANCE.createSubdomain();
subdomain.setName("MyTestSubdomain");
Entity entity = TacticdslFactory.eINSTANCE.createEntity();
entity.setName("Test");
Attribute attribute = TacticdslFactory.eINSTANCE.createAttribute();
attribute.setType("int");
attribute.setName("amount");
entity.getAttributes().add(attribute);
Attribute listAttribute = TacticdslFactory.eINSTANCE.createAttribute();
listAttribute.setCollectionType(CollectionType.LIST);
listAttribute.setName("myList");
listAttribute.setType("String");
entity.getAttributes().add(listAttribute);
subdomain.getEntities().add(entity);
// when
String plantUML = this.creator.createDiagram(subdomain);
// then
assertTrue(plantUML.contains(" class Test <<(E,DarkSeaGreen) Entity>> {" + System.lineSeparator() + " int amount" + System.lineSeparator() + " List<String> myList" + System.lineSeparator() + " }" + System.lineSeparator()));
}
use of org.contextmapper.dsl.contextMappingDSL.Subdomain in project context-mapper-dsl by ContextMapper.
the class PlantUMLGeneratorTest method canCreatePlantUMLDiagramFiles.
@Test
void canCreatePlantUMLDiagramFiles() {
// given
ContextMappingModel model = ContextMappingDSLFactory.eINSTANCE.createContextMappingModel();
ContextMap contextMap = ContextMappingDSLFactory.eINSTANCE.createContextMap();
BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
Domain domain = ContextMappingDSLFactory.eINSTANCE.createDomain();
Subdomain subdomain = ContextMappingDSLFactory.eINSTANCE.createSubdomain();
domain.setName("TestDomain");
subdomain.setName("TestSubdomain");
domain.getSubdomains().add(subdomain);
boundedContext.setName("TestContext");
model.getBoundedContexts().add(boundedContext);
contextMap.getBoundedContexts().add(boundedContext);
model.setMap(contextMap);
model.getDomains().add(domain);
// when
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
// then
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_ContextMap.puml"));
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_BC_TestContext.puml"));
assertFalse(filesystem.getGeneratedFilesSet().contains("testmodel_SD_TestSubdomain.puml"));
}
use of org.contextmapper.dsl.contextMappingDSL.Subdomain in project context-mapper-dsl by ContextMapper.
the class PlantUMLBoundedContextClassDiagramCreator method printLegend.
private void printLegend(BoundedContext boundedContext) {
List<Subdomain> subdomains = getSubdomains(boundedContext.getImplementedDomainParts());
if (subdomains.isEmpty() && boundedContext.getRefinedBoundedContext() == null)
return;
sb.append("legend left");
linebreak();
if (boundedContext.getRefinedBoundedContext() != null) {
sb.append(" ").append("This Bounded Context '").append(boundedContext.getName()).append("' refines the '").append(boundedContext.getRefinedBoundedContext().getName()).append("' Bounded Context.");
linebreak();
}
for (Subdomain subdomain : subdomains) {
if (subdomain.getEntities().isEmpty()) {
sb.append(" ").append("This bounded context implements the subdomain '" + subdomain.getName() + "'.");
} else {
sb.append(" ").append("This bounded context implements the subdomain '" + subdomain.getName() + "', which contains the following entities:");
}
linebreak();
for (Entity entity : subdomain.getEntities()) {
sb.append(" ").append(" - ").append(entity.getName());
linebreak();
}
}
sb.append("end legend");
linebreak();
}
Aggregations