Search in sources :

Example 6 with OutputClauseUnaryTests

use of org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests in project kie-wb-common by kiegroup.

the class OutputClauseUnaryTestsPropertyConverterTest method testDMNFromWBWhenNonNullWithNonEmptyString.

@Test
public void testDMNFromWBWhenNonNullWithNonEmptyString() {
    final OutputClauseUnaryTests wb = new OutputClauseUnaryTests();
    wb.getText().setValue(TEXT);
    final JSITUnaryTests dmn = OutputClauseUnaryTestsPropertyConverter.dmnFromWB(wb);
    assertThat(dmn).isNotNull();
    verify(jsitUnaryTests).setText(TEXT);
}
Also used : JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests) OutputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests) Test(org.junit.Test)

Example 7 with OutputClauseUnaryTests

use of org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests in project kie-wb-common by kiegroup.

the class OutputClauseUnaryTestsPropertyConverterTest method testDMNFromWBWhenNonNullWithEmptyString.

@Test
public void testDMNFromWBWhenNonNullWithEmptyString() {
    final OutputClauseUnaryTests wb = new OutputClauseUnaryTests();
    wb.getText().setValue("");
    final JSITUnaryTests dmn = OutputClauseUnaryTestsPropertyConverter.dmnFromWB(wb);
    assertThat(dmn).isNull();
}
Also used : JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests) OutputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests) Test(org.junit.Test)

Example 8 with OutputClauseUnaryTests

use of org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests in project kie-wb-common by kiegroup.

the class OutputClauseUnaryTestsPropertyConverterTest method testDMNFromWBWhenTextIsNull.

@Test
public void testDMNFromWBWhenTextIsNull() {
    final OutputClauseUnaryTests wb = new OutputClauseUnaryTests();
    wb.setText(null);
    final JSITUnaryTests dmn = OutputClauseUnaryTestsPropertyConverter.dmnFromWB(wb);
    assertThat(dmn).isNull();
}
Also used : JSITUnaryTests(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests) OutputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests) Test(org.junit.Test)

Example 9 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.

public static OutputClauseUnaryTests wbFromDMN(final org.kie.dmn.model.api.UnaryTests dmn) {
    if (dmn == null) {
        return null;
    }
    final Id id = new Id(dmn.getId());
    final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
    final String constraintString = dmn.getAdditionalAttributes().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 10 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 org.kie.dmn.model.api.OutputClause dmn) {
    final Id id = new Id(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(), dmn);
    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 (outputValues != null) {
        outputValues.setParent(result);
    }
    if (defaultOutputEntry != null) {
        defaultOutputEntry.setParent(result);
    }
    return result;
}
Also used : 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)

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