BF [ 1704828 ] PO.is_Changed() and PO.is_ValueChanged are not consistent
http://sourceforge.net/tracker/?func=detail&atid=879332&aid=1704828&group_id=176962
This commit is contained in:
parent
de610700c1
commit
e3b4ec86bd
|
@ -36,6 +36,8 @@ import org.w3c.dom.*;
|
|||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: PO.java,v 1.12 2006/08/09 16:38:47 jjanke Exp $
|
||||
*
|
||||
* @author Teo Sarca - FR [ 1675490 ], BF [ 1704828 ]
|
||||
*/
|
||||
public abstract class PO
|
||||
implements Serializable, Comparator, Evaluatee
|
||||
|
@ -1801,7 +1803,6 @@ public abstract class PO
|
|||
return false;
|
||||
}
|
||||
// Save
|
||||
boolean success = false;
|
||||
if (newRecord)
|
||||
return saveNew();
|
||||
else
|
||||
|
@ -1902,8 +1903,9 @@ public abstract class PO
|
|||
int size = get_ColumnCount();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
if (m_newValues[i] != null)
|
||||
return true; // something changed
|
||||
// Test if the column has changed - teo_sarca [ 1704828 ]
|
||||
if (is_ValueChanged(i))
|
||||
return true;
|
||||
}
|
||||
if (m_custom != null && m_custom.size() > 0)
|
||||
return true; // there are custom columns modified
|
||||
|
|
|
@ -14,6 +14,7 @@ public class FunctionalTestSuite {
|
|||
suite.addTestSuite(MUserTest.class);
|
||||
suite.addTestSuite(MBPGroupTest.class);
|
||||
suite.addTestSuite(MLocationTest.class);
|
||||
suite.addTestSuite(POTest.class);
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package test.functional;
|
||||
|
||||
import org.compiere.model.MTest;
|
||||
|
||||
import test.AdempiereTestCase;
|
||||
|
||||
/**
|
||||
* Tests for {@link org.compiere.model.PO} class.
|
||||
* @author Teo Sarca
|
||||
*
|
||||
*/
|
||||
public class POTest extends AdempiereTestCase
|
||||
{
|
||||
/**
|
||||
* Tests the following methods:
|
||||
* <ul>
|
||||
* <li>{@link org.compiere.model.PO#is_Changed()}
|
||||
* <li>{@link org.compiere.model.PO#is_ValueChanged(String)}
|
||||
* </ul>
|
||||
* Applies to following bugs:
|
||||
* <ul>
|
||||
* <li>[ 1704828 ] PO.is_Changed() and PO.is_ValueChanged are not consistent
|
||||
* </ul>
|
||||
* @throws Exception
|
||||
*/
|
||||
public void test_Changed() throws Exception {
|
||||
String[] testStrings = new String[] {
|
||||
"a",
|
||||
"test",
|
||||
};
|
||||
// Create the test PO and save
|
||||
MTest testPO = new MTest(getCtx(), getClass().getName(), 1);
|
||||
testPO.set_TrxName(getTrxName());
|
||||
|
||||
for (String str : testStrings) {
|
||||
testPO.setHelp(str);
|
||||
testPO.save();
|
||||
String originalString = testPO.getHelp();
|
||||
String info = "testString=[" + str + "]" + ", originalString=[" + originalString + "]";
|
||||
|
||||
// Initial asserts (nothing changed)
|
||||
assertFalse(info, testPO.is_ValueChanged(MTest.COLUMNNAME_Help));
|
||||
assertFalse(info, testPO.is_Changed());
|
||||
// Set the same name
|
||||
testPO.setHelp(originalString);
|
||||
assertFalse(info, testPO.is_ValueChanged(MTest.COLUMNNAME_Help));
|
||||
assertFalse(info, testPO.is_Changed());
|
||||
// Set a new name
|
||||
testPO.setHelp(originalString+"-changed");
|
||||
assertTrue(info, testPO.is_ValueChanged(MTest.COLUMNNAME_Help));
|
||||
assertTrue(info, testPO.is_Changed());
|
||||
// Set the original name back
|
||||
testPO.setHelp(originalString);
|
||||
assertFalse(info, testPO.is_ValueChanged(MTest.COLUMNNAME_Help));
|
||||
assertFalse(info, testPO.is_Changed());
|
||||
}
|
||||
|
||||
// Finally, delete the testPO
|
||||
testPO.delete(true, getTrxName());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue