Search in sources :

Example 1 with IGeneratorContextMock

use of org.contextmapper.dsl.generators.mocks.IGeneratorContextMock 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 IGeneratorContextMock

use of org.contextmapper.dsl.generators.mocks.IGeneratorContextMock in project context-mapper-dsl by ContextMapper.

the class PlantUMLGeneratorTest method canCreatePlantUMLDiagrmFiles4SubdomainIfEntitiesAvailable.

@Test
void canCreatePlantUMLDiagrmFiles4SubdomainIfEntitiesAvailable() {
    // given
    ContextMappingModel model = ContextMappingDSLFactory.eINSTANCE.createContextMappingModel();
    Domain domain = ContextMappingDSLFactory.eINSTANCE.createDomain();
    Subdomain subdomain1 = ContextMappingDSLFactory.eINSTANCE.createSubdomain();
    domain.setName("TestDomain");
    subdomain1.setName("TestSubdomain1");
    Subdomain subdomain2 = ContextMappingDSLFactory.eINSTANCE.createSubdomain();
    subdomain2.setName("TestSubdomain2");
    domain.getSubdomains().add(subdomain1);
    domain.getSubdomains().add(subdomain2);
    subdomain2.getEntities().add(createTestEntity("TestEntity"));
    model.getDomains().add(domain);
    // when
    IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
    this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
    // then
    assertFalse(filesystem.getGeneratedFilesSet().contains("testmodel_SD_TestSubdomain1.puml"));
    assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_SD_TestSubdomain2.puml"));
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) IFileSystemAccess2Mock(org.contextmapper.dsl.generators.mocks.IFileSystemAccess2Mock) Subdomain(org.contextmapper.dsl.contextMappingDSL.Subdomain) IGeneratorContextMock(org.contextmapper.dsl.generators.mocks.IGeneratorContextMock) Domain(org.contextmapper.dsl.contextMappingDSL.Domain) ContextMappingModelResourceMock(org.contextmapper.dsl.generators.mocks.ContextMappingModelResourceMock) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 3 with IGeneratorContextMock

use of org.contextmapper.dsl.generators.mocks.IGeneratorContextMock in project context-mapper-dsl by ContextMapper.

the class PlantUMLGeneratorTest method canCreateBoundedContextClassDiagramsWithoutContextMap.

@Test
void canCreateBoundedContextClassDiagramsWithoutContextMap() {
    // given
    ContextMappingModel model = ContextMappingDSLFactory.eINSTANCE.createContextMappingModel();
    BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
    boundedContext.setName("TestContext");
    model.getBoundedContexts().add(boundedContext);
    // when
    IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
    this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
    // then
    assertTrue(filesystem.getGeneratedFilesSet().contains("testmodel_BC_TestContext.puml"));
}
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) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 4 with IGeneratorContextMock

use of org.contextmapper.dsl.generators.mocks.IGeneratorContextMock in project context-mapper-dsl by ContextMapper.

the class PlantUMLGeneratorTest method expectExceptionForEmptyContextMappingModel.

@Test
void expectExceptionForEmptyContextMappingModel() {
    ContextMappingModel model = ContextMappingDSLFactory.eINSTANCE.createContextMappingModel();
    IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
    assertThrows(GeneratorInputException.class, () -> {
        this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
    });
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) IFileSystemAccess2Mock(org.contextmapper.dsl.generators.mocks.IFileSystemAccess2Mock) IGeneratorContextMock(org.contextmapper.dsl.generators.mocks.IGeneratorContextMock) ContextMappingModelResourceMock(org.contextmapper.dsl.generators.mocks.ContextMappingModelResourceMock) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 5 with IGeneratorContextMock

use of org.contextmapper.dsl.generators.mocks.IGeneratorContextMock in project context-mapper-dsl by ContextMapper.

the class PlantUMLGeneratorTest method expectExceptionIfThereIsOnlyAnEmptyDomain.

@Test
void expectExceptionIfThereIsOnlyAnEmptyDomain() {
    ContextMappingModel model = ContextMappingDSLFactory.eINSTANCE.createContextMappingModel();
    Domain emptyDomain = ContextMappingDSLFactory.eINSTANCE.createDomain();
    emptyDomain.setName("TestDomain");
    model.getDomains().add(emptyDomain);
    IFileSystemAccess2Mock filesystem = new IFileSystemAccess2Mock();
    assertThrows(GeneratorInputException.class, () -> {
        this.generator.doGenerate(new ContextMappingModelResourceMock(model, "testmodel", "cml"), filesystem, new IGeneratorContextMock());
    });
}
Also used : ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) IFileSystemAccess2Mock(org.contextmapper.dsl.generators.mocks.IFileSystemAccess2Mock) IGeneratorContextMock(org.contextmapper.dsl.generators.mocks.IGeneratorContextMock) Domain(org.contextmapper.dsl.contextMappingDSL.Domain) ContextMappingModelResourceMock(org.contextmapper.dsl.generators.mocks.ContextMappingModelResourceMock) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Aggregations

IFileSystemAccess2Mock (org.contextmapper.dsl.generators.mocks.IFileSystemAccess2Mock)40 IGeneratorContextMock (org.contextmapper.dsl.generators.mocks.IGeneratorContextMock)40 Test (org.junit.jupiter.api.Test)37 ContextMappingModelResourceMock (org.contextmapper.dsl.generators.mocks.ContextMappingModelResourceMock)32 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)30 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)22 ContextMap (org.contextmapper.dsl.contextMappingDSL.ContextMap)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 File (java.io.File)7 GenericContentGenerator (org.contextmapper.dsl.generator.GenericContentGenerator)7 CMLResource (org.contextmapper.dsl.cml.CMLResource)5 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)5 Domain (org.contextmapper.dsl.contextMappingDSL.Domain)3 MDSLContractsGenerator (org.contextmapper.dsl.generator.MDSLContractsGenerator)3 Subdomain (org.contextmapper.dsl.contextMappingDSL.Subdomain)2 NewServiceCutContextMapGenerator (org.contextmapper.dsl.generator.NewServiceCutContextMapGenerator)1 ProtectedRegionReader (org.contextmapper.dsl.generator.mdsl.ProtectedRegionReader)1 ServiceCutterConfigurationModelResourceMock (org.contextmapper.dsl.generators.mocks.ServiceCutterConfigurationModelResourceMock)1 ServiceCutterUserRepresentationsModel (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel)1 CsvSource (org.junit.jupiter.params.provider.CsvSource)1