///** // * // */ //package fr.emse.gitlab.saref.tests; // //import java.io.File; //import java.io.FileInputStream; //import java.io.FileNotFoundException; //import java.io.FileOutputStream; //import java.io.OutputStream; //import java.nio.file.Path; //import java.nio.file.Paths; //import java.util.HashMap; //import java.util.HashSet; //import java.util.Map; //import java.util.Set; // //import javax.xml.bind.JAXBContext; //import javax.xml.bind.JAXBException; //import javax.xml.bind.Marshaller; // //import org.apache.jena.rdf.model.Model; //import org.apache.jena.rdf.model.Resource; //import org.apache.jena.riot.Lang; //import org.apache.jena.riot.RDFDataMgr; //import org.apache.jena.riot.RDFFormat; //import org.slf4j.Logger; //import org.slf4j.LoggerFactory; //import org.topbraid.jenax.util.JenaUtil; //import org.topbraid.shacl.validation.ValidationUtil; //import org.topbraid.shacl.vocabulary.SH; // //import com.fasterxml.jackson.core.sym.Name; // //import fr.emse.gitlab.saref.testsuites.TestCase; //import fr.emse.gitlab.saref.testsuites.TestSuite; // ///** // * @author Omar Qawasmeh // * // * // */ //public class ShaclTests { // // // private static Logger logger = LoggerFactory.getLogger(Main.class); // // public static boolean checkShaclShape(File dataTtl, TestCase tstCase, TestSuite tstSuite, String projectID, // String projectName) throws FileNotFoundException { // boolean testResults = true; // // // File fileData = new File(dataTtl); // from String to file // FileInputStream fisDataTtl = new FileInputStream(dataTtl); // from File // // to FIS // // tstCase.setClassName(ShaclTests.class.getName()); // tstCase.setName(new Object() { // }.getClass().getEnclosingMethod().getName()); // // try { // // Model dataModel = JenaUtil.createDefaultModel(); // data model // dataModel.read(fisDataTtl, "", Lang.TURTLE.getLabel()); // read the // // FIS as // // data // // model // // (fisDataTtl) // // String shapeTtl = "sarefShape.ttl"; // shape file, fixed. // // String shapeTtl = "src/main/resources/sarefShape.ttl"; /* shape // // file, fixed. */ // // Model shapeModel = JenaUtil.createDefaultModel(); // shapeModel.read(shapeTtl); // // Resource reportResource = ValidationUtil.validateModel(dataModel, shapeModel, true); // // boolean sameFormat = reportResource.getProperty(SH.conforms).getBoolean(); // // // logger.trace("Conforms = " + sameFormat); // // if (!sameFormat) { // // // System.err.println("Errorr! check your ttl format"); // tstCase.setStatus("danger"); // // tstCase.setSystemErr(new String[] { "Your Ttl file violates // // the Shacl shape format" }); // tstCase.setSystemErr("Your ontology file is missing some metadata"); // // String report = "shacl-report.ttl"; // // File reportFile = new File(report); // // reportFile.createNewFile(); // // OutputStream reportOutputStream = new FileOutputStream(reportFile); // RDFDataMgr.write(reportOutputStream, reportResource.getModel(), RDFFormat.TURTLE); // // // Path reportPath = Paths.get(reportOutputStream.toString()); // // System.err.println(reportFile.getAbsolutePath()); //// tstCase.setInfo("You can download the report shape at: \n \n" + "http://saref.gitlab.emse.fr/-/" //// + projectName + "/-/jobs/" + projectID + "/artifacts/shacl-report.ttl"); // // // tstSuite.setTestcase(new TestCase[] { tstCase }); // // tstSuite.jaxbObjectToXML(tstSuite); // // testResults = false; // // // System.exit(42); // // } else { // // System.out.println("Turtle format is ok"); // // tstCase.setSystemOut(new String[] { "Your Ttl file is // // complete and it follows our shacl shape." }); // tstCase.setSystemOut("Your ontology file contains all the required metadata"); // tstCase.setStatus("success"); // testResults = true; // // } // } catch (Throwable t) { // testResults = false; // tstCase.setStatus("danger"); // tstCase.setSystemErr("Your ontology file is missing some metadata"); // // // tstCase.setSystemErr(new String[] { "Your Ttl file violates the // // Shacl shape format" }); // // System.err.println(t.getMessage()); // // logger.error(t.getMessage()); // } // // return testResults; // // } // //}