Search in sources :

Example 26 with ModelElementType

use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-xml-model by camunda.

the class ModelElementTypeAssert method isNotExtendedBy.

public ModelElementTypeAssert isNotExtendedBy(ModelElementType... types) {
    isNotNull();
    List<ModelElementType> notExtendingTypes = Arrays.asList(types);
    Collection<ModelElementType> actualExtendingTypes = actual.getExtendingTypes();
    List<ModelElementType> errorTypes = new ArrayList<ModelElementType>();
    for (ModelElementType notExtendingType : notExtendingTypes) {
        if (actualExtendingTypes.contains(notExtendingType)) {
            errorTypes.add(notExtendingType);
        }
    }
    if (!errorTypes.isEmpty()) {
        Collection<String> errorTypeNames = getTypeNames(errorTypes);
        Collection<String> notExtendingTypeNames = getTypeNames(notExtendingTypes);
        failWithMessage("Expected element type <%s> to be not extended by types <%s> but is extended by <%s>", typeName, notExtendingTypeNames, errorTypeNames);
    }
    return this;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) ArrayList(java.util.ArrayList)

Example 27 with ModelElementType

use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-xml-model by camunda.

the class ModelElementTypeAssert method extendsNoType.

public ModelElementTypeAssert extendsNoType() {
    isNotNull();
    ModelElementType actualBaseType = actual.getBaseType();
    if (actualBaseType != null) {
        failWithMessage("Expected element type <%s> to not extend any type but extends <%s>", typeName, actualBaseType.getTypeName());
    }
    return this;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType)

Example 28 with ModelElementType

use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-xml-model by camunda.

the class ModelTest method testGetTypeForName.

@Test
public void testGetTypeForName() {
    ModelElementType birdType = model.getTypeForName(ELEMENT_NAME_BIRD);
    assertThat(birdType).isNull();
    birdType = model.getTypeForName(MODEL_NAMESPACE, ELEMENT_NAME_BIRD);
    assertThat(birdType.getInstanceType()).isEqualTo(Bird.class);
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) Test(org.junit.Test)

Example 29 with ModelElementType

use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-xml-model by camunda.

the class UnknownAnimalTest method testGetUnknownAnimalByType.

@Test
public void testGetUnknownAnimalByType() {
    ModelInstanceImpl modelInstanceImpl = (ModelInstanceImpl) modelInstance;
    ModelElementType unknownAnimalType = modelInstanceImpl.registerGenericType(MODEL_NAMESPACE, "unknownAnimal");
    List<ModelElementInstance> unknownAnimals = new ArrayList<ModelElementInstance>(modelInstance.getModelElementsByType(unknownAnimalType));
    assertThat(unknownAnimals).hasSize(2);
    ModelElementInstance wanda = unknownAnimals.get(0);
    assertThat(wanda.getAttributeValue("id")).isEqualTo("wanda");
    assertThat(wanda.getAttributeValue("gender")).isEqualTo("Female");
    assertThat(wanda.getAttributeValue("species")).isEqualTo("fish");
    ModelElementInstance flipper = unknownAnimals.get(1);
    assertThat(flipper.getAttributeValue("id")).isEqualTo("flipper");
    assertThat(flipper.getAttributeValue("gender")).isEqualTo("Male");
    assertThat(flipper.getAttributeValue("species")).isEqualTo("dolphin");
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) ArrayList(java.util.ArrayList) ModelInstanceImpl(org.camunda.bpm.model.xml.impl.ModelInstanceImpl) Test(org.junit.Test)

Example 30 with ModelElementType

use of org.camunda.bpm.model.xml.type.ModelElementType in project camunda-xml-model by camunda.

the class AttributeTest method testOwningElementType.

@Test
public void testOwningElementType() {
    ModelElementType animalType = modelInstance.getModel().getType(Animal.class);
    assertThat(idAttribute).hasOwningElementType(animalType);
    assertThat(nameAttribute).hasOwningElementType(animalType);
    assertThat(fatherAttribute).hasOwningElementType(animalType);
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) Test(org.junit.Test) TestModelTest(org.camunda.bpm.model.xml.testmodel.TestModelTest) AnimalTest(org.camunda.bpm.model.xml.testmodel.instance.AnimalTest)

Aggregations

ModelElementType (org.camunda.bpm.model.xml.type.ModelElementType)34 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)9 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)8 Model (org.camunda.bpm.model.xml.Model)3 TestModelTest (org.camunda.bpm.model.xml.testmodel.TestModelTest)3 ModelException (org.camunda.bpm.model.xml.ModelException)2 ModelInstanceImpl (org.camunda.bpm.model.xml.impl.ModelInstanceImpl)2 ModelElementTypeImpl (org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)2 DomElement (org.camunda.bpm.model.xml.instance.DomElement)2 Before (org.junit.Before)2 PlanItemDefinition (org.camunda.bpm.model.cmmn.instance.PlanItemDefinition)1 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)1 ModelBuildOperation (org.camunda.bpm.model.xml.impl.ModelBuildOperation)1 QName (org.camunda.bpm.model.xml.impl.util.QName)1 AnimalTest (org.camunda.bpm.model.xml.testmodel.instance.AnimalTest)1 Attribute (org.camunda.bpm.model.xml.type.attribute.Attribute)1 Reference (org.camunda.bpm.model.xml.type.reference.Reference)1