Search in sources :

Example 1 with ACL

use of org.contextmapper.dsl.refactoring.ContextSplittingIntegrationType.ACL in project context-mapper-dsl by ContextMapper.

the class DeriveFrontendAndBackendSystemsFromFeatureTest method canDeriveFrontendAndBackendSystemContexts.

@ParameterizedTest
@ValueSource(strings = { "derive-frontend-backend-from-feature-test-6-input.cml" })
public void canDeriveFrontendAndBackendSystemContexts(String inputFile) throws IOException {
    // given
    CMLResource input = getResourceCopyOfTestCML(inputFile);
    DeriveFrontendAndBackendSystemsFromFeature ar = new DeriveFrontendAndBackendSystemsFromFeature("TestSystem", ACL);
    ar.setBackendName("TestBackend");
    ar.setFrontendName("TestFrontend");
    // when
    ar.refactor(input);
    ar.persistChanges(serializer);
    // then
    ContextMappingModel model = reloadResource(input).getContextMappingModel();
    Set<String> bcNames = model.getBoundedContexts().stream().map(bc -> bc.getName()).collect(Collectors.toSet());
    // model already contains two BCs
    assertEquals(4, model.getBoundedContexts().size());
    assertTrue(bcNames.contains("TestSystem"));
    assertTrue(bcNames.contains("TestBackend"));
    assertTrue(bcNames.contains("TestFrontend"));
    BoundedContext frontend = model.getBoundedContexts().stream().filter(bc -> bc.getName().equals("TestFrontend")).findFirst().get();
    assertEquals(BoundedContextType.SYSTEM, frontend.getType());
    BoundedContext backend = model.getBoundedContexts().stream().filter(bc -> bc.getName().equals("TestBackend")).findFirst().get();
    assertEquals(BoundedContextType.SYSTEM, backend.getType());
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) UpstreamRole(org.contextmapper.dsl.contextMappingDSL.UpstreamRole) BoundedContextType(org.contextmapper.dsl.contextMappingDSL.BoundedContextType) CONFORMIST(org.contextmapper.dsl.refactoring.ContextSplittingIntegrationType.CONFORMIST) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Charset(java.nio.charset.Charset) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ACL(org.contextmapper.dsl.refactoring.ContextSplittingIntegrationType.ACL) ValueSource(org.junit.jupiter.params.provider.ValueSource) Set(java.util.Set) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Collectors(java.util.stream.Collectors) File(java.io.File) Test(org.junit.jupiter.api.Test) RefactoringInputException(org.contextmapper.dsl.refactoring.exception.RefactoringInputException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Paths(java.nio.file.Paths) DownstreamRole(org.contextmapper.dsl.contextMappingDSL.DownstreamRole) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SculptorModule(org.contextmapper.dsl.contextMappingDSL.SculptorModule) NullSource(org.junit.jupiter.params.provider.NullSource) ContextMap(org.contextmapper.dsl.contextMappingDSL.ContextMap) CMLResource(org.contextmapper.dsl.cml.CMLResource) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) CMLResource(org.contextmapper.dsl.cml.CMLResource) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with ACL

use of org.contextmapper.dsl.refactoring.ContextSplittingIntegrationType.ACL in project context-mapper-dsl by ContextMapper.

the class DeriveFrontendAndBackendSystemsFromFeatureTest method canAddExposedAggregatesToNewRelationship.

@Test
public void canAddExposedAggregatesToNewRelationship() throws IOException {
    // given
    CMLResource input = getResourceCopyOfTestCML("derive-frontend-backend-from-feature-test-5-input.cml");
    DeriveFrontendAndBackendSystemsFromFeature ar = new DeriveFrontendAndBackendSystemsFromFeature("TestFeature", ACL);
    // when
    ar.refactor(input);
    ar.persistChanges(serializer);
    // then
    UpstreamDownstreamRelationship relationship = (UpstreamDownstreamRelationship) reloadResource(input).getContextMappingModel().getMap().getRelationships().get(0);
    assertNotNull(relationship);
    assertEquals(2, relationship.getUpstreamExposedAggregates().size());
    Set<String> exposedAggregateNames = relationship.getUpstreamExposedAggregates().stream().map(agg -> agg.getName()).collect(Collectors.toSet());
    assertTrue(exposedAggregateNames.contains("TestAggregateBackend"));
    assertTrue(exposedAggregateNames.contains("TestAggregateInModuleBackend_2"));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) UpstreamRole(org.contextmapper.dsl.contextMappingDSL.UpstreamRole) BoundedContextType(org.contextmapper.dsl.contextMappingDSL.BoundedContextType) CONFORMIST(org.contextmapper.dsl.refactoring.ContextSplittingIntegrationType.CONFORMIST) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Charset(java.nio.charset.Charset) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ACL(org.contextmapper.dsl.refactoring.ContextSplittingIntegrationType.ACL) ValueSource(org.junit.jupiter.params.provider.ValueSource) Set(java.util.Set) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Collectors(java.util.stream.Collectors) File(java.io.File) Test(org.junit.jupiter.api.Test) RefactoringInputException(org.contextmapper.dsl.refactoring.exception.RefactoringInputException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Paths(java.nio.file.Paths) DownstreamRole(org.contextmapper.dsl.contextMappingDSL.DownstreamRole) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SculptorModule(org.contextmapper.dsl.contextMappingDSL.SculptorModule) NullSource(org.junit.jupiter.params.provider.NullSource) ContextMap(org.contextmapper.dsl.contextMappingDSL.ContextMap) CMLResource(org.contextmapper.dsl.cml.CMLResource) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) CMLResource(org.contextmapper.dsl.cml.CMLResource) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 Charset (java.nio.charset.Charset)2 Paths (java.nio.file.Paths)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 FileUtils (org.apache.commons.io.FileUtils)2 CMLResource (org.contextmapper.dsl.cml.CMLResource)2 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)2 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)2 BoundedContextType (org.contextmapper.dsl.contextMappingDSL.BoundedContextType)2 ContextMap (org.contextmapper.dsl.contextMappingDSL.ContextMap)2 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)2 DownstreamRole (org.contextmapper.dsl.contextMappingDSL.DownstreamRole)2 SculptorModule (org.contextmapper.dsl.contextMappingDSL.SculptorModule)2 UpstreamDownstreamRelationship (org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship)2 UpstreamRole (org.contextmapper.dsl.contextMappingDSL.UpstreamRole)2 ACL (org.contextmapper.dsl.refactoring.ContextSplittingIntegrationType.ACL)2 CONFORMIST (org.contextmapper.dsl.refactoring.ContextSplittingIntegrationType.CONFORMIST)2 RefactoringInputException (org.contextmapper.dsl.refactoring.exception.RefactoringInputException)2