Author: apatel
Date: Sat Sep 20 11:25:05 2014 New Revision: 1626421 URL: http://svn.apache.org/r1626421 Log: [OFBIZ-4838] Applied more recent patch. Thanks Tom Burns for reporting the issue and providing the fix. Thanks Deepak Dixit for testing and making adjustments to the patch. Added: ofbiz/trunk/applications/party/script/org/ofbiz/party/test/PartyStatusChangeTests.xml (with props) ofbiz/trunk/applications/party/testdef/PartyStatusChangeTests.xml (with props) ofbiz/trunk/applications/party/testdef/data/PartyStatusChangeTestData.xml (with props) Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java ofbiz/trunk/applications/party/testdef/PartyTests.xml Added: ofbiz/trunk/applications/party/script/org/ofbiz/party/test/PartyStatusChangeTests.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/script/org/ofbiz/party/test/PartyStatusChangeTests.xml?rev=1626421&view=auto ============================================================================== --- ofbiz/trunk/applications/party/script/org/ofbiz/party/test/PartyStatusChangeTests.xml (added) +++ ofbiz/trunk/applications/party/script/org/ofbiz/party/test/PartyStatusChangeTests.xml Sat Sep 20 11:25:05 2014 @@ -0,0 +1,72 @@ +<?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. +--> + +<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods-v2.xsd"> + + <simple-method method-name="testSetPartyStatusToDisabled" short-description="Test case for changing party status to PARTY_DISABLED." login-required="false"> + <now-timestamp field="nowTimestamp"/> + <set field="serviceCtx.locale" value="en"/> + <set field="serviceCtx.partyId" value="PARTY_ENABLED"/> + <set field="serviceCtx.statusId" value="PARTY_DISABLED"/> + <set field="serviceCtx.statusDate" from-field="nowTimestamp"/> + <entity-one entity-name="UserLogin" value-field="userLogin"> + <field-map field-name="userLoginId" value="system"/> + </entity-one> + <set field="serviceCtx.userLogin" from-field="userLogin"/> + <call-service service-name="setPartyStatus" in-map-name="serviceCtx"> + <results-to-map map-name="results"/> + </call-service> + <entity-one entity-name="Party" value-field="party"> + <field-map field-name="partyId" value="PARTY_ENABLED"/> + </entity-one> + <assert> + <not><if-empty field="results"/></not> + <if-compare field="party.statusId" operator="equals" value="PARTY_DISABLED"/> + <if-compare field="results.oldStatusId" operator="equals" value="PARTY_ENABLED"/> + </assert> + <check-errors/> + </simple-method> + + <simple-method method-name="testSetPartyStatusToEnabled" short-description="Test case for changing party status to PARTY_DISABLED." login-required="false"> + <now-timestamp field="nowTimestamp"/> + <set field="serviceCtx.locale" value="en"/> + <set field="serviceCtx.partyId" value="PARTY_DISABLED"/> + <set field="serviceCtx.statusId" value="PARTY_ENABLED"/> + <set field="serviceCtx.statusDate" from-field="nowTimestamp"/> + <entity-one entity-name="UserLogin" value-field="userLogin"> + <field-map field-name="userLoginId" value="system"/> + </entity-one> + <set field="serviceCtx.userLogin" from-field="userLogin"/> + <call-service service-name="setPartyStatus" in-map-name="serviceCtx"> + <results-to-map map-name="results"/> + </call-service> + <entity-one entity-name="Party" value-field="party"> + <field-map field-name="partyId" value="PARTY_DISABLED"/> + </entity-one> + <assert> + <not><if-empty field="results"/></not> + <if-compare field="party.statusId" operator="equals" value="PARTY_ENABLED"/> + <if-compare field="results.oldStatusId" operator="equals" value="PARTY_DISABLED"/> + </assert> + <check-errors/> + </simple-method> + +</simple-methods> \ No newline at end of file Propchange: ofbiz/trunk/applications/party/script/org/ofbiz/party/test/PartyStatusChangeTests.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/party/script/org/ofbiz/party/test/PartyStatusChangeTests.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/party/script/org/ofbiz/party/test/PartyStatusChangeTests.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java?rev=1626421&r1=1626420&r2=1626421&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java Sat Sep 20 11:25:05 2014 @@ -223,12 +223,13 @@ public class PartyServices { try { GenericValue party = delegator.findOne("Party", UtilMisc.toMap("partyId", partyId), false); - if (party.get("statusId") == null) { // old records - party.set("statusId", "PARTY_ENABLED"); - } - String oldStatusId = party.getString("statusId"); - if (!party.getString("statusId").equals(statusId)) { + if (!statusId.equals(oldStatusId)) { + + if (oldStatusId == null) { // old records + party.set("statusId", "PARTY_ENABLED"); + oldStatusId = party.getString("statusId"); + } else { // check that status is defined as a valid change GenericValue statusValidChange = delegator.findOne("StatusValidChange", UtilMisc.toMap("statusId", party.getString("statusId"), "statusIdTo", statusId), false); @@ -242,6 +243,7 @@ public class PartyServices { } party.set("statusId", statusId); + } party.store(); // record this status change in PartyStatus table Added: ofbiz/trunk/applications/party/testdef/PartyStatusChangeTests.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/testdef/PartyStatusChangeTests.xml?rev=1626421&view=auto ============================================================================== --- ofbiz/trunk/applications/party/testdef/PartyStatusChangeTests.xml (added) +++ ofbiz/trunk/applications/party/testdef/PartyStatusChangeTests.xml Sat Sep 20 11:25:05 2014 @@ -0,0 +1,32 @@ +<?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="partystatuschangetests" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd"> + + <test-case case-name="partystatuschangetestdata"> + <entity-xml action="load" entity-xml-url="component://party/testdef/data/PartyStatusChangeTestData.xml"/> + </test-case> + + <test-case case-name="partystatuschangetest"> + <simple-method-test location="component://party/script/org/ofbiz/party/test/PartyStatusChangeTests.xml"/> + </test-case> + +</test-suite> Propchange: ofbiz/trunk/applications/party/testdef/PartyStatusChangeTests.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/party/testdef/PartyStatusChangeTests.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/party/testdef/PartyStatusChangeTests.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: ofbiz/trunk/applications/party/testdef/PartyTests.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/testdef/PartyTests.xml?rev=1626421&r1=1626420&r2=1626421&view=diff ============================================================================== --- ofbiz/trunk/applications/party/testdef/PartyTests.xml (original) +++ ofbiz/trunk/applications/party/testdef/PartyTests.xml Sat Sep 20 11:25:05 2014 @@ -24,5 +24,11 @@ <test-case case-name="party-tests"> <simple-method-test location="component://party/script/org/ofbiz/party/test/PartyTests.xml"/> </test-case> - + <test-case case-name="partystatuschangetestdata"> + <entity-xml action="load" entity-xml-url="component://party/testdef/data/PartyStatusChangeTestData.xml"/> + </test-case> + <test-case case-name="partystatuschangetest"> + <simple-method-test location="component://party/script/org/ofbiz/party/test/PartyStatusChangeTests.xml"/> + </test-case> + </test-suite> Added: ofbiz/trunk/applications/party/testdef/data/PartyStatusChangeTestData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/testdef/data/PartyStatusChangeTestData.xml?rev=1626421&view=auto ============================================================================== --- ofbiz/trunk/applications/party/testdef/data/PartyStatusChangeTestData.xml (added) +++ ofbiz/trunk/applications/party/testdef/data/PartyStatusChangeTestData.xml Sat Sep 20 11:25:05 2014 @@ -0,0 +1,25 @@ +<?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. +--> + +<entity-engine-xml> + <Party partyId="PARTY_ENABLED" statusId="PARTY_ENABLED"/> + <Party partyId="PARTY_DISABLED" statusId="PARTY_DISABLED"/> + <Party partyId="STATUS_NULL"/> +</entity-engine-xml> \ No newline at end of file Propchange: ofbiz/trunk/applications/party/testdef/data/PartyStatusChangeTestData.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/party/testdef/data/PartyStatusChangeTestData.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/party/testdef/data/PartyStatusChangeTestData.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml |
Free forum by Nabble | Edit this page |