Search in sources :

Example 11 with Printer

use of ai.grakn.graql.Printer in project grakn by graknlabs.

the class GraqlPrinterTest method whenGettingOutputForRelation_TheResultShouldHaveCommasBetweenRolePlayers.

@Test
public void whenGettingOutputForRelation_TheResultShouldHaveCommasBetweenRolePlayers() {
    Printer printer = Printers.graql(true);
    Match match = rule.tx().graql().match(var("r").isa("has-cluster"));
    Relationship relationship = match.get("r").iterator().next().asRelationship();
    long numRolePlayers = relationship.rolePlayers().count();
    long numCommas = numRolePlayers - 1;
    String relationString = printer.graqlString(relationship);
    assertEquals(relationString + " should have " + numCommas + " commas separating role-players", numCommas, StringUtils.countMatches(relationString, ","));
}
Also used : Relationship(ai.grakn.concept.Relationship) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Printer(ai.grakn.graql.Printer) Match(ai.grakn.graql.Match) Test(org.junit.Test)

Example 12 with Printer

use of ai.grakn.graql.Printer in project grakn by graknlabs.

the class GraqlPrinterTest method whenPrintingNull_ResultIsNullString.

@Test
public void whenPrintingNull_ResultIsNullString() {
    Printer printer = Printers.graql(false);
    assertEquals("null", printer.graqlString(null));
}
Also used : Printer(ai.grakn.graql.Printer) Test(org.junit.Test)

Example 13 with Printer

use of ai.grakn.graql.Printer in project grakn by graknlabs.

the class GraqlPrinterTest method testConcept.

@Test
public void testConcept() {
    Printer printer = Printers.graql(true);
    SchemaConcept concept = rule.tx().admin().getMetaConcept();
    String conceptString = printer.graqlString(concept);
    assertThat(conceptString, containsString("label"));
    assertThat(conceptString, containsString(Schema.MetaSchema.THING.getLabel().getValue()));
    assertThat(conceptString, not(containsString("sub")));
    assertThat(conceptString, not(containsString("isa")));
}
Also used : SchemaConcept(ai.grakn.concept.SchemaConcept) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Printer(ai.grakn.graql.Printer) Test(org.junit.Test)

Example 14 with Printer

use of ai.grakn.graql.Printer in project grakn by graknlabs.

the class GraqlPrinterTest method whenPrintingWitholorizeFalse_ResultIsNotColored.

@Test
public void whenPrintingWitholorizeFalse_ResultIsNotColored() {
    Printer printer = Printers.graql(false);
    Type production = rule.tx().getEntityType("production");
    String productionString = printer.graqlString(production);
    assertThat(productionString, not(containsString("\u001B")));
}
Also used : Type(ai.grakn.concept.Type) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Printer(ai.grakn.graql.Printer) Test(org.junit.Test)

Aggregations

Printer (ai.grakn.graql.Printer)14 Test (org.junit.Test)13 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 Type (ai.grakn.concept.Type)4 Match (ai.grakn.graql.Match)3 Thing (ai.grakn.concept.Thing)2 Relationship (ai.grakn.concept.Relationship)1 Role (ai.grakn.concept.Role)1 SchemaConcept (ai.grakn.concept.SchemaConcept)1 GetQuery (ai.grakn.graql.GetQuery)1 Query (ai.grakn.graql.Query)1 Answer (ai.grakn.graql.admin.Answer)1 QueryAnswer (ai.grakn.graql.internal.query.QueryAnswer)1