use of org.contextmapper.dsl.contextMappingDSL.Subdomain in project context-mapper-dsl by ContextMapper.
the class DeriveSubdomainFromUserRequirementsTest method canDeriveSubdomainFromUserStory.
@ParameterizedTest
@ValueSource(strings = { "derive-subdomain-from-user-story-test-1-input.cml", "derive-subdomain-from-user-story-test-2-input.cml", "derive-subdomain-from-user-story-test-3-input.cml", "derive-subdomain-from-user-story-test-4-input.cml", "derive-subdomain-from-user-story-test-5-input.cml", "derive-subdomain-from-user-story-test-6-input.cml" })
public void canDeriveSubdomainFromUserStory(String inputFile) throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML(inputFile);
// when
Set<String> userStories = Sets.newHashSet(Arrays.asList(new String[] { "US1_Create", "Story_to_be_Ignored", "UseCase_to_be_Ignored" }));
DeriveSubdomainFromUserRequirements ar = new DeriveSubdomainFromUserRequirements("InsuranceDomain", "Customers", userStories);
ar.refactor(input);
ar.persistChanges(serializer);
// then
ContextMappingModel model = reloadResource(input).getContextMappingModel();
assertEquals(1, model.getDomains().size());
assertNotNull(model.getDomains().get(0));
Domain domain = model.getDomains().get(0);
assertEquals(1, domain.getSubdomains().size());
assertNotNull(domain.getSubdomains().get(0));
Subdomain subdomain = domain.getSubdomains().get(0);
Set<String> supportedFeatures = subdomain.getSupportedFeatures().stream().map(f -> f.getName()).collect(Collectors.toSet());
assertTrue(supportedFeatures.contains("US1_Create"));
assertEquals("Customers", subdomain.getName());
assertEquals("Aims at promoting the following benefit for a Insurance Employee: I am able to manage the customer data and offer contracts.", subdomain.getDomainVisionStatement());
assertEquals(1, subdomain.getEntities().size());
assertEquals(1, subdomain.getServices().size());
Entity entity = subdomain.getEntities().get(0);
assertEquals("Customer", entity.getName());
Service service = subdomain.getServices().get(0);
assertEquals("US1_CreateService", service.getName());
assertEquals(1, service.getOperations().size());
ServiceOperation operation = service.getOperations().get(0);
assertEquals("createCustomer", operation.getName());
}
use of org.contextmapper.dsl.contextMappingDSL.Subdomain in project context-mapper-dsl by ContextMapper.
the class DeriveSubdomainFromUserRequirementsTest method canMergeDomainVisionStatements.
@Test
public void canMergeDomainVisionStatements() throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML("derive-subdomain-from-user-story-test-existing-dvs-1.cml");
// when
Set<String> userStories = Sets.newHashSet(Arrays.asList(new String[] { "US1_Create", "Story_to_be_Ignored" }));
DeriveSubdomainFromUserRequirements ar = new DeriveSubdomainFromUserRequirements("InsuranceDomain", "Customers", userStories);
ar.refactor(input);
ar.persistChanges(serializer);
// then
ContextMappingModel model = reloadResource(input).getContextMappingModel();
assertEquals(1, model.getDomains().size());
assertNotNull(model.getDomains().get(0));
Domain domain = model.getDomains().get(0);
assertEquals(1, domain.getSubdomains().size());
assertNotNull(domain.getSubdomains().get(0));
Subdomain subdomain = domain.getSubdomains().get(0);
assertEquals("Customers", subdomain.getName());
assertEquals("existing dvs 1; existing dvs 2; Aims at promoting the following benefit for a Insurance Employee: I am able to manage the customer data and offer contracts.", subdomain.getDomainVisionStatement());
}
use of org.contextmapper.dsl.contextMappingDSL.Subdomain in project context-mapper-dsl by ContextMapper.
the class BoundedContextSemanticsValidator method validateThatAggregateContainsOnlyOneAggregateRoot.
@Check
public void validateThatAggregateContainsOnlyOneAggregateRoot(final BoundedContext boundedContext) {
List<Domain> domains = boundedContext.getImplementedDomainParts().stream().filter(domainPart -> domainPart instanceof Domain).map(domainPart -> (Domain) domainPart).collect(Collectors.toList());
if (domains.isEmpty())
return;
boundedContext.getImplementedDomainParts().stream().filter(domainPart -> domainPart instanceof Subdomain).map(domainPart -> (Subdomain) domainPart).forEach(subdomain -> {
Domain parentDomain = (Domain) subdomain.eContainer();
if (domains.contains(parentDomain))
error(String.format(ALREADY_IMPLEMENTED_SUBDOMAIN, subdomain.getName(), parentDomain.getName()), boundedContext, ContextMappingDSLPackage.Literals.BOUNDED_CONTEXT__IMPLEMENTED_DOMAIN_PARTS, boundedContext.getImplementedDomainParts().indexOf(subdomain));
});
}
use of org.contextmapper.dsl.contextMappingDSL.Subdomain in project context-mapper-dsl by ContextMapper.
the class GenerateBoundedContextFromSubdomainRefactoringHandler method executeRefactoring.
@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
Set<Subdomain> subdomains = getAllSelectedElements().stream().filter(sd -> sd instanceof Subdomain).map(sd -> (Subdomain) sd).collect(Collectors.toSet());
Set<String> boundedContexts = resource.getContextMappingModel().getBoundedContexts().stream().map(bc -> bc.getName()).collect(Collectors.toSet());
Set<String> ids = subdomains.stream().map(sd -> sd.getName()).collect(Collectors.toSet());
DeriveBoundedContextFromSubdomainsContext refactoringContext = new DeriveBoundedContextFromSubdomainsContext("NewContextFromSubdomains", boundedContexts);
new WizardDialog(HandlerUtil.getActiveShell(event), new DeriveBoundedContextFromSubdomainsWizard(refactoringContext, executionContext -> {
return finishRefactoring(new DeriveBoundedContextFromSubdomains(executionContext.getBoundedContextName(), ids), resource, event);
})).open();
}
use of org.contextmapper.dsl.contextMappingDSL.Subdomain in project context-mapper-dsl by ContextMapper.
the class PlantUMLSubdomainClassDiagramCreatorTest method canCreateLegend.
@Test
public void canCreateLegend() {
// given
Subdomain subdomain = ContextMappingDSLFactory.eINSTANCE.createSubdomain();
subdomain.setName("MyTestSubdomain");
String domainVisionStatement = "this is the vision of this test subdomain ...";
subdomain.setDomainVisionStatement(domainVisionStatement);
// when
String plantUML = this.creator.createDiagram(subdomain);
// then
assertTrue(plantUML.contains("legend left"));
assertTrue(plantUML.contains(" This subdomain is part of the 'TestDomain' domain."));
assertTrue(plantUML.contains(" " + domainVisionStatement));
assertTrue(plantUML.contains("end legend"));
}
Aggregations