/**
* Test updates the description of {@link Currency} by the admin user.
*/
public void testUpdateCurrencyByAdmin() {
setBigBazaarAdminContext();
Currency c = null;
String prevDescription = null;
String newDescription = null;
{
final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "USD"));
final List<Currency> cs = obc.list();
assertEquals(1, cs.size());
c = cs.get(0);
prevDescription = c.getDescription();
c.setDescription(c.getDescription() + " a test");
newDescription = c.getDescription();
OBDal.getInstance().save(c);
commitTransaction();
}
// roll back the change, while doing some checks
{
final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "USD"));
final List<Currency> cs = obc.list();
assertEquals(1, cs.size());
final Currency newC = cs.get(0);
assertTrue(c != newC);
assertEquals(newDescription, newC.getDescription());
newC.setDescription(prevDescription);
commitTransaction();
}
}