Search in sources :

Example 1 with CONFORMIST

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

the class DeriveFrontendAndBackendSystemsFromFeatureTest method canDeriveUpstreamDownstreamRelationship.

@Test
public void canDeriveUpstreamDownstreamRelationship() throws IOException {
    // given
    CMLResource input = getResourceCopyOfTestCML("derive-frontend-backend-from-feature-test-1-input.cml");
    DeriveFrontendAndBackendSystemsFromFeature ar = new DeriveFrontendAndBackendSystemsFromFeature("TestFeature", CONFORMIST);
    // when
    ar.refactor(input);
    ar.persistChanges(serializer);
    // then
    ContextMappingModel model = reloadResource(input).getContextMappingModel();
    assertNotNull(model.getMap());
    ContextMap map = model.getMap();
    assertEquals(1, map.getRelationships().size());
    UpstreamDownstreamRelationship relationship = (UpstreamDownstreamRelationship) map.getRelationships().get(0);
    assertEquals("TestFeatureFrontend", relationship.getDownstream().getName());
    assertEquals("TestFeatureBackend", relationship.getUpstream().getName());
    assertTrue(relationship.getUpstreamRoles().contains(UpstreamRole.PUBLISHED_LANGUAGE));
    assertTrue(relationship.getDownstreamRoles().contains(DownstreamRole.CONFORMIST));
    assertFalse(relationship.getDownstreamRoles().contains(DownstreamRole.ANTICORRUPTION_LAYER));
    Set<String> boundedContextsRegisteredOnContextMap = map.getBoundedContexts().stream().map(bc -> bc.getName()).collect(Collectors.toSet());
    assertTrue(boundedContextsRegisteredOnContextMap.contains("TestFeatureFrontend"));
    assertTrue(boundedContextsRegisteredOnContextMap.contains("TestFeatureBackend"));
}
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) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) ContextMap(org.contextmapper.dsl.contextMappingDSL.ContextMap) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

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