use of org.kie.dmn.validation.dtanalysis.mcdc.dmntck.TestCases.TestCase.ResultNode in project drools by kiegroup.
the class MCDC2TCKGenerator method appendRecordToTestCases.
private static void appendRecordToTestCases(DecisionTable dt, TestCases testCases, String withId, Record record) {
ObjectFactory factory = new ObjectFactory();
TestCase testCase = factory.createTestCasesTestCase().withId("mcdc_" + withId).withName("Test case " + withId);
testCase.withDescription(record.toString());
for (int i = 0; i < record.enums.length; i++) {
Object en = record.enums[i];
String inputName = dt.getInput().get(i).getInputExpression().getText();
InputNode inputNode = factory.createTestCasesTestCaseInputNode().withName(inputName);
testCase.withInputNode(inputNode);
JAXBElement<Object> jaxbElement = factory.createValueTypeValue(en);
inputNode.withValue(jaxbElement);
}
if (record.output.size() == 1) {
Object out = record.output.get(0);
String outputName = dt.getOutputLabel();
ResultNode resultNode = factory.createTestCasesTestCaseResultNode().withName(outputName);
testCase.withResultNode(resultNode);
JAXBElement<Object> jaxbElement = factory.createValueTypeValue(out);
resultNode.withExpected(factory.createValueType().withValue(jaxbElement));
} else {
throw new UnsupportedOperationException();
}
testCases.withTestCase(testCase);
}
Aggregations