use of org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests in project kie-wb-common by kiegroup.
the class OutputClausePropertyConverter method wbFromDMN.
public static OutputClause wbFromDMN(final JSITOutputClause dmn) {
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final OutputClauseUnaryTests outputValues = OutputClauseUnaryTestsPropertyConverter.wbFromDMN(dmn.getOutputValues());
final OutputClauseLiteralExpression defaultOutputEntry = OutputClauseLiteralExpressionPropertyConverter.wbFromDMN(dmn.getDefaultOutputEntry());
final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
final OutputClause result = new OutputClause();
result.setId(id);
result.setName(dmn.getName());
result.setDescription(description);
result.setOutputValues(outputValues);
result.setDefaultOutputEntry(defaultOutputEntry);
result.setTypeRef(typeRef);
if (Objects.nonNull(outputValues)) {
outputValues.setParent(result);
}
if (Objects.nonNull(defaultOutputEntry)) {
defaultOutputEntry.setParent(result);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests in project kie-wb-common by kiegroup.
the class OutputClauseUnaryTestsPropertyConverter method wbFromDMN.
/**
* Returns a non-null instance of OutputClauseUnaryTestsPropertyConverter. The Properties Panel needs
* non-null objects to bind therefore a concrete object must always be returned.
* @param dmn
* @return
*/
public static OutputClauseUnaryTests wbFromDMN(final JSITUnaryTests dmn) {
if (Objects.isNull(dmn)) {
return new OutputClauseUnaryTests();
}
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
final Map<QName, String> otherAttributes = JSITUnaryTests.getOtherAttributesMap(dmn);
final String constraintString = otherAttributes.getOrDefault(key, "");
final ConstraintType constraint = ConstraintType.fromString(constraintString);
final OutputClauseUnaryTests result = new OutputClauseUnaryTests(id, new Text(dmn.getText()), constraint);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests in project kie-wb-common by kiegroup.
the class OutputClauseUnaryTestsPropertyConverterTest method testWbFromDMN.
public void testWbFromDMN(final ConstraintType constraintType) {
when(additionalAttributes.getOrDefault(key, "")).thenReturn(constraintType.value());
final OutputClauseUnaryTests outputClause = OutputClauseUnaryTestsPropertyConverter.wbFromDMN(dmnUnary);
assertEquals(outputClause.getConstraintType(), constraintType);
assertEquals(outputClause.getId().getValue(), ID);
assertEquals(outputClause.getText().getValue(), TEXT);
}
use of org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests in project kie-wb-common by kiegroup.
the class OutputClauseUnaryTestsPropertyConverterTest method testWBFromDMNWhenNull.
@Test
public void testWBFromDMNWhenNull() {
final OutputClauseUnaryTests wb = OutputClauseUnaryTestsPropertyConverter.wbFromDMN(null);
assertThat(wb).isNotNull();
}
use of org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests in project kie-wb-common by kiegroup.
the class OutputClauseUnaryTestsPropertyConverterTest method testWBFromDMNWhenNonNull.
@Test
public void testWBFromDMNWhenNonNull() {
when(jsitUnaryTests.getText()).thenReturn(TEXT);
final OutputClauseUnaryTests wb = OutputClauseUnaryTestsPropertyConverter.wbFromDMN(jsitUnaryTests);
assertThat(wb).isNotNull();
assertThat(wb.getText().getValue()).isEqualTo(TEXT);
}
Aggregations