use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class JmxQueryProcedureTest method shouldHandleMBeanThatThrowsOnGetAttribute.
@Test
void shouldHandleMBeanThatThrowsOnGetAttribute() throws Throwable {
// given some JVM MBeans do not allow accessing their attributes, despite marking
// then as readable
when(jmxServer.getAttribute(beanName, "name")).thenThrow(new RuntimeMBeanException(new UnsupportedOperationException("Haha, screw discoverable services!")));
JmxQueryProcedure procedure = new JmxQueryProcedure(ProcedureSignature.procedureName("bob"), jmxServer);
// when
RawIterator<AnyValue[], ProcedureException> result = procedure.apply(null, new AnyValue[] { stringValue("*:*") }, EMPTY_RESOURCE_TRACKER);
// then
assertThat(asList(result)).contains(new AnyValue[] { stringValue("org.neo4j:chevyMakesTheTruck=bobMcCoshMakesTheDifference"), stringValue("This is a description"), ValueUtils.of(map(attributeName, map("description", "This is the attribute desc.", "value", null))) });
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method listAllCapabilitiesShouldNotReturnBlocked.
@Test
void listAllCapabilitiesShouldNotReturnBlocked() throws KernelException {
// set blocked capabilities
Config config = dependencyResolver.resolveDependency(Config.class);
config.set(CapabilitiesSettings.dbms_capabilities_blocked, List.of("my.custom.**"));
QualifiedName procedureName = procedureName("dbms", "listAllCapabilities");
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(DBMSCapabilities.dbms_instance_version.name().fullName(), DBMSCapabilities.dbms_instance_kernel_version.name().fullName(), DBMSCapabilities.dbms_instance_edition.name().fullName(), DBMSCapabilities.dbms_instance_operational_mode.name().fullName(), TestCapabilities.my_dynamic_capability.name().fullName(), TestCapabilities.my_internal_capability.name().fullName());
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method listAllCapabilities.
@Test
void listAllCapabilities() throws KernelException {
QualifiedName procedureName = procedureName("dbms", "listAllCapabilities");
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(DBMSCapabilities.dbms_instance_version.name().fullName(), DBMSCapabilities.dbms_instance_kernel_version.name().fullName(), DBMSCapabilities.dbms_instance_edition.name().fullName(), DBMSCapabilities.dbms_instance_operational_mode.name().fullName(), TestCapabilities.my_custom_capability.name().fullName(), TestCapabilities.my_internal_capability.name().fullName(), TestCapabilities.my_dynamic_capability.name().fullName());
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method callListConfig.
private List<AnyValue[]> callListConfig(String searchString) throws KernelException {
QualifiedName procedureName = procedureName("dbms", "listConfig");
int procedureId = procs().procedureGet(procedureName).id();
RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, toArray(stringValue(searchString)), ProcedureCallContext.EMPTY);
return asList(callResult);
}
use of org.neo4j.internal.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class MyCoreAPI method makeNode.
public long makeNode(Transaction tx, String label) throws ProcedureException {
try {
KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
long nodeId = ktx.dataWrite().nodeCreate();
int labelId = ktx.tokenWrite().labelGetOrCreateForName(label);
ktx.dataWrite().nodeAddLabel(nodeId, labelId);
return nodeId;
} catch (Exception e) {
log.error("Failed to create node: " + e.getMessage());
throw new ProcedureException(Status.Procedure.ProcedureCallFailed, "Failed to create node: " + e.getMessage(), e);
}
}
Aggregations