Commit c1258ed5 authored by R.W.Majeed's avatar R.W.Majeed

test case for fact class annotation

parent bfadf0ec
package de.sekmi.histream.export.config;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import de.sekmi.histream.export.FactClassAnnotator;
import de.sekmi.histream.impl.ObservationImplJAXBTest;
import de.sekmi.histream.xml.XMLUtils;
public class TestFactClassAnnotator {
@Test
public void validateAnnotation() throws Exception{
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
f.setNamespaceAware(true);
f.setIgnoringElementContentWhitespace(true);
DocumentBuilder b = f.newDocumentBuilder();
Document dom = null;
try( InputStream in = ObservationImplJAXBTest.class.getResourceAsStream("/fact1.xml") ){
dom = b.parse(in);
}
Element el = (Element)dom.getFirstChild();
// before annotation
Assert.assertEquals("fact", el.getLocalName());
// attribute not available will return empty string
Assert.assertEquals("", el.getAttribute("class"));
// annotate
FactClassAnnotator fa = new FactClassAnnotator();
fa.addMapRule("T:testconcept1", "class1");
fa.annotateFact(el);
// after annotation
Assert.assertEquals("class1", el.getAttribute("class"));
// XMLUtils.printDOM(dom, System.out);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment