use of org.contextmapper.tactic.dsl.tacticdsl.Enum in project context-mapper-dsl by ContextMapper.
the class PlantUMLBoundedContextClassDiagramCreatorTest method canCreateEnum.
@Test
public void canCreateEnum() {
// given
BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
Aggregate aggregate = ContextMappingDSLFactory.eINSTANCE.createAggregate();
aggregate.setName("testAggregate");
boundedContext.getAggregates().add(aggregate);
Enum enumm = TacticdslFactory.eINSTANCE.createEnum();
enumm.setName("TestType");
EnumValue value1 = TacticdslFactory.eINSTANCE.createEnumValue();
value1.setName("VAL1");
EnumValue value2 = TacticdslFactory.eINSTANCE.createEnumValue();
value2.setName("VAL2");
enumm.getValues().add(value1);
enumm.getValues().add(value2);
aggregate.getDomainObjects().add(enumm);
// when
String plantUML = this.creator.createDiagram(boundedContext);
// then
assertTrue(plantUML.contains(" enum TestType {" + System.lineSeparator() + " VAL1" + System.lineSeparator() + " VAL2" + System.lineSeparator() + " }" + System.lineSeparator()));
}
use of org.contextmapper.tactic.dsl.tacticdsl.Enum in project context-mapper-dsl by ContextMapper.
the class MDSLDataTypeCreator method createComplexType.
private DataType createComplexType(String complexTypeName, ComplexType type) {
// do not create new type if a type with the given name already exists
if (dataTypeMapping.containsKey(complexTypeName) && !(dataTypeMapping.get(complexTypeName).isAbstractDataType()))
return dataTypeMapping.get(complexTypeName);
DataType dataType = new DataType();
dataType.setName(complexTypeName);
dataTypeMapping.put(complexTypeName, dataType);
// add attributes if available
if (type.getDomainObjectType() != null && type.getDomainObjectType() instanceof Enum) {
dataType.setIsEnumType(true);
dataType.addAttributes(createAttributesForEnum((Enum) type.getDomainObjectType()));
} else if (type.getDomainObjectType() != null && type.getDomainObjectType() instanceof DomainObject) {
DomainObject object = (DomainObject) type.getDomainObjectType();
dataType.addAttributes(createAttributes4AttributeList(getDomainObjectAttributes(object)));
dataType.addAttributes(createAttributes4ReferencesList(getDomainObjectReferences(object)));
}
return dataType;
}
Aggregations