Fix OFBIZ-5565: FinAccountHelper.getFinAccountFromCode() no longer

returns financial account.

Now that EntityCondition lookups work against encrypted fields, there is
no longer a need to do the field encryption locally in the above method.
So, just pass the value directly into the entity engine.

There are also test cases, to prevent this breakage from occurring
again.

This commit depends on r1604967 and r1604968, at the minimum.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604993 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adam Heath
2014-06-24 01:30:56 +00:00
parent 1596c224f4
commit d4ae304e5a
4 changed files with 88 additions and 4 deletions
+1
View File
@@ -52,6 +52,7 @@ under the License.
<service-resource type="model" loader="main" location="servicedef/services_olap.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas.xml"/>
<test-suite loader="main" location="testdef/FinAccountTests.xml"/>
<test-suite loader="main" location="testdef/OrderTest.xml"/>
<test-suite loader="main" location="testdef/CustRequestTests.xml"/>
<test-suite loader="main" location="testdef/quotetests.xml"/>
@@ -140,11 +140,8 @@ public class FinAccountHelper {
}
finAccountCode = finAccountCode.toUpperCase().replaceAll("[^0-9A-Z]", "");
// now we need to get the encrypted version of the fin account code the user passed in to look up against FinAccount
String encryptedFinAccountCode = (String) delegator.encryptFieldValue("FinAccount", finAccountCode);
// now look for the account
List<GenericValue> accounts = delegator.findByAnd("FinAccount", UtilMisc.toMap("finAccountCode", encryptedFinAccountCode), null, false);
List<GenericValue> accounts = delegator.findByAnd("FinAccount", UtilMisc.toMap("finAccountCode", finAccountCode), null, false);
accounts = EntityUtil.filterByDate(accounts);
if (UtilValidate.isEmpty(accounts)) {
@@ -0,0 +1,58 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*******************************************************************************/
package org.ofbiz.order.test;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.service.testtools.OFBizTestCase;
import org.ofbiz.order.finaccount.FinAccountHelper;
public class FinAccountTest extends OFBizTestCase {
public FinAccountTest(String name) {
super(name);
}
public void testCreateFinAccountBasic() throws Exception {
String finAccountCode;
GenericValue account;
finAccountCode = FinAccountHelper.getNewFinAccountCode(20, delegator);
System.err.printf("finAccountCode=%s\n", finAccountCode);
assertNotNull(finAccountCode);
account = FinAccountHelper.getFinAccountFromCode(finAccountCode, delegator);
assertNull(account);
delegator.createSetNextSeqId(delegator.makeValue("FinAccount", UtilMisc.toMap("finAccountCode", finAccountCode)));
account = FinAccountHelper.getFinAccountFromCode(finAccountCode, delegator);
assertNotNull(account);
assertEquals(finAccountCode, account.get("finAccountCode"));
account = FinAccountHelper.getFinAccountFromCode(finAccountCode.toUpperCase(), delegator);
assertNotNull(account);
assertEquals(finAccountCode, account.get("finAccountCode"));
account = FinAccountHelper.getFinAccountFromCode(finAccountCode.toLowerCase(), delegator);
assertNotNull(account);
assertEquals(finAccountCode, account.get("finAccountCode"));
delegator.createSetNextSeqId(delegator.makeValue("FinAccount", UtilMisc.toMap("finAccountCode", finAccountCode)));
account = FinAccountHelper.getFinAccountFromCode(finAccountCode, delegator);
assertNull(account);
}
}
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<test-suite suite-name="finaccounttests"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">
<test-case case-name="finaccount-tests">
<junit-test-suite class-name="org.ofbiz.order.test.FinAccountTest"/>
</test-case>
</test-suite>