Package org.openbravo.model.common.currency

Examples of org.openbravo.model.common.currency.Currency


    setBigBazaarAdminContext();
    final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
    obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "TE2"));
    final List<Currency> cs = obc.list();
    if (cs.size() == 0) {
      final Currency c = OBProvider.getInstance().get(Currency.class);
      c.setSymbol("TE2");
      c.setDescription("test currency");
      c.setISOCode("TE2");
      c.setPricePrecision((long) 5);
      c.setStandardPrecision((long) 6);
      c.setCostingPrecision((long) 4);
      OBDal.getInstance().save(c);
    }
  }
View Full Code Here


    addReadWriteAccess(Currency.class);
    final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
    obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "TE2"));
    final List<Currency> cs = obc.list();
    assertEquals(1, cs.size());
    final Currency c = cs.get(0);
    try {
      OBDal.getInstance().remove(c);
      OBDal.getInstance().flush();
      fail("Currency should be non-deletable");
    } catch (final OBSecurityException e) {
View Full Code Here

   * Checks the derived readable concept, only identifier fields of a derived readable object may be
   * read.
   */
  public void testCheckDerivedReadableCurrency() {
    setUserContext("1000020");
    final Currency c = OBDal.getInstance().get(Currency.class, "100");
    log.debug(c.getIdentifier());
    log.debug(c.getId());
    try {
      log.debug(c.getCostingPrecision());
      fail("Derived readable not applied");
    } catch (final OBSecurityException e) {
      assertTrue("Wrong exception thrown:  " + e.getMessage(), e.getMessage().indexOf(
          "is not directly readable") != -1);
    }
View Full Code Here

  /**
   * Test derived readable on a set method, also there this check must be done.
   */
  public void testUpdateCurrencyDerivedRead() {
    setUserContext("1000020");
    final Currency c = OBDal.getInstance().get(Currency.class, "100");
    try {
      c.setCostingPrecision((long) 5);
      fail("Derived readable not checked on set");
    } catch (final OBSecurityException e) {
      assertTrue("Wrong exception thrown:  " + e.getMessage(), e.getMessage().indexOf(
          "is not directly readable") != -1);
    }
View Full Code Here

    setUserContext("1000019");
    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 c = cs.get(0);
    c.setDescription(c.getDescription() + " a test");
    try {
      OBDal.getInstance().save(c);
      fail("No security check");
    } catch (final OBSecurityException e) {
      // successfull check
View Full Code Here

  /**
   * 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();
    }
  }
View Full Code Here

    String cashBookId = "";
    {
      final OBCriteria<Currency> cc = OBDal.getInstance().createCriteria(Currency.class);
      cc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "USD"));
      final List<Currency> cs = cc.list();
      final Currency currency = cs.get(0);
      final CashBook c = OBProvider.getInstance().get(CashBook.class);
      c.setName("c_" + System.currentTimeMillis());
      c.setDescription("test");
      c.setDefault(false);
      c.set(CashBook.PROPERTY_CURRENCY, currency);
View Full Code Here

  public void testTypeChecking() {
    setBigBazaarAdminContext();
    final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class);
    obc.add(Expression.eq(Currency.PROPERTY_ISOCODE, "USD"));
    final List<Currency> cs = obc.list();
    final Currency c = cs.get(0);

    // now set difference values and get exceptions on each
    setValue(c, Currency.PROPERTY_UPDATEDBY, "test", "only allows reference instances of type");
    setValue(c, Currency.PROPERTY_CLIENT, "test", "only allows reference instances of type");
    setValue(c, Currency.PROPERTY_PRICEPRECISION, new Double(400.0), "only allows instances of");
View Full Code Here

    setUserContext("1000019");
    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 c = cs.get(0);
    c.setDescription(c.getDescription() + " a test");
    try {
      OBDal.getInstance().save(c);
      fail("No security check");
    } catch (final OBSecurityException e) {
      // successfull check, do not commit the change
View Full Code Here

TOP

Related Classes of org.openbravo.model.common.currency.Currency

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.