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