Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowOverridingProcedureName() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAllowOverridingProcedureName()
        {
            // When
            CallableUserFunction proc = Compile(typeof(FunctionWithOverriddenName))[0];

            // Then
            assertEquals("org.mystuff.thisisActuallyTheName", proc.Signature().name().ToString());
        }
Exemple #2
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));
        }
Exemple #3
0
        public virtual UserFunctionHandle Function(QualifiedName name)
        {
            CallableUserFunction func = _functions.get(name);

            if (func == null)
            {
                return(null);
            }
            return(new UserFunctionHandle(func.Signature(), _functions.idOf(name)));
        }
Exemple #4
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]")));
        }
Exemple #5
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"))));
        }
Exemple #6
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"))));
        }
Exemple #7
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]);
        }
Exemple #8
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"))));
        }
Exemple #9
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");
        }
Exemple #10
0
        /// <summary>
        /// Register a new function.
        /// </summary>
        /// <param name="function"> the function. </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void register(org.neo4j.kernel.api.proc.CallableUserFunction function, boolean overrideCurrentImplementation) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual void Register(CallableUserFunction function, bool overrideCurrentImplementation)
        {
            UserFunctionSignature signature = function.Signature();
            QualifiedName         name      = signature.Name();

            CallableUserFunction oldImplementation = _functions.get(name);

            if (oldImplementation == null)
            {
                _functions.put(name, function, signature.CaseInsensitive());
            }
            else
            {
                if (overrideCurrentImplementation)
                {
                    _functions.put(name, function, signature.CaseInsensitive());
                }
                else
                {
                    throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureRegistrationFailed, "Unable to register function, because the name `%s` is already in use.", name);
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// Register a new function. This method must not be called concurrently with <seealso cref="procedure(QualifiedName)"/>. </summary>
        /// <param name="function"> the function. </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void register(org.neo4j.kernel.api.proc.CallableUserFunction function) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual void Register(CallableUserFunction function)
        {
            Register(function, false);
        }
Exemple #12
0
        /// <summary>
        /// Register a new procedure. This method must not be called concurrently with <seealso cref="procedure(QualifiedName)"/>. </summary>
        /// <param name="function"> the function. </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void register(org.neo4j.kernel.api.proc.CallableUserFunction function, boolean overrideCurrentImplementation) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual void Register(CallableUserFunction function, bool overrideCurrentImplementation)
        {
            _registry.register(function, overrideCurrentImplementation);
        }
Exemple #13
0
 public virtual void Add(CallableUserFunction func)
 {
     FunctionsConflict.Add(func);
 }