use of org.kie.dmn.validation.dtanalysis.mcdc.dmntck.TestCases in project drools by kiegroup.
the class MCDC2TCKGenerator method mcdc2tck.
public static String mcdc2tck(DecisionTable dt, List<PosNegBlock> selectedBlocks) throws JAXBException {
ObjectFactory factory = new ObjectFactory();
TestCases testCases = factory.createTestCases();
Set<Record> mcdcRecords = new LinkedHashSet<>();
int testCaseId = 1;
for (PosNegBlock b : selectedBlocks) {
boolean add = mcdcRecords.add(b.posRecord);
if (add) {
appendRecordToTestCases(dt, testCases, String.valueOf(testCaseId), b.posRecord);
testCaseId++;
}
for (Record negRecord : b.negRecords) {
add = mcdcRecords.add(negRecord);
if (add) {
appendRecordToTestCases(dt, testCases, String.valueOf(testCaseId), negRecord);
testCaseId++;
}
}
}
JAXBContext jaxbContext = JAXBContext.newInstance(TestCases.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
StringWriter sw = new StringWriter();
jaxbMarshaller.marshal(testCases, sw);
return sw.toString();
}
Aggregations