Search in sources :

Example 71 with ConceptId

use of ai.grakn.concept.ConceptId in project grakn by graknlabs.

the class DeleteQueryTest method whenDeletingAResource_TheResourceAndImplicitRelationsAreDeleted.

@Test
public void whenDeletingAResource_TheResourceAndImplicitRelationsAreDeleted() {
    ConceptId id = qb.match(x.has("title", "Godfather"), var("a").rel(x).rel(y).isa(Schema.ImplicitType.HAS.getLabel("tmdb-vote-count").getValue())).get("a").findFirst().get().getId();
    assertExists(qb, var().has("title", "Godfather"));
    assertExists(qb, var().id(id));
    assertExists(qb, var().val(1000L).isa("tmdb-vote-count"));
    qb.match(x.val(1000L).isa("tmdb-vote-count")).delete(x).execute();
    assertExists(qb, var().has("title", "Godfather"));
    assertNotExists(qb, var().id(id));
    assertNotExists(qb, var().val(1000L).isa("tmdb-vote-count"));
}
Also used : ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 72 with ConceptId

use of ai.grakn.concept.ConceptId in project grakn by graknlabs.

the class InsertQueryTest method testInsertResourceOnExistingResourceIdWithType.

@Test
public void testInsertResourceOnExistingResourceIdWithType() {
    ConceptId apocalypseNow = qb.match(var("x").val("Apocalypse Now")).get("x").findAny().get().getId();
    assertNotExists(qb, var().id(apocalypseNow).has("title", "Apocalypse Maybe Tomorrow"));
    qb.insert(var().id(apocalypseNow).isa("title").has("title", "Apocalypse Maybe Tomorrow")).execute();
    assertExists(qb, var().id(apocalypseNow).has("title", "Apocalypse Maybe Tomorrow"));
}
Also used : ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 73 with ConceptId

use of ai.grakn.concept.ConceptId in project grakn by graknlabs.

the class InsertQueryTest method testInsertResourceOnExistingIdWithType.

@Test
public void testInsertResourceOnExistingIdWithType() {
    ConceptId apocalypseNow = qb.match(var("x").has("title", "Apocalypse Now")).get("x").findAny().get().getId();
    assertNotExists(qb, var().id(apocalypseNow).has("title", "Apocalypse Maybe Tomorrow"));
    qb.insert(var().id(apocalypseNow).isa("movie").has("title", "Apocalypse Maybe Tomorrow")).execute();
    assertExists(qb, var().id(apocalypseNow).has("title", "Apocalypse Maybe Tomorrow"));
}
Also used : ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 74 with ConceptId

use of ai.grakn.concept.ConceptId in project grakn by graknlabs.

the class InsertQueryTest method testInsertResourceOnExistingResourceId.

@Test
public void testInsertResourceOnExistingResourceId() {
    ConceptId apocalypseNow = qb.match(var("x").val("Apocalypse Now")).get("x").findAny().get().getId();
    assertNotExists(qb, var().id(apocalypseNow).has("title", "Apocalypse Maybe Tomorrow"));
    qb.insert(var().id(apocalypseNow).has("title", "Apocalypse Maybe Tomorrow")).execute();
    assertExists(qb, var().id(apocalypseNow).has("title", "Apocalypse Maybe Tomorrow"));
}
Also used : ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Example 75 with ConceptId

use of ai.grakn.concept.ConceptId in project grakn by graknlabs.

the class InsertQueryTest method testInsertResourceOnExistingId.

@Test
public void testInsertResourceOnExistingId() {
    ConceptId apocalypseNow = qb.match(var("x").has("title", "Apocalypse Now")).get("x").findAny().get().getId();
    assertNotExists(qb, var().id(apocalypseNow).has("title", "Apocalypse Maybe Tomorrow"));
    qb.insert(var().id(apocalypseNow).has("title", "Apocalypse Maybe Tomorrow")).execute();
    assertExists(qb, var().id(apocalypseNow).has("title", "Apocalypse Maybe Tomorrow"));
}
Also used : ConceptId(ai.grakn.concept.ConceptId) Test(org.junit.Test)

Aggregations

ConceptId (ai.grakn.concept.ConceptId)80 Test (org.junit.Test)55 Concept (ai.grakn.concept.Concept)23 Role (ai.grakn.concept.Role)22 RelationshipType (ai.grakn.concept.RelationshipType)19 GraknTx (ai.grakn.GraknTx)18 EntityType (ai.grakn.concept.EntityType)18 Label (ai.grakn.concept.Label)16 GrpcConcept (ai.grakn.rpc.generated.GrpcConcept)14 Var (ai.grakn.graql.Var)12 List (java.util.List)12 Entity (ai.grakn.concept.Entity)10 AttributeType (ai.grakn.concept.AttributeType)9 HashSet (java.util.HashSet)9 Set (java.util.Set)9 Assert.assertEquals (org.junit.Assert.assertEquals)9 ClassRule (org.junit.ClassRule)9 GraknTxType (ai.grakn.GraknTxType)8 Keyspace (ai.grakn.Keyspace)8 IdPredicate (ai.grakn.graql.internal.reasoner.atom.predicate.IdPredicate)8