use of fr.lirmm.graphik.graal.core.DefaultAtom in project graal by graphik-team.
the class DlgpWriterTest method writeValideURI.
@Test
public void writeValideURI() throws IOException {
String uri = "/a//a///a////a/////a//////" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "´áéíóúýàèìòùỳ¨äëïöüÿâêîôûŷ" + "?¿.:,;!¡~'" + "0123456789₀₁₂₃₄₅₆₇₈₉₍₎₊₋₌ₐₑₒₓₔ⁰¹⁴⁵⁶⁷⁸⁹⁺⁽⁾⁼⁻" + "+-*%=()[]«»_—–#" + "ßæœçåÅøØĐħĦ" + "€$¤£" + "¶¦¬©®™ªº♯♮♭" + "ΑΒΔΕΦΓΗΙΘΚΛΜΝΟΠΧΡΣΤΥΩΞΨΖαβδεφγηιθκλμνοπχρστυωξψζ" + "‰≃≠≮≯≤≥≰≱≲≳Ω¼½¾ƒℓ⅓⅔⅛⅜⅝⅞⩽⩾←↑→↓↔↦⇒⇔∂∙∏∑∆∇√∞∫≈≡∀∃∈∉∪∩⊂⊃♀♂ℝℂℚℕℤℍ⊥‖∧∨⟦⟧⟨⟩∘" + // unbreakable spaces
" " + "////";
Predicate p = new Predicate(new DefaultURI(uri), 1);
ByteArrayOutputStream os = new ByteArrayOutputStream();
DlgpWriter writer = new DlgpWriter(os);
writer.write(new DefaultAtom(p, cst));
writer.flush();
String s = new String(os.toByteArray(), "UTF-8");
writer.close();
Assert.assertTrue(s.contains("<" + uri + ">(<A>)."));
}
use of fr.lirmm.graphik.graal.core.DefaultAtom in project graal by graphik-team.
the class DlgpWriterTest method bugIllegalCharInPrefixedName.
@Test
public void bugIllegalCharInPrefixedName() throws IOException {
Prefix p1 = new Prefix("a", "http://p#");
Predicate p = new Predicate(new DefaultURI("http://p#to@to"), 1);
ByteArrayOutputStream os = new ByteArrayOutputStream();
DlgpWriter writer = new DlgpWriter(os);
writer.write(p1);
writer.write(new DefaultAtom(p, cst));
writer.flush();
String s = new String(os.toByteArray(), "UTF-8");
writer.close();
Assert.assertTrue(s.contains("<http://p#to@to>(<A>)."));
}
use of fr.lirmm.graphik.graal.core.DefaultAtom in project graal by graphik-team.
the class DlgpWriterTest method bugDoubleQuoteInStringLiteral.
@Test
public void bugDoubleQuoteInStringLiteral() throws IOException {
Literal l = DefaultTermFactory.instance().createLiteral(URIUtils.XSD_STRING, "test\"test");
ByteArrayOutputStream os = new ByteArrayOutputStream();
DlgpWriter writer = new DlgpWriter(os);
writer.write(new DefaultAtom(predicat, l));
writer.flush();
String s = new String(os.toByteArray(), "UTF-8");
writer.close();
Assert.assertTrue(s.contains("\"test\\\"test\""));
}
use of fr.lirmm.graphik.graal.core.DefaultAtom in project graal by graphik-team.
the class DlgpWriterTest method writeVariable.
@Test
public void writeVariable() throws IOException {
Term x = DefaultTermFactory.instance().createVariable("x");
ByteArrayOutputStream os = new ByteArrayOutputStream();
DlgpWriter writer = new DlgpWriter(os);
writer.write(new DefaultAtom(predicat, x));
writer.flush();
String s = new String(os.toByteArray(), "UTF-8");
writer.close();
Assert.assertTrue("Variable label does not begin with upper case.", Character.isUpperCase(s.charAt(s.indexOf("(") + 1)));
}
use of fr.lirmm.graphik.graal.core.DefaultAtom in project graal by graphik-team.
the class Atom2SubstitutionConverterTest method basic2.
@Test
public void basic2() throws ParseException {
// given
Predicate p = DefaultPredicateFactory.instance().create("p", 3);
Variable x = DefaultTermFactory.instance().createVariable("X");
Variable y = DefaultTermFactory.instance().createVariable("Y");
Variable z = DefaultTermFactory.instance().createVariable("Z");
Atom queryAtom = new DefaultAtom(p, x, y, z);
List<Term> ansList = new LinkedList<>();
ansList.add(x);
ansList.add(z);
// when
Converter<Atom, Substitution> converter = new Atom2SubstitutionConverter(queryAtom, ansList);
Substitution s = null;
try {
s = converter.convert(DlgpParser.parseAtom("p(a,b,c)."));
} catch (ConversionException e) {
fail();
}
// then
Constant a = DefaultTermFactory.instance().createConstant("a");
Constant c = DefaultTermFactory.instance().createConstant("c");
assertEquals(a, s.createImageOf(x));
assertEquals(y, s.createImageOf(y));
assertEquals(c, s.createImageOf(z));
}
Aggregations