Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.values.AnyValue callFunction(org.neo4j.kernel.api.proc.Context ctx, org.neo4j.internal.kernel.api.procs.QualifiedName name, org.neo4j.values.AnyValue[] input) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual AnyValue CallFunction(Context ctx, QualifiedName name, AnyValue[] input)
        {
            CallableUserFunction func = _functions.get(name);

            if (func == null)
            {
                throw NoSuchFunction(name);
            }
            return(func.Apply(ctx, input));
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompileAndRunUserFunctions() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCompileAndRunUserFunctions()
        {
            // Given
            CallableUserFunction proc = _compiler.compileFunction(typeof(FunctionWithInjectedAPI))[0];

            // When
            object @out = proc.Apply(new BasicContext(), new AnyValue[0]);

            // Then
            assertThat(@out, equalTo(Values.of("[Bonnie, Clyde]")));
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRunSimpleReadOnlyFunction() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRunSimpleReadOnlyFunction()
        {
            // Given
            CallableUserFunction func = Compile(typeof(SingleReadOnlyFunction))[0];

            // When
            object @out = func.Apply(new BasicContext(), new AnyValue[0]);

            // Then
            assertThat(@out, equalTo(ValueUtils.of(Arrays.asList("Bonnie", "Clyde"))));
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLoadWhiteListedFunction() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLoadWhiteListedFunction()
        {
            // Given
            _procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, new ComponentRegistry(), NullLog.Instance, new ProcedureConfig(Config.defaults(GraphDatabaseSettings.procedure_whitelist, "org.neo4j.kernel.impl.proc.listCoolPeople")));

            CallableUserFunction method = Compile(typeof(SingleReadOnlyFunction))[0];

            // Expect
            object @out = method.Apply(new BasicContext(), new AnyValue[0]);

            assertThat(@out, equalTo(ValueUtils.of(Arrays.asList("Bonnie", "Clyde"))));
        }
Beispiel #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGiveHelpfulErrorOnNullMessageException() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldGiveHelpfulErrorOnNullMessageException()
        {
            // Given
            CallableUserFunction proc = Compile(typeof(FunctionThatThrowsNullMsgExceptionAtInvocation))[0];

            // Expect
            Exception.expect(typeof(ProcedureException));
            Exception.expectMessage("Failed to invoke function `org.neo4j.kernel.impl.proc.throwsAtInvocation`: " + "Caused by: java.lang.IndexOutOfBoundsException");

            // When
            proc.Apply(new BasicContext(), new AnyValue[0]);
        }
Beispiel #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRunClassWithMultipleFunctionsDeclared() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRunClassWithMultipleFunctionsDeclared()
        {
            // Given
            IList <CallableUserFunction> compiled     = Compile(typeof(ReflectiveUserFunctionTest.MultiFunction));
            CallableUserFunction         bananaPeople = compiled[0];
            CallableUserFunction         coolPeople   = compiled[1];

            // When
            object coolOut   = coolPeople.Apply(new BasicContext(), new AnyValue[0]);
            object bananaOut = bananaPeople.Apply(new BasicContext(), new AnyValue[0]);

            // Then
            assertThat(coolOut, equalTo(ValueUtils.of(Arrays.asList("Bonnie", "Clyde"))));

            assertThat((( MapValue )bananaOut).get("foo"), equalTo(ValueUtils.of(Arrays.asList("bar", "baz"))));
        }
Beispiel #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInjectLogging() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldInjectLogging()
        {
            // Given
            Log log = spy(typeof(Log));

            _components.register(typeof(Log), ctx => log);
            CallableUserFunction function = _procedureCompiler.compileFunction(typeof(LoggingFunction))[0];

            // When
            function.Apply(new BasicContext(), new AnyValue[0]);

            // Then
            verify(log).debug("1");
            verify(log).info("2");
            verify(log).warn("3");
            verify(log).error("4");
        }