Search in sources :

Example 6 with CMLResource

use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.

the class SplitBoundedContextByOwnerTest method canSplitByOwner.

@Test
void canSplitByOwner() throws IOException {
    // given
    String inputModelName = "split-bc-by-owner-test-1-input.cml";
    CMLResource input = getResourceCopyOfTestCML(inputModelName);
    // when
    SplitBoundedContextByOwner ar = new SplitBoundedContextByOwner("CustomerManagement");
    ar.refactor(input);
    // then
    ContextMappingModel model = input.getContextMappingModel();
    assertEquals(4, model.getBoundedContexts().size());
    List<String> boundedContextNames = model.getBoundedContexts().stream().map(bc -> bc.getName()).collect(Collectors.toList());
    assertTrue(boundedContextNames.contains("CustomerManagement"));
    assertTrue(boundedContextNames.contains("NewBoundedContext1"));
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Test(org.junit.jupiter.api.Test) List(java.util.List) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SplitBoundedContextByOwner(org.contextmapper.dsl.refactoring.SplitBoundedContextByOwner) IOException(java.io.IOException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Collectors(java.util.stream.Collectors) CMLResource(org.contextmapper.dsl.cml.CMLResource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) SplitBoundedContextByOwner(org.contextmapper.dsl.refactoring.SplitBoundedContextByOwner) CMLResource(org.contextmapper.dsl.cml.CMLResource) Test(org.junit.jupiter.api.Test)

Example 7 with CMLResource

use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.

the class SplitBoundedContextByUseCasesTest method canSplitIfThereIsNothingToSplit.

@Test
void canSplitIfThereIsNothingToSplit() throws IOException {
    // given
    String inputModelName = "split-bc-by-use-cases-test-3-input.cml";
    CMLResource input = getResourceCopyOfTestCML(inputModelName);
    // when
    SplitBoundedContextByFeatures ar = new SplitBoundedContextByFeatures("CustomerManagement");
    ar.refactor(input);
    // then
    assertEquals(1, input.getContextMappingModel().getBoundedContexts().size());
}
Also used : SplitBoundedContextByFeatures(org.contextmapper.dsl.refactoring.SplitBoundedContextByFeatures) CMLResource(org.contextmapper.dsl.cml.CMLResource) Test(org.junit.jupiter.api.Test)

Example 8 with CMLResource

use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.

the class SplitBoundedContextByUseCasesTest method canSplitWithSingleUseCases.

@Test
void canSplitWithSingleUseCases() throws IOException {
    // given
    String inputModelName = "split-bc-by-use-cases-test-1-input.cml";
    CMLResource input = getResourceCopyOfTestCML(inputModelName);
    // when
    SplitBoundedContextByFeatures ar = new SplitBoundedContextByFeatures("CustomerManagement");
    ar.refactor(input);
    // then
    ContextMappingModel model = input.getContextMappingModel();
    assertEquals(2, model.getBoundedContexts().size());
    List<String> boundedContextNames = model.getBoundedContexts().stream().map(bc -> bc.getName()).collect(Collectors.toList());
    assertTrue(boundedContextNames.contains("CustomerManagement"));
    assertTrue(boundedContextNames.contains("NewBoundedContext1"));
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Test(org.junit.jupiter.api.Test) List(java.util.List) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SplitBoundedContextByFeatures(org.contextmapper.dsl.refactoring.SplitBoundedContextByFeatures) IOException(java.io.IOException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Collectors(java.util.stream.Collectors) CMLResource(org.contextmapper.dsl.cml.CMLResource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) SplitBoundedContextByFeatures(org.contextmapper.dsl.refactoring.SplitBoundedContextByFeatures) CMLResource(org.contextmapper.dsl.cml.CMLResource) Test(org.junit.jupiter.api.Test)

Example 9 with CMLResource

use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.

the class SplitBoundedContextByUseCasesTest method canSplitAndFixExposedAggregatesInContextMapRelationships.

@Test
void canSplitAndFixExposedAggregatesInContextMapRelationships() throws IOException {
    // given
    String inputModelName = "split-bc-by-use-cases-test-4-input.cml";
    CMLResource input = getResourceCopyOfTestCML(inputModelName);
    // when
    SplitBoundedContextByFeatures ar = new SplitBoundedContextByFeatures("CustomerManagement");
    ar.refactor(input);
    // then
    ContextMappingModel model = input.getContextMappingModel();
    assertEquals(3, model.getBoundedContexts().size());
    List<String> boundedContextNames = model.getBoundedContexts().stream().map(bc -> bc.getName()).collect(Collectors.toList());
    assertTrue(boundedContextNames.contains("CustomerManagement"));
    assertTrue(boundedContextNames.contains("NewBoundedContext1"));
    List<UpstreamDownstreamRelationship> relationships = model.getMap().getRelationships().stream().filter(rel -> rel instanceof UpstreamDownstreamRelationship).map(rel -> (UpstreamDownstreamRelationship) rel).collect(Collectors.toList());
    assertEquals(2, relationships.size());
    assertEquals(1, relationships.get(0).getUpstreamExposedAggregates().size());
    assertEquals(1, relationships.get(1).getUpstreamExposedAggregates().size());
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Test(org.junit.jupiter.api.Test) List(java.util.List) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SplitBoundedContextByFeatures(org.contextmapper.dsl.refactoring.SplitBoundedContextByFeatures) IOException(java.io.IOException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Collectors(java.util.stream.Collectors) CMLResource(org.contextmapper.dsl.cml.CMLResource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) SplitBoundedContextByFeatures(org.contextmapper.dsl.refactoring.SplitBoundedContextByFeatures) CMLResource(org.contextmapper.dsl.cml.CMLResource) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) Test(org.junit.jupiter.api.Test)

Example 10 with CMLResource

use of org.contextmapper.dsl.cml.CMLResource in project context-mapper-dsl by ContextMapper.

the class SplitSystemIntoSubsystemsTest method canSplitTierIfNewSystemNamesAndContextMapAlreadyExist.

@ParameterizedTest
@ValueSource(strings = { "split-system-tier-test-4" })
public void canSplitTierIfNewSystemNamesAndContextMapAlreadyExist(String testBasefileName) throws IOException {
    // given
    CMLResource input = getResourceCopyOfTestCML(testBasefileName + "-input.cml");
    SplitSystemIntoSubsystems ar = new SplitSystemIntoSubsystems("TestBackendLogic", "TestBackendLogic", "TestBackendDatabase");
    // when
    ar.refactor(input);
    ar.persistChanges(serializer);
    // then
    String dslText = FileUtils.readFileToString(new File(input.getURI().toFileString()), "UTF-8");
    String expectedResult = FileUtils.readFileToString(new File(Paths.get("").toAbsolutePath().toString(), "/integ-test-files/refactorings/" + testBasefileName + "-output.cml"), Charset.forName("UTF-8"));
    assertEquals(expectedResult, dslText);
}
Also used : CMLResource(org.contextmapper.dsl.cml.CMLResource) File(java.io.File) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CMLResource (org.contextmapper.dsl.cml.CMLResource)192 Test (org.junit.jupiter.api.Test)155 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)87 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)73 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)59 UpstreamDownstreamRelationship (org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship)48 Collectors (java.util.stream.Collectors)44 IOException (java.io.IOException)43 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)43 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)41 List (java.util.List)40 ContextMap (org.contextmapper.dsl.contextMappingDSL.ContextMap)35 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)32 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)29 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)28 Optional (java.util.Optional)27 File (java.io.File)26 SculptorModule (org.contextmapper.dsl.contextMappingDSL.SculptorModule)22 ValueSource (org.junit.jupiter.params.provider.ValueSource)22 MergeBoundedContextsRefactoring (org.contextmapper.dsl.refactoring.MergeBoundedContextsRefactoring)14