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());
}
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"));
}
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));
}
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());
}
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());
}
Aggregations