use of org.contextmapper.dsl.contextMappingDSL.Domain 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.Domain 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.Domain 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.Domain in project context-mapper-dsl by ContextMapper.
the class PlantUMLGeneratorTest method canCreatePlantUMLDiagrmFiles4SubdomainIfEntitiesAvailable.
@Test
void canCreatePlantUMLDiagrmFiles4SubdomainIfEntitiesAvailable() {
// given
ContextMappingModel model = ContextMappingDSLFactory.eINSTANCE.createContextMappingModel();
Domain domain = ContextMappingDSLFactory.eINSTANCE.createDomain();
Subdomain subdomain1 = ContextMappingDSLFactory.eINSTANCE.createSubdomain();
domain.setName("TestDomain");
subdomain1.setName("TestSubdomain1");
Subdomain subdomain2 = ContextMappingDSLFactory.eINSTANCE.createSubdomain();
subdomain2.setName("TestSubdomain2");
domain.getSubdomains().add(subdomain1);
domain.getSubdomains().add(subdomain2);
subdomain2.getEntities().add(createTestEntity("TestEntity"));
model.getDomains().add(domain);
// when
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
// then
assertFalse(filesystem.getGeneratedFilesSet().contains("testmodel_SD_TestSubdomain1.puml"));
assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_SD_TestSubdomain2.puml"));
}
use of org.contextmapper.dsl.contextMappingDSL.Domain in project context-mapper-dsl by ContextMapper.
the class PlantUMLGeneratorTest method expectExceptionIfThereIsOnlyAnEmptyDomain.
@Test
void expectExceptionIfThereIsOnlyAnEmptyDomain() {
ContextMappingModel model = ContextMappingDSLFactory.eINSTANCE.createContextMappingModel();
Domain emptyDomain = ContextMappingDSLFactory.eINSTANCE.createDomain();
emptyDomain.setName("TestDomain");
model.getDomains().add(emptyDomain);
IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
assertThrows(GeneratorInputException.class, () -> {
this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
});
}
Aggregations