use of org.contextmapper.dsl.generators.mocks.ContextMappingModelResourceMock 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());
}
use of org.contextmapper.dsl.generators.mocks.ContextMappingModelResourceMock 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"));
}
use of org.contextmapper.dsl.generators.mocks.ContextMappingModelResourceMock 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"));
}
use of org.contextmapper.dsl.generators.mocks.ContextMappingModelResourceMock 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());
});
}
use of org.contextmapper.dsl.generators.mocks.ContextMappingModelResourceMock 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());
});
}
Aggregations