Search in sources :

Example 1 with ModelTypeException

use of org.camunda.bpm.model.xml.impl.util.ModelTypeException in project camunda-xml-model by camunda.

the class AbstractModelElementInstanceTest method testType.

@Test
public void testType() {
    assertThatType().isPartOfModel(model);
    TypeAssumption assumption = getTypeAssumption();
    assertThatType().hasTypeNamespace(assumption.namespaceUri);
    if (assumption.isAbstract) {
        assertThatType().isAbstract();
    } else {
        assertThatType().isNotAbstract();
    }
    if (assumption.extendsType == null) {
        assertThatType().extendsNoType();
    } else {
        assertThatType().extendsType(assumption.extendsType);
    }
    if (assumption.isAbstract) {
        try {
            modelInstance.newInstance(modelElementType);
            fail("Element type " + modelElementType.getTypeName() + " is abstract.");
        } catch (DOMException e) {
        // expected exception
        } catch (ModelTypeException e) {
        // expected exception
        } catch (Exception e) {
            fail("Unexpected exception " + e.getMessage());
        }
    } else {
        ModelElementInstance modelElementInstance = modelInstance.newInstance(modelElementType);
        assertThat(modelElementInstance).isNotNull();
    }
}
Also used : DOMException(org.w3c.dom.DOMException) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) DOMException(org.w3c.dom.DOMException) ModelTypeException(org.camunda.bpm.model.xml.impl.util.ModelTypeException) ModelTypeException(org.camunda.bpm.model.xml.impl.util.ModelTypeException) Test(org.junit.Test)

Aggregations

ModelTypeException (org.camunda.bpm.model.xml.impl.util.ModelTypeException)1 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)1 Test (org.junit.Test)1 DOMException (org.w3c.dom.DOMException)1