Search in sources :

Example 1 with PredefinedService

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

Example 2 with PredefinedService

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;
}
Also used : Attribute(org.contextmapper.tactic.dsl.tacticdsl.Attribute) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) PredefinedService(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.PredefinedService)

Example 3 with PredefinedService

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! */");
}
Also used : BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) PredefinedService(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.PredefinedService)

Aggregations

PredefinedService (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.PredefinedService)3 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)2 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)1 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)1 UserRepresentationsBuilder (org.contextmapper.dsl.generator.servicecutter.input.userrepresentations.UserRepresentationsBuilder)1 ServiceCutterUserRepresentationsModel (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.ServiceCutterUserRepresentationsModel)1 Attribute (org.contextmapper.tactic.dsl.tacticdsl.Attribute)1 Test (org.junit.jupiter.api.Test)1