函数在流口水中返回错误的布尔值

时间:2018-11-02 09:43:20

标签: java drools

我正在使用Drool规则引擎来处理业务规则。对于以下规则,我得到的响应不正确。

rule "H13: Offer not valid for channelType requesting offers"
activation-group "OFFER"
salience 4
    when
      offer : OfferEligibilityRulesData(isOfferInvalidForRequestedChannelType(getOfferChannelType(),getRequestChannelType()))
    then
          offer.setInEligible("Offer channelType type is not equal to requesting channelType type","0028","H13");
end

function boolean isOfferInvalidForRequestedChannelType(String offerChannel, String requestChannel){
  return offerChannel!="ALL" && offerChannel!=requestChannel;
}

当我使用offerChannelType =“ ALL”和requestchannelType =“ mobile”函数调用此规则时,返回错误的结果值TRUE。期望值为FALSE。

当删除函数调用并将其主体写入规则本身时,一切正常。

rule "H13: Offer not valid for channelType requesting offers"
activation-group "OFFER"
salience 4
    when
      offer : OfferEligibilityRulesData(getOfferChannelType()!="ALL" && getOfferChannelType()!=getRequestChannelType())
    then
          offer.setInEligible("Offer channelType type is not equal to requesting channelType type","0028","H13");
end

有人可以告诉我第一种方法有什么问题吗?同样,第一种方法的单元测试也可以正常工作。只有当我运行该应用程序时,我才会遇到这个问题

0 个答案:

没有答案