Search in sources :

Example 1 with OutputClauseUnaryTests

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;
}
Also used : JSITOutputClause(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITOutputClause) OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) OutputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.OutputClauseLiteralExpression) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) OutputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests)

Example 2 with OutputClauseUnaryTests

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;
}
Also used : QName(javax.xml.namespace.QName) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) OutputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests)

Example 3 with OutputClauseUnaryTests

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);
}
Also used : OutputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests)

Example 4 with OutputClauseUnaryTests

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();
}
Also used : OutputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests) Test(org.junit.Test)

Example 5 with OutputClauseUnaryTests

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);
}
Also used : OutputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests) Test(org.junit.Test)

Aggregations

OutputClauseUnaryTests (org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests)10 Test (org.junit.Test)5 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 JSITUnaryTests (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests)3 QName (javax.xml.namespace.QName)2 ConstraintType (org.kie.workbench.common.dmn.api.definition.model.ConstraintType)2 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)2 OutputClauseLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.OutputClauseLiteralExpression)2 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)2 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)2 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)2 JSITOutputClause (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITOutputClause)1