Search in sources :

Example 1 with Enum

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()));
}
Also used : Enum(org.contextmapper.tactic.dsl.tacticdsl.Enum) EnumValue(org.contextmapper.tactic.dsl.tacticdsl.EnumValue) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Example 2 with Enum

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;
}
Also used : Enum(org.contextmapper.tactic.dsl.tacticdsl.Enum) DomainObject(org.contextmapper.tactic.dsl.tacticdsl.DomainObject) DataType(org.contextmapper.dsl.generator.mdsl.model.DataType)

Aggregations

Enum (org.contextmapper.tactic.dsl.tacticdsl.Enum)2 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)1 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)1 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)1 DataType (org.contextmapper.dsl.generator.mdsl.model.DataType)1 DomainObject (org.contextmapper.tactic.dsl.tacticdsl.DomainObject)1 EnumValue (org.contextmapper.tactic.dsl.tacticdsl.EnumValue)1 Test (org.junit.jupiter.api.Test)1