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);
}
}
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);
}
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);
}
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());
}
Aggregations