Search in sources :

Example 1 with DMNElement

use of org.kie.dmn.model.api.DMNElement in project drools by kiegroup.

the class DMNElementConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    DMNElement e = (DMNElement) parent;
    if (e.getDescription() != null) {
        writeChildrenNodeAsValue(writer, context, e.getDescription(), DESCRIPTION);
    }
    if (e.getExtensionElements() != null) {
        writeChildrenNode(writer, context, e.getExtensionElements(), EXTENSION_ELEMENTS);
    }
}
Also used : DMNElement(org.kie.dmn.model.api.DMNElement)

Example 2 with DMNElement

use of org.kie.dmn.model.api.DMNElement in project drools by kiegroup.

the class DMNElementConverter method assignAttributes.

@Override
protected void assignAttributes(HierarchicalStreamReader reader, Object parent) {
    super.assignAttributes(reader, parent);
    String id = reader.getAttribute(ID);
    String label = reader.getAttribute(LABEL);
    DMNElement dmne = (DMNElement) parent;
    dmne.setId(id);
    dmne.setLabel(label);
}
Also used : DMNElement(org.kie.dmn.model.api.DMNElement)

Example 3 with DMNElement

use of org.kie.dmn.model.api.DMNElement in project kie-wb-common by kiegroup.

the class DMNDomainValidatorImplTest method testValidationMessageConversion.

@Test
public void testValidationMessageConversion() {
    final String dmnElementUUID = "element-uuid";
    final DMNElement dmnElement1 = mock(DMNElement.class);
    final DMNElement dmnElement2 = mock(DMNElement.class);
    doReturn(resolver).when(domainValidator).getValidatorImportReaderResolver(metadata);
    // Default UUID
    validationMessages.add(makeDMNMessage(DMNMessage.Severity.ERROR, "error", null));
    // Explicit UUID
    when(dmnElement1.getId()).thenReturn(dmnElementUUID);
    validationMessages.add(makeDMNMessage(DMNMessage.Severity.WARN, "warn", dmnElement1));
    // Parent UUID
    when(dmnElement2.getParent()).thenReturn(dmnElement1);
    validationMessages.add(makeDMNMessage(DMNMessage.Severity.INFO, "info", dmnElement2));
    domainValidator.validate(diagram, resultConsumer);
    verify(resultConsumer).accept(domainViolationsArgumentCaptor.capture());
    final Collection<DomainViolation> domainViolations = domainViolationsArgumentCaptor.getValue();
    assertThat(domainViolations).hasSize(3);
    final Iterator<DomainViolation> domainViolationIterator = domainViolations.iterator();
    final DomainViolation domainViolation0 = domainViolationIterator.next();
    assertThat(domainViolation0.getViolationType()).isEqualTo(Violation.Type.ERROR);
    assertThat(domainViolation0.getMessage()).contains("error");
    assertThat(domainViolation0.getUUID()).isEqualTo(DMNDomainValidatorImpl.DEFAULT_UUID);
    final DomainViolation domainViolation1 = domainViolationIterator.next();
    assertThat(domainViolation1.getViolationType()).isEqualTo(Violation.Type.WARNING);
    assertThat(domainViolation1.getMessage()).contains("warn");
    assertThat(domainViolation1.getUUID()).isEqualTo(dmnElementUUID);
    final DomainViolation domainViolation2 = domainViolationIterator.next();
    assertThat(domainViolation2.getViolationType()).isEqualTo(Violation.Type.INFO);
    assertThat(domainViolation2.getMessage()).contains("info");
    assertThat(domainViolation2.getUUID()).isEqualTo(dmnElementUUID);
}
Also used : DMNElement(org.kie.dmn.model.api.DMNElement) DomainViolation(org.kie.workbench.common.stunner.core.validation.DomainViolation) Test(org.junit.Test)

Example 4 with DMNElement

use of org.kie.dmn.model.api.DMNElement in project drools by kiegroup.

the class DMNElementConverter method writeAttributes.

@Override
protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) {
    super.writeAttributes(writer, parent);
    DMNElement e = (DMNElement) parent;
    if (e.getId() != null)
        writer.addAttribute(ID, e.getId());
    if (e.getLabel() != null)
        writer.addAttribute(LABEL, e.getLabel());
}
Also used : DMNElement(org.kie.dmn.model.api.DMNElement)

Aggregations

DMNElement (org.kie.dmn.model.api.DMNElement)4 Test (org.junit.Test)1 DomainViolation (org.kie.workbench.common.stunner.core.validation.DomainViolation)1