use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class UserFunctionsTest method shouldNotAllowRegisteringConflictingName.
@Test
void shouldNotAllowRegisteringConflictingName() throws Throwable {
// Given
procs.register(function);
ProcedureException exception = assertThrows(ProcedureException.class, () -> procs.register(function));
assertThat(exception.getMessage()).isEqualTo("Unable to register function, because the name `org.myproc` is already in use.");
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class BuiltInProcedures method indexDetails.
@Deprecated(since = "4.2.0", forRemoval = true)
@SystemProcedure
@Description("Detailed description of specific index.")
@Procedure(name = "db.indexDetails", mode = READ, deprecatedBy = "SHOW INDEXES YIELD * command")
public Stream<IndexDetailResult> indexDetails(@Name("indexName") String indexName) throws ProcedureException {
if (callContext.isSystemDatabase()) {
return Stream.empty();
}
TokenRead tokenRead = kernelTransaction.tokenRead();
IndexingService indexingService = resolver.resolveDependency(IndexingService.class);
SchemaReadCore schemaRead = kernelTransaction.schemaRead().snapshot();
List<IndexDescriptor> indexes = asList(schemaRead.indexesGetAll());
IndexDescriptor index = null;
for (IndexDescriptor candidate : indexes) {
if (candidate.getName().equals(indexName)) {
index = candidate;
break;
}
}
if (index == null) {
throw new ProcedureException(Status.Schema.IndexNotFound, "Could not find index with name \"" + indexName + "\"");
}
final IndexDetailResult indexDetailResult = asIndexDetails(tokenRead, schemaRead, index);
return Stream.of(indexDetailResult);
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class BoltChannelAutoReadLimiterIT method installSleepProcedure.
private static void installSleepProcedure(GraphDatabaseService db) throws ProcedureException {
GraphDatabaseAPI dbApi = (GraphDatabaseAPI) db;
dbApi.getDependencyResolver().resolveDependency(GlobalProcedures.class).register(new CallableProcedure.BasicProcedure(procedureSignature("boltissue", "sleep").in("data", Neo4jTypes.NTString).out(ProcedureSignature.VOID).build()) {
@Override
public RawIterator<AnyValue[], ProcedureException> apply(Context context, AnyValue[] objects, ResourceTracker resourceTracker) throws ProcedureException {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
throw new ProcedureException(Status.General.UnknownError, e, "Interrupted");
}
return RawIterator.empty();
}
});
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method listCapabilitiesShouldReturnDynamicValues.
@Test
void listCapabilitiesShouldReturnDynamicValues() throws KernelException {
QualifiedName procedureName = procedureName("dbms", "listCapabilities");
int procedureId = procs().procedureGet(procedureName).id();
// first call
RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
List<AnyValue[]> capabilities = asList(callResult);
// should return false
assertThat(capabilities).contains(new AnyValue[] { Values.stringValue(TestCapabilities.my_dynamic_capability.name().fullName()), Values.stringValue(TestCapabilities.my_dynamic_capability.description()), Values.booleanValue(false) });
try (var txc = db.beginTx()) {
txc.createNode(label("my_dynamic_capability"));
txc.commit();
}
// second call
callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
capabilities = asList(callResult);
// should return true
assertThat(capabilities).contains(new AnyValue[] { Values.stringValue(TestCapabilities.my_dynamic_capability.name().fullName()), Values.stringValue(TestCapabilities.my_dynamic_capability.description()), Values.booleanValue(true) });
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method listCapabilities.
@Test
void listCapabilities() throws KernelException {
QualifiedName procedureName = procedureName("dbms", "listCapabilities");
int procedureId = procs().procedureGet(procedureName).id();
RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
List<AnyValue[]> capabilities = asList(callResult);
List<String> capabilityNames = capabilities.stream().map(c -> ((TextValue) c[0]).stringValue()).collect(Collectors.toList());
assertThat(capabilityNames).containsExactlyInAnyOrder(TestCapabilities.my_custom_capability.name().fullName(), TestCapabilities.my_dynamic_capability.name().fullName());
}
Aggregations