use of org.contextmapper.tactic.dsl.tacticdsl.Service in project context-mapper-dsl by ContextMapper.
the class DeriveBoundedContextFromSubdomainsTest method canCopyAndEnhanceServices.
@ParameterizedTest
@ValueSource(strings = { "derive-bc-from-subdomain-test-1-input.cml", "derive-bc-from-subdomain-test-6-input.cml", "derive-bc-from-subdomain-test-7-input.cml" })
public void canCopyAndEnhanceServices(String inputFile) throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML(inputFile);
// when
Set<String> subdomains = Sets.newHashSet(Arrays.asList(new String[] { "CustomerDomain" }));
DeriveBoundedContextFromSubdomains ar = new DeriveBoundedContextFromSubdomains("NewTestBC", subdomains);
ar.refactor(input);
ar.persistChanges(serializer);
// then
ContextMappingModel model = reloadResource(input).getContextMappingModel();
assertEquals(1, model.getBoundedContexts().size());
assertNotNull(model.getBoundedContexts().get(0));
BoundedContext bc = model.getBoundedContexts().get(0);
assertEquals("NewTestBC", bc.getName());
assertEquals(BoundedContextType.FEATURE, bc.getType());
assertEquals(1, bc.getAggregates().size());
assertNotNull(bc.getAggregates().get(0));
Aggregate aggregate = bc.getAggregates().get(0);
assertEquals(1, aggregate.getServices().size());
Service service = aggregate.getServices().get(0);
assertEquals("CustomerService", service.getName());
assertEquals(2, service.getOperations().size());
ServiceOperation operation = service.getOperations().stream().filter(o -> o.getName().equals("createCustomer")).findFirst().get();
assertEquals("createCustomer", operation.getName());
assertEquals("boolean", operation.getReturnType().getType());
assertEquals(1, operation.getParameters().size());
Parameter parameter = operation.getParameters().get(0);
assertEquals("createCustomerInput", parameter.getName());
assertEquals("CreateCustomerInput", parameter.getParameterType().getType());
}
use of org.contextmapper.tactic.dsl.tacticdsl.Service in project context-mapper-dsl by ContextMapper.
the class DeriveBoundedContextFromSubdomainsTest method canCreateServiceOperationParametersFromFeaturesInModule.
@ParameterizedTest
@ValueSource(strings = { "derive-bc-from-subdomain-test-10-input.cml" })
public void canCreateServiceOperationParametersFromFeaturesInModule(String inputFile) throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML(inputFile);
// when
Set<String> subdomains = Sets.newHashSet(Arrays.asList(new String[] { "CustomerDomain" }));
DeriveBoundedContextFromSubdomains ar = new DeriveBoundedContextFromSubdomains("NewTestBC", subdomains);
ar.refactor(input);
ar.persistChanges(serializer);
// then
ContextMappingModel model = reloadResource(input).getContextMappingModel();
assertEquals(1, model.getBoundedContexts().size());
assertNotNull(model.getBoundedContexts().get(0));
BoundedContext bc = model.getBoundedContexts().get(0);
assertEquals("NewTestBC", bc.getName());
assertEquals(BoundedContextType.FEATURE, bc.getType());
assertEquals(1, bc.getModules().get(0).getAggregates().size());
assertNotNull(bc.getModules().get(0).getAggregates().get(0));
Aggregate aggregate = bc.getModules().get(0).getAggregates().get(0);
assertEquals(1, aggregate.getServices().size());
Service service = aggregate.getServices().get(0);
assertEquals("CustomerService", service.getName());
assertEquals(2, service.getOperations().size());
ServiceOperation createOperation = service.getOperations().stream().filter(o -> o.getName().equals("createCustomer")).findFirst().get();
assertEquals("createCustomer", createOperation.getName());
assertEquals("String", createOperation.getReturnType().getType());
assertEquals(1, createOperation.getParameters().size());
Parameter parameter = createOperation.getParameters().get(0);
assertEquals("customer", parameter.getName());
assertEquals("Customer", parameter.getParameterType().getDomainObjectType().getName());
ServiceOperation readOperation = service.getOperations().stream().filter(o -> o.getName().equals("readCustomer")).findFirst().get();
assertEquals("readCustomer", readOperation.getName());
assertEquals("Customer", readOperation.getReturnType().getDomainObjectType().getName());
assertEquals(1, readOperation.getParameters().size());
parameter = readOperation.getParameters().get(0);
assertEquals("id", parameter.getName());
assertEquals("String", parameter.getParameterType().getType());
}
use of org.contextmapper.tactic.dsl.tacticdsl.Service in project context-mapper-dsl by ContextMapper.
the class DeriveBoundedContextFromSubdomainsTest method canCreateServiceOperationParametersFromFeatures.
@ParameterizedTest
@ValueSource(strings = { "derive-bc-from-subdomain-test-9-input.cml" })
public void canCreateServiceOperationParametersFromFeatures(String inputFile) throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML(inputFile);
// when
Set<String> subdomains = Sets.newHashSet(Arrays.asList(new String[] { "CustomerDomain" }));
DeriveBoundedContextFromSubdomains ar = new DeriveBoundedContextFromSubdomains("NewTestBC", subdomains);
ar.refactor(input);
ar.persistChanges(serializer);
// then
ContextMappingModel model = reloadResource(input).getContextMappingModel();
assertEquals(1, model.getBoundedContexts().size());
assertNotNull(model.getBoundedContexts().get(0));
BoundedContext bc = model.getBoundedContexts().get(0);
assertEquals("NewTestBC", bc.getName());
assertEquals(BoundedContextType.FEATURE, bc.getType());
assertEquals(1, bc.getAggregates().size());
assertNotNull(bc.getAggregates().get(0));
Aggregate aggregate = bc.getAggregates().get(0);
assertEquals(1, aggregate.getServices().size());
Service service = aggregate.getServices().get(0);
assertEquals("CustomerService", service.getName());
assertEquals(2, service.getOperations().size());
ServiceOperation createOperation = service.getOperations().stream().filter(o -> o.getName().equals("createCustomer")).findFirst().get();
assertEquals("createCustomer", createOperation.getName());
assertEquals("String", createOperation.getReturnType().getType());
assertEquals(1, createOperation.getParameters().size());
Parameter parameter = createOperation.getParameters().get(0);
assertEquals("customer", parameter.getName());
assertEquals("Customer", parameter.getParameterType().getDomainObjectType().getName());
ServiceOperation readOperation = service.getOperations().stream().filter(o -> o.getName().equals("readCustomer")).findFirst().get();
assertEquals("readCustomer", readOperation.getName());
assertEquals("Customer", readOperation.getReturnType().getDomainObjectType().getName());
assertEquals(1, readOperation.getParameters().size());
parameter = readOperation.getParameters().get(0);
assertEquals("id", parameter.getName());
assertEquals("String", parameter.getParameterType().getType());
}
use of org.contextmapper.tactic.dsl.tacticdsl.Service 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.tactic.dsl.tacticdsl.Service in project context-mapper-dsl by ContextMapper.
the class PlantUMLBoundedContextClassDiagramCreatorTest method respectEventsAndCommandsAndServicesFromApplicationLayer.
@Test
public void respectEventsAndCommandsAndServicesFromApplicationLayer() {
// given
BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
Application app = ContextMappingDSLFactory.eINSTANCE.createApplication();
boundedContext.setApplication(app);
DomainEvent testEvent = TacticdslFactory.eINSTANCE.createDomainEvent();
testEvent.setName("TestEvent");
app.getEvents().add(testEvent);
CommandEvent testCommand = TacticdslFactory.eINSTANCE.createCommandEvent();
testCommand.setName("TestCommand");
app.getCommands().add(testCommand);
Service testService = TacticdslFactory.eINSTANCE.createService();
testService.setName("TestService");
app.getServices().add(testService);
// when
String plantUML = this.creator.createDiagram(boundedContext);
// then
assertTrue(plantUML.contains("package \"'Application'\" <<Rectangle>> {" + System.lineSeparator()));
assertTrue(plantUML.contains(" class TestEvent <<(E,#ff9f4b) Domain Event>> {" + System.lineSeparator() + " }" + System.lineSeparator()));
assertTrue(plantUML.contains(" class TestCommand <<(C,#3bc5e9) Command>> {" + System.lineSeparator() + " }" + System.lineSeparator()));
assertTrue(plantUML.contains(" class TestService <<(S,DarkSeaGreen) Service>> {" + System.lineSeparator() + " }" + System.lineSeparator()));
}
Aggregations