use of ai.grakn.concept.ConceptId in project grakn by graknlabs.
the class IndexPostProcessorTest method whenPostProcessingIndices_EnsureFixingMethodIsCalled.
@Test
public void whenPostProcessingIndices_EnsureFixingMethodIsCalled() {
// Setup mocks
Keyspace keyspace = Keyspace.of("whatakeyspace");
EmbeddedGraknTx<?> tx = mock(EmbeddedGraknTx.class);
when(tx.duplicateResourcesExist(any(), any())).thenReturn(true);
when(tx.keyspace()).thenReturn(keyspace);
String index = "index1";
Set<ConceptId> ids = Stream.of("a", "b", "c").map(ConceptId::of).collect(Collectors.toSet());
// Call post processor
indexPostProcessor.mergeDuplicateConcepts(tx, index, ids);
// Check method calls
verify(tx, Mockito.times(1)).fixDuplicateResources(index, ids);
}
use of ai.grakn.concept.ConceptId in project grakn by graknlabs.
the class RelatesProperty method mapToAtom.
@Override
public Atomic mapToAtom(VarPatternAdmin var, Set<VarPatternAdmin> vars, ReasonerQuery parent) {
Var varName = var.var().asUserDefined();
VarPatternAdmin roleVar = this.role();
Var roleVariable = roleVar.var().asUserDefined();
IdPredicate predicate = getIdPredicate(roleVariable, roleVar, vars, parent);
ConceptId predicateId = predicate != null ? predicate.getPredicate() : null;
return RelatesAtom.create(varName, roleVariable, predicateId, parent);
}
use of ai.grakn.concept.ConceptId 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.ConceptId 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.ConceptId 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()));
}
}
Aggregations