use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.PredefinedService 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());
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.PredefinedService in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsExampleFactory method createSamplePredefinedServices.
private List<PredefinedService> createSamplePredefinedServices() {
List<PredefinedService> predefinedServices = Lists.newArrayList();
for (BoundedContext boundedContext : this.contextMappingModel.getBoundedContexts()) {
List<Attribute> attributes = collectAttributes(boundedContext);
PredefinedService predefinedService = factory.createPredefinedService();
predefinedService.setName(boundedContext.getName());
predefinedService.setDoc("/* This predefined service is based on your '" + boundedContext.getName() + "' BoundedContext. You do not have to change it. */");
predefinedService.getNanoentities().addAll(convertAttributesToNanoEntites(attributes));
predefinedServices.add(predefinedService);
}
return predefinedServices;
}
use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.PredefinedService in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsBuilder method buildPredefinedServices.
private void buildPredefinedServices() {
model.getPredefinedServices().clear();
for (BoundedContext bc : contextMappingModel.getBoundedContexts()) {
if (bc.getType().equals(BoundedContextType.TEAM))
continue;
PredefinedService predefinedService = factory.createPredefinedService();
predefinedService.setName(bc.getName());
predefinedService.getNanoentities().addAll(nanoentityResolver.getAllNanoentities(bc));
model.getPredefinedServices().add(predefinedService);
}
if (!model.getPredefinedServices().isEmpty())
model.getPredefinedServices().get(0).setDoc("/* These predefined services are generated from the CML model. Note that they are overwritten each time you use the service cut generator! */");
}
Aggregations