use of ai.grakn.graql.Printer in project grakn by graknlabs.
the class GraqlPrinterTest method testResourceOutputWithResource.
// allOf accepts an array with generics
@SuppressWarnings("unchecked")
@Test
public void testResourceOutputWithResource() {
Printer printer = Printers.graql(true, rule.tx().getAttributeType("title"), rule.tx().getAttributeType("tmdb-vote-count"), rule.tx().getAttributeType("name"));
Thing godfather = rule.tx().getAttributeType("title").getAttribute("Godfather").owner();
String repr = printer.graqlString(godfather);
assertThat(repr, allOf(containsString("movie"), containsString("has"), containsString("title"), containsString("\"Godfather\""), containsString("tmdb-vote-count"), containsString("1000"), not(containsString("name"))));
}
use of ai.grakn.graql.Printer in project grakn by graknlabs.
the class GraqlPrinterTest method whenPrintingWithColorizeTrue_ResultIsColored.
@Test
public void whenPrintingWithColorizeTrue_ResultIsColored() {
Printer printer = Printers.graql(true);
Type production = rule.tx().getEntityType("production");
String productionString = printer.graqlString(production);
assertThat(productionString, containsString("\u001B"));
}
use of ai.grakn.graql.Printer in project grakn by graknlabs.
the class GraqlPrinterTest method testRelationOutput.
@Test
public void testRelationOutput() {
Printer printer = Printers.graql(true);
Match match = rule.tx().graql().match(var("r").isa("has-cast").rel(var().has("name", "Al Pacino")).rel(var().has("name", "Michael Corleone")).rel(var().has("title", "Godfather")));
String relationString = printer.graqlString(match.get("r").iterator().next());
assertThat(relationString, containsString("has-cast"));
assertThat(relationString, containsString("actor"));
assertThat(relationString, containsString("production-with-cast"));
assertThat(relationString, containsString("character-being-played"));
}
use of ai.grakn.graql.Printer in project grakn by graknlabs.
the class GraqlPrinterTest method testResourceOutputNoResources.
@Test
public void testResourceOutputNoResources() {
Printer printer = Printers.graql(true);
Thing godfather = rule.tx().getAttributeType("title").getAttribute("Godfather").owner();
String repr = printer.graqlString(godfather);
assertThat(repr, allOf(containsString("movie"), not(containsString("title")), not(containsString("Godfather"))));
}
use of ai.grakn.graql.Printer in project grakn by graknlabs.
the class GraqlPrinterTest method whenGettingOutputForResource_IncludesValueOfResource.
@Test
public void whenGettingOutputForResource_IncludesValueOfResource() {
Printer printer = Printers.graql(false);
Match match = rule.tx().graql().match(var("x").isa("title").val("Godfather"));
String result = printer.graqlString(match.iterator().next());
assertEquals("$x val \"Godfather\" isa title;", result.trim());
}
Aggregations