Example usage for java.math BigDecimal ONE

List of usage examples for java.math BigDecimal ONE

Introduction

In this page you can find the example usage for java.math BigDecimal ONE.

Prototype

BigDecimal ONE

To view the source code for java.math BigDecimal ONE.

Click Source Link

Document

The value 1, with a scale of 0.

Usage

From source file:com.redhat.lightblue.metadata.types.BigDecimalTypeTest.java

@Test
public void testCompareEqual() {
    assertEquals(bigDecimalType.compare((Object) BigDecimal.ONE, (Object) BigDecimal.ONE), 0);
}

From source file:org.codelibs.fess.service.SuggestElevateWordService.java

public void importCsv(final Reader reader) {
    final CsvReader csvReader = new CsvReader(reader, new CsvConfig());
    try {//from   ww  w  . j  a v a2  s  .  co  m
        List<String> list;
        csvReader.readValues(); // ignore header
        while ((list = csvReader.readValues()) != null) {
            final String suggestWord = getValue(list, 0);
            if (StringUtil.isBlank(suggestWord)) {
                // skip
                continue;
            }
            try {
                final String role = getValue(list, 2);
                final String label = getValue(list, 3);
                SuggestElevateWord suggestElevateWord = suggestElevateWordBhv.selectEntity(cb -> {
                    cb.query().setSuggestWord_Equal(suggestWord);
                    if (StringUtil.isNotBlank(role)) {
                        cb.query().setTargetRole_Equal(role);
                    }
                    if (StringUtil.isNotBlank(label)) {
                        cb.query().setTargetLabel_Equal(label);
                    }
                }).orElse(null);//TODO
                final String reading = getValue(list, 1);
                final String boost = getValue(list, 4);
                final LocalDateTime now = ComponentUtil.getSystemHelper().getCurrentTime();
                if (suggestElevateWord == null) {
                    suggestElevateWord = new SuggestElevateWord();
                    suggestElevateWord.setSuggestWord(suggestWord);
                    suggestElevateWord.setReading(reading);
                    suggestElevateWord.setTargetRole(role);
                    suggestElevateWord.setTargetLabel(label);
                    suggestElevateWord
                            .setBoost(StringUtil.isBlank(boost) ? BigDecimal.ONE : new BigDecimal(boost));
                    suggestElevateWord.setCreatedBy("system");
                    suggestElevateWord.setCreatedTime(now);
                    suggestElevateWordBhv.insert(suggestElevateWord);
                } else if (StringUtil.isBlank(reading) && StringUtil.isBlank(boost)) {
                    suggestElevateWord.setDeletedBy("system");
                    suggestElevateWord.setDeletedTime(now);
                    suggestElevateWordBhv.update(suggestElevateWord);
                } else {
                    suggestElevateWord.setReading(reading);
                    suggestElevateWord
                            .setBoost(StringUtil.isBlank(boost) ? BigDecimal.ONE : new BigDecimal(boost));
                    suggestElevateWord.setUpdatedBy("system");
                    suggestElevateWord.setUpdatedTime(now);
                    suggestElevateWordBhv.update(suggestElevateWord);
                }
            } catch (final Exception e) {
                log.warn("Failed to read a sugget elevate word: " + list, e);
            }
        }
    } catch (final IOException e) {
        log.warn("Failed to read a sugget elevate word.", e);
    }
}

From source file:org.apache.sling.jcr.resource.internal.JcrPropertyMapTest.java

public void testTypeByDefaultValue() throws Exception {
    this.rootNode.getSession().refresh(false);
    testValue(rootNode, "A String Value", "default");

    testValue(rootNode, 1l, (byte) 10);
    testValue(rootNode, 1l, (short) 10);
    testValue(rootNode, 1l, 10);//from w w w  .j  a  va2  s  .  co  m
    testValue(rootNode, 1l, 10l);

    testValue(rootNode, 1.0d, 10.0f);
    testValue(rootNode, 1.0d, 10.0d);
    testValue(rootNode, 1.0d, new BigDecimal("1.0"));

    testValue(rootNode, BigDecimal.TEN, 10.0f);
    testValue(rootNode, BigDecimal.TEN, 10.0d);
    testValue(rootNode, BigDecimal.TEN, BigDecimal.TEN);

    long refTime = 1000l;
    Date refDate = new Date(refTime);
    Calendar refCal = Calendar.getInstance();
    refCal.setTimeInMillis(refTime);

    Calendar cal = Calendar.getInstance();
    testValue(rootNode, cal, refCal);
    testValue(rootNode, cal, refDate);
    testValue(rootNode, cal, refTime);

    testValue(rootNode, BigDecimal.TEN, BigDecimal.ONE);
}

From source file:pe.gob.mef.gescon.web.ui.ParametroMB.java

public void cleanAttributes() {
    this.setId(BigDecimal.ZERO);
    this.setDescripcion(StringUtils.EMPTY);
    this.setNombre(StringUtils.EMPTY);
    this.setValor(StringUtils.EMPTY);
    this.setActivo(BigDecimal.ONE);
    this.setSelectedParametro(null);
    Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages();
    if (iter.hasNext() == true) {
        iter.remove();/* ww  w.  j  a v  a2  s. c o m*/
        FacesContext.getCurrentInstance().renderResponse();
    }
}

From source file:com.redhat.lightblue.metadata.types.BigDecimalTypeTest.java

@Test
public void testCompareNotEqual() {
    assertEquals(bigDecimalType.compare((Object) BigDecimal.ZERO, (Object) BigDecimal.ONE), -1);
}

From source file:pe.gob.mef.gescon.hibernate.impl.BaseLegalDaoImpl.java

@Override
public List<HashMap> getTbaselegalesLinkedById(final BigDecimal id) throws Exception {
    final StringBuilder sql = new StringBuilder();
    Object object = null;/*www.j  av a2  s .c  o m*/
    try {
        sql.append(
                "SELECT a.nbaselegalid AS ID, a.vnumero AS NUMERO, a.vnombre AS NOMBRE, a.vsumilla AS SUMILLA, ");
        sql.append(
                "       a.ncategoriaid AS IDCATEGORIA, b.vnombre AS CATEGORIA, a.dfechapublicacion AS FECHA, ");
        sql.append("       e.ntipovinculo AS IDESTADO, c.vnombre AS ESTADO ");
        sql.append("FROM TBASELEGAL a ");
        sql.append("INNER JOIN MTCATEGORIA b ON a.ncategoriaid = b.ncategoriaid ");
        sql.append(
                "INNER JOIN TVINCULO_BASELEGAL e ON a.nbaselegalid = e.nbaselegalvinculadaid AND e.nbaselegalid = :ID ");
        sql.append("INNER JOIN MTESTADO_BASELEGAL c ON e.ntipovinculo = c.nestadoid ");
        sql.append("WHERE a.nactivo = :ACTIVO ");
        sql.append(
                "AND a.nbaselegalid IN(SELECT d.nbaselegalvinculadaid FROM TVINCULO_BASELEGAL d WHERE d.nbaselegalid = :ID)");
        sql.append("ORDER BY a.vnumero ");

        object = getHibernateTemplate().execute(new HibernateCallback() {
            @Override
            public Object doInHibernate(Session session) throws HibernateException {
                Query query = session.createSQLQuery(sql.toString());
                query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
                query.setParameter("ACTIVO", BigDecimal.ONE);
                query.setParameter("ID", id);
                return query.list();
            }
        });
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
    return (List<HashMap>) object;
}

From source file:org.openvpms.archetype.rules.finance.till.TillRulesTestCase.java

/**
 * Verifies that an act doesn't get added to a new till balance if it
 * is subsequently saved after the till has been cleared.
 *//*from   ww  w.  j a  va 2s .co  m*/
@Test
public void testClearTillAndReSave() {
    List<FinancialAct> payment = createPayment(till);
    payment.get(0).setStatus(POSTED);
    FinancialAct balance = checkAddToTillBalance(till, payment, false, BigDecimal.ONE);

    // clear the till
    Party account = DepositTestHelper.createDepositAccount();
    rules.clearTill(balance, BigDecimal.ZERO, account);

    // reload the act and save it to force TillRules.addToTill() to run
    // again. However the act should not be added to a new balance as
    // there is an existing actRelationship.tillBalanceItem relationship.
    Act latest = get(payment.get(0));
    save(latest);
    latest = get(latest);
    ActBean bean = new ActBean(latest);
    List<ActRelationship> relationships = bean.getRelationships("actRelationship.tillBalanceItem");
    assertEquals(1, relationships.size());
}

From source file:alfio.test.util.IntegrationTestUtil.java

public static Pair<Event, String> initEvent(List<TicketCategoryModification> categories,
        OrganizationRepository organizationRepository, UserManager userManager, EventManager eventManager,
        EventRepository eventRepository) {

    String organizationName = UUID.randomUUID().toString();
    String username = UUID.randomUUID().toString();
    String eventName = UUID.randomUUID().toString();

    userManager.createOrganization(organizationName, "org", "email@example.com");
    Organization organization = organizationRepository.findByName(organizationName).get();
    userManager.insertUser(organization.getId(), username, "test", "test", "test@example.com", Role.OPERATOR,
            User.Type.INTERNAL);
    userManager.insertUser(organization.getId(), username + "_owner", "test", "test", "test@example.com",
            Role.OWNER, User.Type.INTERNAL);

    LocalDateTime expiration = LocalDateTime.now().plusDays(5).plusHours(1);

    Map<String, String> desc = new HashMap<>();
    desc.put("en", "muh description");
    desc.put("it", "muh description");
    desc.put("de", "muh description");

    EventModification em = new EventModification(null, Event.EventType.INTERNAL, "url", "url", "url", "url",
            null, eventName, "event display name", organization.getId(), "muh location", "0.0", "0.0",
            ZoneId.systemDefault().getId(), desc,
            new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()),
            new DateTimeModification(expiration.toLocalDate(), expiration.toLocalTime()), BigDecimal.TEN, "CHF",
            AVAILABLE_SEATS, BigDecimal.ONE, true, Collections.singletonList(PaymentProxy.OFFLINE), categories,
            false, new LocationDescriptor("", "", "", ""), 7, null, null);
    eventManager.createEvent(em);/*from ww w . j a v a2 s  .  co m*/
    Event event = eventManager.getSingleEvent(eventName, username);
    Assert.assertEquals(AVAILABLE_SEATS, eventRepository.countExistingTickets(event.getId()).intValue());
    return Pair.of(event, username);
}

From source file:org.openvpms.component.system.common.jxpath.BigDecimalTestCase.java

/**
 * Tests the mod operator.
 */
@Test
public void testMod() {
    assertEquals(BigDecimal.ONE, context.getValue("3 mod 2"));
}

From source file:org.fineract.module.stellar.TestPaymentInSimpleNetwork.java

@Test
public void paymentAboveCreditLimit() throws Exception {
    logger.info("paymentAboveCreditLimit test begin");

    final AccountListener accountListener = new AccountListener(serverAddress, secondTenantId, firstTenantId);

    BigDecimal transferAmount = TRUST_LIMIT.add(BigDecimal.ONE);
    makePayment(firstTenantId, firstTenantApiKey, secondTenantId, ASSET_CODE, transferAmount);

    accountListener.waitForCredits(PAY_WAIT,
            creditMatcher(secondTenantId, transferAmount, ASSET_CODE, firstTenantId));

    checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId),
            BigDecimal.ZERO);//from w w  w.j  a v a  2 s. c  o m
}