Search in sources :

Example 1 with Aggregate

use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Aggregate in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsExampleFactory method createSampleAggregates.

private List<Aggregate> createSampleAggregates() {
    List<org.contextmapper.dsl.contextMappingDSL.Aggregate> existingAggregates = collectAggregates();
    List<Aggregate> aggregates = Lists.newArrayList();
    if (existingAggregates.size() > 0) {
        for (org.contextmapper.dsl.contextMappingDSL.Aggregate aggregate : existingAggregates) {
            List<Attribute> aggregateAttributes = collectAttributes(aggregate);
            Aggregate scAggregate = factory.createAggregate();
            scAggregate.setName(aggregate.getName());
            scAggregate.setDoc("/* This aggregate was generated by your CML model. You do not have to change it. */");
            scAggregate.getNanoentities().addAll(convertAttributesToNanoEntites(aggregateAttributes));
            aggregates.add(scAggregate);
        }
    } else if (allModelAttributes.size() > 0) {
        Aggregate sampleAggregate = factory.createAggregate();
        sampleAggregate.setDoc("/* This is just a sample aggregate (template). \n" + "* Note that if your CML model had Aggregates within the Bounded Contexts, they would have been generated at this place! */");
        sampleAggregate.setName("SampleAggregate");
        sampleAggregate.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
        sampleAggregate.getNanoentities().add(randomlyPickAttribute(allModelAttributes));
        aggregates.add(sampleAggregate);
    }
    return aggregates;
}
Also used : Attribute(org.contextmapper.tactic.dsl.tacticdsl.Attribute) Aggregate(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Aggregate)

Example 2 with Aggregate

use of org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Aggregate in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilderTest method canGenerateAggregatesFromCML.

@Test
public void canGenerateAggregatesFromCML() 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.getAggregates().size());
    Aggregate aggregate = scModel.getAggregates().get(0);
    assertEquals("TestAggregate", aggregate.getName());
    assertEquals(2, aggregate.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) Aggregate(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Aggregate) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Aggregations

Aggregate (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Aggregate)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