Search in sources :

Example 1 with ContextMappingModel

use of org.contextmapper.dsl.contextMappingDSL.ContextMappingModel in project context-mapper-dsl by ContextMapper.

the class ServiceCutterUserRepresentationsExampleGeneratorTest method canCreateUserRepresentationsFile.

@Test
void canCreateUserRepresentationsFile() {
    // given
    ContextMappingModel model = ContextMappingDSLFactory.eINSTANCE.createContextMappingModel();
    ContextMap contextMap = ContextMappingDSLFactory.eINSTANCE.createContextMap();
    BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
    boundedContext.setName("TestContext");
    contextMap.getBoundedContexts().add(boundedContext);
    model.getBoundedContexts().add(boundedContext);
    model.setMap(contextMap);
    // when
    IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
    this.generator.doGenerate(new ContextMappingModelResourceMock(model, URI.createFileURI(new File(Paths.get("").toAbsolutePath().toString(), dummyInputFilePath).getAbsolutePath())), filesystem, new IGeneratorContextMock());
    // then
    File resultFile = new File(Paths.get("").toAbsolutePath().toString(), resultFiltPath);
    assertTrue(resultFile.exists());
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) IFileSystemAccess2Mock(org.contextmapper.dsl.generators.mocks.IFileSystemAccess2Mock) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) IGeneratorContextMock(org.contextmapper.dsl.generators.mocks.IGeneratorContextMock) ContextMappingModelResourceMock(org.contextmapper.dsl.generators.mocks.ContextMappingModelResourceMock) File(java.io.File) ContextMap(org.contextmapper.dsl.contextMappingDSL.ContextMap) Test(org.junit.jupiter.api.Test)

Example 2 with ContextMappingModel

use of org.contextmapper.dsl.contextMappingDSL.ContextMappingModel in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilderTest method canGenerateConsistencyCriticalityCompatibilitiesFromCML.

@Test
public void canGenerateConsistencyCriticalityCompatibilitiesFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-7.cml").getContextMappingModel();
    // when
    ServiceCutterUserRepresentationsModel scModel = new UserRepresentationsBuilder(inputModel).build();
    // then
    assertNotNull(scModel.getCompatibilities());
    Compatibilities compatibilities = scModel.getCompatibilities();
    assertFalse(compatibilities.getConsistencyCriticality().isEmpty());
    assertEquals(3, compatibilities.getConsistencyCriticality().size());
    ConsistencyCriticality normal = compatibilities.getConsistencyCriticality().stream().filter(sv -> sv.getCharacteristic().equals("Eventually")).findFirst().get();
    ConsistencyCriticality high = compatibilities.getConsistencyCriticality().stream().filter(sv -> sv.getCharacteristic().equals("High")).findFirst().get();
    ConsistencyCriticality low = compatibilities.getConsistencyCriticality().stream().filter(sv -> sv.getCharacteristic().equals("Weak")).findFirst().get();
    assertNotNull(normal);
    assertNotNull(high);
    assertNotNull(low);
    assertTrue(normal.getNanoentities().contains("Customer.testAttr1"));
    assertTrue(high.getNanoentities().contains("Customer.testAttr2"));
    assertTrue(low.getNanoentities().contains("Customer.testAttr3"));
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) UserRepresentationsBuilder(org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder) ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) ConsistencyCriticality(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ConsistencyCriticality) Compatibilities(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Compatibilities) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 3 with ContextMappingModel

use of org.contextmapper.dsl.contextMappingDSL.ContextMappingModel in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilderTest method canGenerateSharedOwnerGroupsFromCML.

@Test
public void canGenerateSharedOwnerGroupsFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-3.cml").getContextMappingModel();
    // when
    UserRepresentationsBuilder builder = new UserRepresentationsBuilder(inputModel);
    ServiceCutterUserRepresentationsModel scModel = builder.build();
    // then
    assertEquals(1, scModel.getSharedOwnerGroups().size());
    SharedOwnerGroup ownerGroup = scModel.getSharedOwnerGroups().get(0);
    assertEquals("TeamA", ownerGroup.getName());
    assertEquals(1, ownerGroup.getNanoentities().size());
    assertEquals("TestEntity.attribute1", ownerGroup.getNanoentities().get(0));
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) UserRepresentationsBuilder(org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder) ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) SharedOwnerGroup(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.SharedOwnerGroup) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 4 with ContextMappingModel

use of org.contextmapper.dsl.contextMappingDSL.ContextMappingModel in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilderTest method canGenerateUseCasesFromCML.

@Test
public void canGenerateUseCasesFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-1.cml").getContextMappingModel();
    // when
    UserRepresentationsBuilder builder = new UserRepresentationsBuilder(inputModel);
    ServiceCutterUserRepresentationsModel scModel = builder.build();
    // then
    assertEquals(1, scModel.getUseCases().size());
    UseCase useCase = scModel.getUseCases().get(0);
    assertEquals(10, useCase.getNanoentitiesRead().size());
    assertEquals(10, useCase.getNanoentitiesWritten().size());
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) UserRepresentationsBuilder(org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder) ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) UseCase(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 5 with ContextMappingModel

use of org.contextmapper.dsl.contextMappingDSL.ContextMappingModel in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilderTest method canGeneratePredefinedServicesFromCML.

@Test
public void canGeneratePredefinedServicesFromCML() throws IOException {
    // given
    ContextMappingModel inputModel = getOriginalResourceOfTestCML("user-representations-builder-test-2.cml").getContextMappingModel();
    // when
    UserRepresentationsBuilder builder = new UserRepresentationsBuilder(inputModel);
    ServiceCutterUserRepresentationsModel scModel = builder.build();
    // then
    assertEquals(1, scModel.getPredefinedServices().size());
    PredefinedService predefinedService = scModel.getPredefinedServices().get(0);
    assertEquals("TestContext", predefinedService.getName());
    assertEquals(2, predefinedService.getNanoentities().size());
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) UserRepresentationsBuilder(org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder) ServiceCutterUserRepresentationsModel(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel) PredefinedService(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.PredefinedService) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Aggregations

ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)180 Test (org.junit.jupiter.api.Test)147 CMLResource (org.contextmapper.dsl.cml.CMLResource)79 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)63 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)61 ContextMap (org.contextmapper.dsl.contextMappingDSL.ContextMap)46 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)46 Collectors (java.util.stream.Collectors)41 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)41 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)39 IOException (java.io.IOException)36 List (java.util.List)35 UpstreamDownstreamRelationship (org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship)35 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)31 ContextMappingModelResourceMock (org.contextmapper.dsl.generators.mocks.ContextMappingModelResourceMock)30 IFileSystemAccess2Mock (org.contextmapper.dsl.generators.mocks.IFileSystemAccess2Mock)30 IGeneratorContextMock (org.contextmapper.dsl.generators.mocks.IGeneratorContextMock)30 Flow (org.contextmapper.dsl.contextMappingDSL.Flow)27 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)25 SketchMinerModelCreator (org.contextmapper.dsl.generator.sketchminer.SketchMinerModelCreator)20