Package org.drools.spring.pojorule

Examples of org.drools.spring.pojorule.RuleReflectMethod


            Argument[] arguments = getArguments(rule, argumentsMetadata);

            if (methodMetadata.getMethodType() == MethodMetadata.METHOD_CONDITION) {
                assertReturnType(pojoMethod, boolean.class);
                rule.addCondition(
                        new PojoCondition(new RuleReflectMethod(rule, pojo, pojoMethod, arguments)));
                log.info("Condition method added to rule: " + pojoMethod.toString());

            } else if (methodMetadata.getMethodType() == MethodMetadata.METHOD_CONSEQUENCE) {
                conditionRuleReflectMethods.add(
                        new RuleReflectMethod(rule, pojo, pojoMethod, arguments));
                log.info("Consequence method added to rule: " + pojoMethod.toString());
            } else if (methodMetadata.getMethodType() == MethodMetadata.OBJECT_CONDITION) {
                if (arguments.length != 0) {
                    throw new InvalidPojoConditionException("Rule pojo condition must not have arguments"
                                                            + ": method = " + pojoMethod + ", arguments = " + arguments);
View Full Code Here


            ArgumentMetadata[] argumentsMetadata = getArgumentMetadata(pojoMethod);
            Argument[] arguments = getArguments(rule, argumentsMetadata);
   
            if (methodMetadata.getMethodType() == MethodMetadata.METHOD_CONDITION) {
                assertReturnType(pojoMethod, boolean.class);
                rule.addCondition(new PojoCondition(new RuleReflectMethod(rule, pojo, pojoMethod, arguments)));
   
            }
        }
    }
View Full Code Here

    private EasymockContainer mocks = new EasymockContainer();

    public void testGetParameterValues() throws Exception {
        Argument[] expectedParameterValues = new Argument[] {};

        RuleReflectMethod ruleMethod = new RuleReflectMethod(null, null, null,
                expectedParameterValues);
        Argument[] parameterValues = ruleMethod.getArguments();

        assertSame(expectedParameterValues, parameterValues);
    }
View Full Code Here

        Argument[] parameterValues = new Argument[] {
                mockKnowledgeHelperArgument, mockFactArgument, mockApplicationDataArgument };

        mocks.replay();

        RuleReflectMethod ruleMethod = new RuleReflectMethod(rule, pojo, pojoMethod,
                parameterValues);
        ruleMethod.invokeMethod(mockTuple);

        mocks.verify();
    }
View Full Code Here

        Argument[] parameterValues = new Argument[] { new TestArgument() };

        SerializablePojo pojo = new SerializablePojo();
        Method pojoMethod = SerializablePojo.class
                .getMethod("method", new Class[] { String.class });
        RuleReflectMethod ruleMethod = new RuleReflectMethod(rule, pojo, pojoMethod,
                parameterValues);

        RuleReflectMethod deserializedRuleMethod = (RuleReflectMethod) fromByteArray(toByteArray(ruleMethod));
        deserializedRuleMethod.invokeMethod(null);

        Field pojoField = deserializedRuleMethod.getClass().getDeclaredField("pojo");
        pojoField.setAccessible(true);
        SerializablePojo deserializedPojo = (SerializablePojo) pojoField
                .get(deserializedRuleMethod);

        assertEquals("VALUE", deserializedPojo.methodString);
View Full Code Here

        parameterValues[0] = new ApplicationDataArgument("name", Object.class);
        parameterValues[1] = new FactArgument(expectedDeclaration_1);
        parameterValues[2] = new FactArgument(expectedDeclaration_2);

        MockControl controlRuleMethod = newMockRuleMethod();
        RuleReflectMethod mockRuleMethod = (RuleReflectMethod) controlRuleMethod.getMock();
        controlRuleMethod.expectAndReturn(mockRuleMethod.getArguments(), parameterValues);

        mocks.replay();

        PojoCondition pojoCondition = new PojoCondition(mockRuleMethod);
View Full Code Here

        assertSame(expectedDeclaration_2, requiredTupleMembers[1]);
    }

    public void testPojoMethodThrowsException() throws Exception {
        MockControl controlRuleMethod = newMockRuleMethod();
        RuleReflectMethod mockRuleMethod = (RuleReflectMethod) controlRuleMethod.getMock();
        controlRuleMethod.expectAndReturn(mockRuleMethod.getArguments(), new Argument[] {});
        controlRuleMethod.expectAndThrow(mockRuleMethod.invokeMethod(null), new RuntimeException("test"));

        mocks.replay();

        PojoCondition pojoCondition = new PojoCondition(mockRuleMethod);
        try {
View Full Code Here

    public void testIsAllowed() throws Exception {
        MockControl controlTuple = mocks.createControl(Tuple.class);
        Tuple mockTuple = (Tuple)controlTuple.getMock();
        MockControl controlRuleMethod = newMockRuleMethod();
        RuleReflectMethod mockRuleMethod = (RuleReflectMethod) controlRuleMethod.getMock();
        controlRuleMethod.expectAndReturn(mockRuleMethod.getArguments(), new Argument[] {});
        controlRuleMethod.expectAndReturn(mockRuleMethod.invokeMethod(mockTuple), Boolean.TRUE);

        mocks.replay();

        PojoCondition pojoCondition = new PojoCondition(mockRuleMethod);
        pojoCondition.isAllowed(mockTuple);
View Full Code Here

    public void testPojoMethodThrowsException() throws Exception {
        MockControl controlTuple = mocks.createControl(Tuple.class);
        Tuple mockTuple = (Tuple)controlTuple.getMock();
        MockControl controlRuleMethod = newMockRuleMethod();
        RuleReflectMethod mockRuleMethod = (RuleReflectMethod) controlRuleMethod.getMock();
        controlRuleMethod.expectAndThrow(mockRuleMethod.invokeMethod(mockTuple),
                new RuntimeException("test-exception"));
        RuleReflectMethod[] mockRuleMethods = new RuleReflectMethod[]{mockRuleMethod};

        mocks.replay();
View Full Code Here

    public void testInvoke() throws Exception {
        MockControl controlTuple = mocks.createControl(Tuple.class);
        Tuple mockTuple = (Tuple)controlTuple.getMock();
        MockControl controlRuleMethod = newMockRuleMethod();
        RuleReflectMethod mockRuleMethod = (RuleReflectMethod) controlRuleMethod.getMock();
        controlRuleMethod.expectAndReturn(mockRuleMethod.invokeMethod(mockTuple), null);
        RuleReflectMethod[] mockRuleMethods = new RuleReflectMethod[]{mockRuleMethod};

        mocks.replay();

        PojoConsequence pojoConsequence = new PojoConsequence(mockRuleMethods);
View Full Code Here

TOP

Related Classes of org.drools.spring.pojorule.RuleReflectMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.