use of ai.grakn.concept.Concept in project grakn by graknlabs.
the class GrpcServerTest method whenGettingALabelForANonSchemaConcept_Throw.
@Test
public void whenGettingALabelForANonSchemaConcept_Throw() throws InterruptedException {
ConceptId id = ConceptId.of("V123456");
Concept concept = mock(Concept.class);
when(tx.getConcept(id)).thenReturn(concept);
when(concept.isSchemaConcept()).thenReturn(false);
when(concept.asSchemaConcept()).thenThrow(EXCEPTION);
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.READ));
tx.receive().ok();
tx.send(GrpcUtil.runConceptMethodRequest(id, ConceptMethods.GET_LABEL));
exception.expect(hasStatus(Status.UNKNOWN.withDescription(EXCEPTION_MESSAGE)));
throw tx.receive().error();
}
}
use of ai.grakn.concept.Concept in project grakn by graknlabs.
the class GrpcServerTest method whenGettingAConcept_ReturnTheConcept.
@Test
public void whenGettingAConcept_ReturnTheConcept() throws InterruptedException {
ConceptId id = ConceptId.of("V123456");
Concept concept = mock(Concept.class, RETURNS_DEEP_STUBS);
when(concept.getId()).thenReturn(id);
when(concept.isRelationship()).thenReturn(true);
when(tx.getConcept(id)).thenReturn(concept);
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.READ));
tx.receive().ok();
tx.send(GrpcUtil.getConceptRequest(id));
GrpcConcept.OptionalConcept response = tx.receive().ok().getOptionalConcept();
assertEquals(id.getValue(), response.getPresent().getId().getValue());
assertEquals(BaseType.Relationship, response.getPresent().getBaseType());
}
}
use of ai.grakn.concept.Concept in project grakn by graknlabs.
the class GrpcServerTest method whenGettingIsInferredProperty_IsInferredIsReturned.
@Test
public void whenGettingIsInferredProperty_IsInferredIsReturned() throws InterruptedException {
ConceptId id = ConceptId.of("V123456");
Concept concept = mock(Concept.class, RETURNS_DEEP_STUBS);
when(tx.getConcept(id)).thenReturn(concept);
when(concept.isThing()).thenReturn(true);
when(concept.asThing().isInferred()).thenReturn(false);
try (TxGrpcCommunicator tx = TxGrpcCommunicator.create(stub)) {
tx.send(openRequest(MYKS, GraknTxType.READ));
tx.receive().ok();
tx.send(GrpcUtil.runConceptMethodRequest(id, ConceptMethods.IS_INFERRED));
assertFalse(ConceptMethods.IS_INFERRED.get(conceptConverter, client, tx.receive().ok()));
}
}
use of ai.grakn.concept.Concept in project grakn by graknlabs.
the class AtomicTest method testRuleApplicability_InstancesMakeRuleInapplicable_NoRoleTypes_NoRelationType.
@Test
public void testRuleApplicability_InstancesMakeRuleInapplicable_NoRoleTypes_NoRelationType() {
EmbeddedGraknTx<?> graph = ruleApplicabilitySet.tx();
Concept concept = getConcept(graph, "name", "noRoleEntity");
String relationString = "{" + "($x, $y);" + "$x id '" + concept.getId().getValue() + "';" + "}";
Atom relation = ReasonerQueries.atomic(conjunction(relationString, graph), graph).getAtom();
assertThat(relation.getApplicableRules().collect(toSet()), empty());
}
use of ai.grakn.concept.Concept in project grakn by graknlabs.
the class GenealogyTest method hasDuplicates.
private boolean hasDuplicates(List<Answer> answers) {
boolean hasDuplicates = false;
Iterator<Answer> it = answers.iterator();
while (it.hasNext() && !hasDuplicates) {
Answer answer = it.next();
Set<Concept> existing = new HashSet<>();
hasDuplicates = answer.entrySet().stream().filter(entry -> existing.add(entry.getValue())).count() != answer.size();
if (hasDuplicates)
System.out.println(answer.toString());
}
return hasDuplicates;
}
Aggregations