//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
            CallableUserAggregationFunction method = Compile(typeof(FunctionWithOverriddenName))[0];

            // Then
            assertEquals("org.mystuff.thisisActuallyTheName", method.Signature().name().ToString());
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.internal.kernel.api.procs.UserAggregator createAggregationFunction(org.neo4j.kernel.api.proc.Context ctx, org.neo4j.internal.kernel.api.procs.QualifiedName name) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual UserAggregator CreateAggregationFunction(Context ctx, QualifiedName name)
        {
            CallableUserAggregationFunction func = _aggregationFunctions.get(name);

            if (func == null)
            {
                throw NoSuchFunction(name);
            }
            return(func.Create(ctx));
        }
示例#3
0
        public virtual UserFunctionHandle AggregationFunction(QualifiedName name)
        {
            CallableUserAggregationFunction func = _aggregationFunctions.get(name);

            if (func == null)
            {
                return(null);
            }
            return(new UserFunctionHandle(func.Signature(), _aggregationFunctions.idOf(name)));
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompileAndRunUserAggregationFunctions() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCompileAndRunUserAggregationFunctions()
        {
            // Given
            CallableUserAggregationFunction proc = _compiler.compileAggregationFunction(typeof(AggregationFunctionWithInjectedAPI))[0];

            // When
            proc.Create(new BasicContext()).update(new object[] {});
            object @out = proc.Create(new BasicContext()).result();

            // Then
            assertThat(@out, equalTo("[Bonnie, Clyde]"));
        }
//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
            CallableUserAggregationFunction method = Compile(typeof(FunctionThatThrowsNullMsgExceptionAtInvocation))[0];

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

            // When
            method.Create(new BasicContext()).update(new object[] {});
        }
//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.collectCool")));

            CallableUserAggregationFunction method = Compile(typeof(SingleAggregationFunction))[0];

            // Expect
            UserAggregator created = method.Create(new BasicContext());

            created.Update(new object[] { "Bonnie" });
            assertThat(created.Result(), equalTo(Collections.singletonList("Bonnie")));
        }
示例#7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.internal.kernel.api.procs.UserAggregator createAggregationFunction(org.neo4j.kernel.api.proc.Context ctx, int id) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual UserAggregator CreateAggregationFunction(Context ctx, int id)
        {
            CallableUserAggregationFunction func = null;

            try
            {
                func = _aggregationFunctions.get(id);
            }
            catch (System.IndexOutOfRangeException)
            {
                throw NoSuchFunction(id);
            }
            return(func.Create(ctx));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRunAggregationFunction() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRunAggregationFunction()
        {
            // Given
            CallableUserAggregationFunction func = Compile(typeof(SingleAggregationFunction))[0];

            // When
            UserAggregator aggregator = func.Create(new BasicContext());

            aggregator.Update(new object[] { "Harry" });
            aggregator.Update(new object[] { "Bonnie" });
            aggregator.Update(new object[] { "Sally" });
            aggregator.Update(new object[] { "Clyde" });

            // Then
            assertThat(aggregator.Result(), equalTo(Arrays.asList("Bonnie", "Clyde")));
        }
//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);
            CallableUserAggregationFunction function = _procedureCompiler.compileAggregationFunction(typeof(LoggingFunction))[0];

            // When
            UserAggregator aggregator = function.Create(new BasicContext());

            aggregator.Update(new object[] {});
            aggregator.Result();

            // Then
            verify(log).debug("1");
            verify(log).info("2");
            verify(log).warn("3");
            verify(log).error("4");
        }
//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 <CallableUserAggregationFunction> compiled = Compile(typeof(MultiFunction));
            CallableUserAggregationFunction         f1       = compiled[0];
            CallableUserAggregationFunction         f2       = compiled[1];

            // When
            UserAggregator f1Aggregator = f1.Create(new BasicContext());

            f1Aggregator.Update(new object[] { "Bonnie" });
            f1Aggregator.Update(new object[] { "Clyde" });
            UserAggregator f2Aggregator = f2.Create(new BasicContext());

            f2Aggregator.Update(new object[] { "Bonnie", 1337L });
            f2Aggregator.Update(new object[] { "Bonnie", 42L });

            // Then
            assertThat(f1Aggregator.Result(), equalTo(Arrays.asList("Bonnie", "Clyde")));
            assertThat(((System.Collections.IDictionary)f2Aggregator.Result())["Bonnie"], equalTo(1337L));
        }
示例#11
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.CallableUserAggregationFunction function, boolean overrideCurrentImplementation) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual void Register(CallableUserAggregationFunction function, bool overrideCurrentImplementation)
        {
            UserFunctionSignature signature = function.Signature();
            QualifiedName         name      = signature.Name();

            CallableUserFunction oldImplementation = _functions.get(name);

            if (oldImplementation == null)
            {
                _aggregationFunctions.put(name, function, signature.CaseInsensitive());
            }
            else
            {
                if (overrideCurrentImplementation)
                {
                    _aggregationFunctions.put(name, function, signature.CaseInsensitive());
                }
                else
                {
                    throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureRegistrationFailed, "Unable to register aggregation function, because the name `%s` is already in use.", name);
                }
            }
        }
示例#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.CallableUserAggregationFunction function, boolean overrideCurrentImplementation) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual void Register(CallableUserAggregationFunction function, bool overrideCurrentImplementation)
        {
            _registry.register(function, overrideCurrentImplementation);
        }
示例#13
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.CallableUserAggregationFunction function) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual void Register(CallableUserAggregationFunction function)
        {
            Register(function, false);
        }