Class MethodManagedFunctionBuilderUtil
- java.lang.Object
-
- net.officefloor.compile.test.managedfunction.clazz.MethodManagedFunctionBuilderUtil
-
public class MethodManagedFunctionBuilderUtil extends java.lang.Object
Utility class for testing
MethodManagedFunctionBuilder
.In particular, this is for ensuring extensions load and work as expected.
- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
MethodManagedFunctionBuilderUtil.ManagedFunctionContextBuilder
Builds theManagedFunctionContext
.static interface
MethodManagedFunctionBuilderUtil.ManagedFunctionFlowHandler
HandlesFlow
.static class
MethodManagedFunctionBuilderUtil.MethodResult
Result of running theManagedFunction
.
-
Constructor Summary
Constructors Constructor Description MethodManagedFunctionBuilderUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> ManagedFunctionType<Indexed,Indexed>
buildMethod(java.lang.Class<T> clazz, java.util.function.Function<java.lang.Class<T>,java.lang.reflect.Method> methodFactory, MethodObjectFactory objectInstanceFactory, FunctionNamespaceBuilder expectedFunctionNamespaceType, java.lang.String... propertyNameValues)
Builds theManagedFunctionType
.static ManagedFunctionType<Indexed,Indexed>
buildMethod(java.lang.Object instance, java.lang.String methodName, java.util.function.Consumer<ManagedFunctionTypeBuilder<Indexed,Indexed>> epectedTypeBuilder, java.lang.String... propertyNameValues)
Convenience method to build theManagedFunctionType
.static ManagedFunctionType<Indexed,Indexed>
buildStaticMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.util.function.Consumer<ManagedFunctionTypeBuilder<Indexed,Indexed>> epectedTypeBuilder, java.lang.String... propertyNameValues)
Convenience method to build theManagedFunctionType
.static FunctionNamespaceBuilder
createManagedFunctionTypeBuilder()
Creates theFunctionNamespaceBuilder
to create the expectedFunctionNamespaceType
.static FunctionNamespaceBuilder
createManagedFunctionTypeBuilder(java.lang.String functionName, java.util.function.Consumer<ManagedFunctionTypeBuilder<Indexed,Indexed>> decorator)
Convenience method to create aFunctionNamespaceBuilder
for singleManagedFunctionType
.static MethodObjectFactory
instance(java.lang.Object object)
Convenience means to createMethodObjectFactory
.static <T> java.util.function.Function<java.lang.Class<T>,java.lang.reflect.Method>
method(java.lang.String methodName)
Convenience means to obtain theMethod
from theClass
.static MethodManagedFunctionBuilderUtil.MethodResult
runMethod(java.lang.Object instance, java.lang.String methodName, java.util.function.Consumer<ManagedFunctionTypeBuilder<Indexed,Indexed>> epectedTypeBuilder, java.util.function.Consumer<MethodManagedFunctionBuilderUtil.ManagedFunctionContextBuilder> contextBuilder, java.lang.String... propertyNameValues)
Convenience method to build and run aManagedFunction
.static MethodManagedFunctionBuilderUtil.MethodResult
runMethod(ManagedFunctionType<Indexed,Indexed> functionType, java.util.function.Consumer<MethodManagedFunctionBuilderUtil.ManagedFunctionContextBuilder> contextBuilder)
Runs theManagedFunction
.static MethodManagedFunctionBuilderUtil.MethodResult
runStaticMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.util.function.Consumer<ManagedFunctionTypeBuilder<Indexed,Indexed>> epectedTypeBuilder, java.util.function.Consumer<MethodManagedFunctionBuilderUtil.ManagedFunctionContextBuilder> contextBuilder, java.lang.String... propertyNameValues)
Convenience method to build and run aManagedFunction
for staticMethod
.
-
-
-
Method Detail
-
createManagedFunctionTypeBuilder
public static FunctionNamespaceBuilder createManagedFunctionTypeBuilder()
Creates theFunctionNamespaceBuilder
to create the expectedFunctionNamespaceType
.- Returns:
FunctionNamespaceBuilder
to build the expectedFunctionNamespaceType
.
-
createManagedFunctionTypeBuilder
public static FunctionNamespaceBuilder createManagedFunctionTypeBuilder(java.lang.String functionName, java.util.function.Consumer<ManagedFunctionTypeBuilder<Indexed,Indexed>> decorator)
Convenience method to create aFunctionNamespaceBuilder
for singleManagedFunctionType
.- Parameters:
functionName
- Name ofManagedFunctionType
.decorator
- Optional decorator ofManagedFunctionTypeBuilder
. May benull
.- Returns:
FunctionNamespaceBuilder
.
-
method
public static <T> java.util.function.Function<java.lang.Class<T>,java.lang.reflect.Method> method(java.lang.String methodName)
Convenience means to obtain theMethod
from theClass
.- Type Parameters:
T
- Type ofClass
.- Parameters:
methodName
- Name ofMethod
.- Returns:
Method
.
-
instance
public static MethodObjectFactory instance(java.lang.Object object)
Convenience means to createMethodObjectFactory
.- Parameters:
object
- Instance.- Returns:
MethodObjectFactory
.
-
buildMethod
public static ManagedFunctionType<Indexed,Indexed> buildMethod(java.lang.Object instance, java.lang.String methodName, java.util.function.Consumer<ManagedFunctionTypeBuilder<Indexed,Indexed>> epectedTypeBuilder, java.lang.String... propertyNameValues) throws java.lang.Exception
Convenience method to build theManagedFunctionType
.- Parameters:
instance
- Instance.methodName
- Name ofMethod
.epectedTypeBuilder
- Builds expectedManagedFunctionType
.propertyNameValues
-Property
name/value pairs.- Returns:
ManagedFunctionType
.- Throws:
java.lang.Exception
- If fails to build theManagedFunctionType
.
-
buildStaticMethod
public static ManagedFunctionType<Indexed,Indexed> buildStaticMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.util.function.Consumer<ManagedFunctionTypeBuilder<Indexed,Indexed>> epectedTypeBuilder, java.lang.String... propertyNameValues) throws java.lang.Exception
Convenience method to build theManagedFunctionType
.- Parameters:
clazz
-Class
containing the staticMethod
.methodName
- Name of the staticMethod
.epectedTypeBuilder
- Builds expectedManagedFunctionType
.propertyNameValues
-Property
name/value pairs.- Returns:
ManagedFunctionType
.- Throws:
java.lang.Exception
- If fails to build theManagedFunctionType
.
-
buildMethod
public static <T> ManagedFunctionType<Indexed,Indexed> buildMethod(java.lang.Class<T> clazz, java.util.function.Function<java.lang.Class<T>,java.lang.reflect.Method> methodFactory, MethodObjectFactory objectInstanceFactory, FunctionNamespaceBuilder expectedFunctionNamespaceType, java.lang.String... propertyNameValues) throws java.lang.Exception
Builds theManagedFunctionType
.- Type Parameters:
T
- Type ofClass
.- Parameters:
clazz
-Class
.methodFactory
- Factory to create theMethod
.objectInstanceFactory
-MethodObjectFactory
.expectedFunctionNamespaceType
- ExpectedFunctionNamespaceBuilder
.propertyNameValues
-Property
name/value pairs.- Returns:
ManagedFunctionType
.- Throws:
java.lang.Exception
- If fails to build theManagedFunctionType
.
-
runMethod
public static MethodManagedFunctionBuilderUtil.MethodResult runMethod(java.lang.Object instance, java.lang.String methodName, java.util.function.Consumer<ManagedFunctionTypeBuilder<Indexed,Indexed>> epectedTypeBuilder, java.util.function.Consumer<MethodManagedFunctionBuilderUtil.ManagedFunctionContextBuilder> contextBuilder, java.lang.String... propertyNameValues)
Convenience method to build and run aManagedFunction
.- Parameters:
instance
- Instance.methodName
- Name ofMethod
.epectedTypeBuilder
- Builds expectedManagedFunctionType
.contextBuilder
- Builds up theManagedFunctionContext
.propertyNameValues
-Property
name/value pairs.- Returns:
MethodManagedFunctionBuilderUtil.MethodResult
.
-
runStaticMethod
public static MethodManagedFunctionBuilderUtil.MethodResult runStaticMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.util.function.Consumer<ManagedFunctionTypeBuilder<Indexed,Indexed>> epectedTypeBuilder, java.util.function.Consumer<MethodManagedFunctionBuilderUtil.ManagedFunctionContextBuilder> contextBuilder, java.lang.String... propertyNameValues)
Convenience method to build and run aManagedFunction
for staticMethod
.- Parameters:
clazz
-Class
containing the staticMethod
.methodName
- Name of the staticMethod
.epectedTypeBuilder
- Builds expectedManagedFunctionType
.contextBuilder
- Builds up theManagedFunctionContext
.propertyNameValues
-Property
name/value pairs.- Returns:
MethodManagedFunctionBuilderUtil.MethodResult
.
-
runMethod
public static MethodManagedFunctionBuilderUtil.MethodResult runMethod(ManagedFunctionType<Indexed,Indexed> functionType, java.util.function.Consumer<MethodManagedFunctionBuilderUtil.ManagedFunctionContextBuilder> contextBuilder) throws java.lang.Throwable
Runs theManagedFunction
.- Parameters:
functionType
-ManagedFunctionType
.contextBuilder
- Builds up theManagedFunctionContext
.- Returns:
MethodManagedFunctionBuilderUtil.MethodResult
.- Throws:
java.lang.Throwable
- If fails to createManagedFunction
.
-
-