You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2014/06/24 03:30:56 UTC

svn commit: r1604993 - in /ofbiz/trunk/applications/order: ofbiz-component.xml src/org/ofbiz/order/finaccount/FinAccountHelper.java src/org/ofbiz/order/test/FinAccountTest.java testdef/FinAccountTests.xml

Author: doogie
Date: Tue Jun 24 01:30:56 2014
New Revision: 1604993

URL: http://svn.apache.org/r1604993
Log:
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.

Added:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/test/FinAccountTest.java
    ofbiz/trunk/applications/order/testdef/FinAccountTests.xml
Modified:
    ofbiz/trunk/applications/order/ofbiz-component.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java

Modified: ofbiz/trunk/applications/order/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/ofbiz-component.xml?rev=1604993&r1=1604992&r2=1604993&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/ofbiz-component.xml (original)
+++ ofbiz/trunk/applications/order/ofbiz-component.xml Tue Jun 24 01:30:56 2014
@@ -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"/>

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java?rev=1604993&r1=1604992&r2=1604993&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java Tue Jun 24 01:30:56 2014
@@ -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)) {

Added: ofbiz/trunk/applications/order/src/org/ofbiz/order/test/FinAccountTest.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/test/FinAccountTest.java?rev=1604993&view=auto
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/test/FinAccountTest.java (added)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/test/FinAccountTest.java Tue Jun 24 01:30:56 2014
@@ -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);
+    }
+}

Added: ofbiz/trunk/applications/order/testdef/FinAccountTests.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/testdef/FinAccountTests.xml?rev=1604993&view=auto
==============================================================================
--- ofbiz/trunk/applications/order/testdef/FinAccountTests.xml (added)
+++ ofbiz/trunk/applications/order/testdef/FinAccountTests.xml Tue Jun 24 01:30:56 2014
@@ -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>