List of usage examples for java.math BigDecimal ONE
BigDecimal ONE
To view the source code for java.math BigDecimal ONE.
Click Source Link
From source file:op.care.prescription.DlgOnDemand.java
/** * Creates new form DlgRegular/*w w w. j a va 2 s .c o m*/ */ public DlgOnDemand(Prescription prescription, Closure actionBlock) { super(false); // OnDemand prescriptions have exactly ONE schedule if (prescription.getPrescriptionSchedule().isEmpty()) { PrescriptionSchedule schedule = new PrescriptionSchedule(prescription); schedule.setMorgens(BigDecimal.ZERO); schedule.setMaxAnzahl(1); schedule.setMaxEDosis(BigDecimal.ONE); schedule.setPrescription(prescription); prescription.getPrescriptionSchedule().add(schedule); } schedule = prescription.getPrescriptionSchedule().get(0); this.actionBlock = actionBlock; this.prescription = prescription; schedules2delete = new ArrayList<PrescriptionSchedule>(); initComponents(); initDialog(); pack(); setVisible(true); }
From source file:io.curly.advisor.web.ReviewResourceControllerTests.java
@Test public void testSave() throws Exception { System.out.println(reviewEntity); System.out.println(entity(reviewEntity)); mockMvc.perform(post("/reviews").content(entity(reviewEntity)).contentType(MediaType.APPLICATION_JSON) .principal(User.builder().name("Joao").avatarUrl("example.com").id("6969").build())) .andExpect(status().isCreated()); TimeUnit.MILLISECONDS.sleep(5000); List<Review> reviews = reviewCacheAwareService.getRepository() .findAllByOwner("6969", new PageRequest(0, 20)).getContent(); Assert.assertThat(reviews, hasSize(2)); Assert.assertThat(reviews.get(1).getRate(), is(BigDecimal.ONE)); }
From source file:py.una.pol.karaku.test.test.dao.clauses.WhereTest.java
/** * Prueba si se puede crear un registro/* w w w . j a va 2 s . com*/ * * <p> * Podemos ver que una manera mas fcil de probar seria crear el registro y * llamar a {@link BaseDAO#getCount()}, pero esto esta conceptualmente mal * por que si el mtodo {@link BaseDAO#getCount()} esta mal, fallarn los * mtodos {@link #count()} y {@link #add()}, sin embargo, la creacin de * registro no tendra ningn problema. * </p> */ @Test public void add() { String description = "UNIQUE DESCRIPTION"; TestEntity te = new TestEntity(); te.setDescription(description); te.setCosto(BigDecimal.ONE); TestEntity saved = dao.add(te); assertNotNull(saved); assertNotNull(saved.getId()); assertEquals(saved, te); }
From source file:org.openbravo.advpaymentmngt.filterexpression.TransactionAddPaymentDefaultValues.java
@Override public String getDefaultConversionRate(Map<String, String> requestMap) throws JSONException { return BigDecimal.ONE.toPlainString(); }
From source file:org.codelibs.fess.web.admin.WizardAction.java
protected String crawlingConfigInternal(final String crawlingConfigName, final String crawlingConfigPath) { String configName = crawlingConfigName; String configPath = crawlingConfigPath.trim(); if (StringUtil.isBlank(configName)) { configName = StringUtils.abbreviate(configPath, 30); }/*from w w w. jav a2 s. com*/ // normalize final StringBuilder buf = new StringBuilder(); for (int i = 0; i < configPath.length(); i++) { final char c = configPath.charAt(i); if (c == '\\') { buf.append('/'); } else if (c == ' ') { buf.append("%20"); } else if (CharUtil.isUrlChar(c)) { buf.append(c); } else { try { buf.append(URLEncoder.encode(String.valueOf(c), Constants.UTF_8)); } catch (final UnsupportedEncodingException e) { } } } configPath = convertCrawlingPath(buf.toString()); final String username = systemHelper.getUsername(); final LocalDateTime now = systemHelper.getCurrentTime(); try { if (isWebCrawlingPath(configPath)) { // web final WebCrawlingConfig wConfig = new WebCrawlingConfig(); wConfig.setAvailable(Constants.T); wConfig.setBoost(BigDecimal.ONE); wConfig.setCreatedBy(username); wConfig.setCreatedTime(now); if (StringUtil.isNotBlank(wizardForm.depth)) { wConfig.setDepth(Integer.parseInt(wizardForm.depth)); } wConfig.setExcludedDocUrls( getDefaultString("default.config.web.excludedDocUrls", StringUtil.EMPTY)); wConfig.setExcludedUrls(getDefaultString("default.config.web.excludedUrls", StringUtil.EMPTY)); wConfig.setIncludedDocUrls( getDefaultString("default.config.web.includedDocUrls", StringUtil.EMPTY)); wConfig.setIncludedUrls(getDefaultString("default.config.web.includedUrls", StringUtil.EMPTY)); wConfig.setIntervalTime(getDefaultInteger("default.config.web.intervalTime", Constants.DEFAULT_INTERVAL_TIME_FOR_WEB)); if (StringUtil.isNotBlank(wizardForm.maxAccessCount)) { wConfig.setMaxAccessCount(Long.parseLong(wizardForm.maxAccessCount)); } wConfig.setName(configName); wConfig.setNumOfThread(getDefaultInteger("default.config.web.numOfThread", Constants.DEFAULT_NUM_OF_THREAD_FOR_WEB)); wConfig.setSortOrder(getDefaultInteger("default.config.web.sortOrder", 1)); wConfig.setUpdatedBy(username); wConfig.setUpdatedTime(now); wConfig.setUrls(configPath); wConfig.setUserAgent( getDefaultString("default.config.web.userAgent", ComponentUtil.getUserAgentName())); webCrawlingConfigService.store(wConfig); } else { // file final FileCrawlingConfig fConfig = new FileCrawlingConfig(); fConfig.setAvailable(Constants.T); fConfig.setBoost(BigDecimal.ONE); fConfig.setCreatedBy(username); fConfig.setCreatedTime(now); if (StringUtil.isNotBlank(wizardForm.depth)) { fConfig.setDepth(Integer.parseInt(wizardForm.depth)); } fConfig.setExcludedDocPaths( getDefaultString("default.config.file.excludedDocPaths", StringUtil.EMPTY)); fConfig.setExcludedPaths(getDefaultString("default.config.file.excludedPaths", StringUtil.EMPTY)); fConfig.setIncludedDocPaths( getDefaultString("default.config.file.includedDocPaths", StringUtil.EMPTY)); fConfig.setIncludedPaths(getDefaultString("default.config.file.includedPaths", StringUtil.EMPTY)); fConfig.setIntervalTime(getDefaultInteger("default.config.file.intervalTime", Constants.DEFAULT_INTERVAL_TIME_FOR_FS)); if (StringUtil.isNotBlank(wizardForm.maxAccessCount)) { fConfig.setMaxAccessCount(Long.parseLong(wizardForm.maxAccessCount)); } fConfig.setName(configName); fConfig.setNumOfThread(getDefaultInteger("default.config.file.numOfThread", Constants.DEFAULT_NUM_OF_THREAD_FOR_FS)); fConfig.setSortOrder(getDefaultInteger("default.config.file.sortOrder", 1)); fConfig.setUpdatedBy(username); fConfig.setUpdatedTime(now); fConfig.setPaths(configPath); fileCrawlingConfigService.store(fConfig); } return configName; } catch (final Exception e) { logger.error("Failed to create crawling config: " + wizardForm.crawlingConfigPath, e); throw new SSCActionMessagesException(e, "errors.failed_to_create_crawling_config_at_wizard", wizardForm.crawlingConfigPath); } }
From source file:com.opengamma.web.analytics.blotter.OtcTradeBuilderTest.java
@Test public void newSecurityWithNoUnderlying() { UniqueId tradeId = _builder.addTrade(createTradeData(), BlotterTestUtils.FX_FORWARD_DATA_SOURCE, null, _nodeId);//from w w w . j ava2 s . c o m ManageableTrade trade = _positionMaster.getTrade(tradeId); UniqueId positionId = trade.getParentPositionId(); ManageablePosition position = _positionMaster.get(positionId).getPosition(); assertEquals(BigDecimal.ONE, trade.getQuantity()); assertEquals(BigDecimal.ONE, position.getQuantity()); ManageableSecurity security = _securityMaster .get(trade.getSecurityLink().getObjectId(), VersionCorrection.LATEST).getSecurity(); assertNotNull(security); security.setUniqueId(null); // so it can be tested for equality against the unsaved version assertEquals(BlotterTestUtils.FX_FORWARD, security); assertEquals(COUNTERPARTY_ID, trade.getCounterpartyExternalId()); assertEquals(PREMIUM, trade.getPremium()); assertEquals(Currency.GBP, trade.getPremiumCurrency()); assertEquals(PREMIUM_DATE, trade.getPremiumDate()); assertEquals(TRADE_DATE, trade.getTradeDate()); assertEquals(PREMIUM_TIME, trade.getPremiumTime()); assertEquals(TRADE_TIME, trade.getTradeTime()); assertEquals(ATTRIBUTES, trade.getAttributes()); // can't check the node ID as nodes are completely replaced ManageablePortfolioNode loadedRoot = _portfolioMaster.get(_savedPortfolio.getUniqueId()).getPortfolio() .getRootNode(); ManageablePortfolioNode loadedNode = loadedRoot.getChildNodes().get(0); assertEquals(1, loadedNode.getPositionIds().size()); assertEquals(positionId.getObjectId(), loadedNode.getPositionIds().get(0)); }
From source file:pe.gob.mef.gescon.web.ui.RangoMB.java
public void cleanAttributes() { this.setId(BigDecimal.ZERO); this.setDescripcion(StringUtils.EMPTY); this.setNombre(StringUtils.EMPTY); this.setActivo(BigDecimal.ONE); this.setSelectedRango(null); Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages(); if (iter.hasNext() == true) { iter.remove();/*from w w w .jav a 2s . com*/ FacesContext.getCurrentInstance().renderResponse(); } }
From source file:org.openhab.persistence.dynamodb.internal.AbstractDynamoDBItemSerializationTest.java
@Test public void testOpenClosedTypeWithContactItem() throws IOException { final DynamoDBItem<?> dbitemOpen = testStateGeneric(OpenClosedType.CLOSED, BigDecimal.ZERO); testAsHistoricGeneric(dbitemOpen, new ContactItem("foo"), OpenClosedType.CLOSED); final DynamoDBItem<?> dbitemClosed = testStateGeneric(OpenClosedType.OPEN, BigDecimal.ONE); testAsHistoricGeneric(dbitemClosed, new ContactItem("foo"), OpenClosedType.OPEN); }
From source file:com.splicemachine.derby.impl.sql.execute.operations.InsertOperationIT.java
@Test public void testInsertOverMergeSortOuterJoinIsCorrect() throws Exception { /*/* ww w. j av a2 s . c om*/ * Regression test for DB-1833. Tests that we can insert over a subselect that has a merge-sort * join present,without getting any errors. */ long insertCount = methodWatcher.executeUpdate(String.format("insert into %1$s select " + "%2$s.a,%3$s.c,%2$s.b,%3$s.d " + "from %2$s --SPLICE-PROPERTIES joinStrategy=SORTMERGE \n" + "right join %3$s on %2$s.a=%3$s.c", "T5", "T3", "T4")); Assert.assertEquals("Incorrect number of rows inserted!", 2, insertCount); ResultSet rs = methodWatcher.executeQuery("select * from T5"); int count = 0; while (rs.next()) { int a = rs.getInt(1); if (rs.wasNull()) { BigDecimal b = rs.getBigDecimal(3); Assert.assertTrue("B is not null!", rs.wasNull()); } else { BigDecimal b = rs.getBigDecimal(3); Assert.assertFalse("B is null!", rs.wasNull()); Assert.assertTrue("Incorrect B value!", BigDecimal.ONE.subtract(b).abs().compareTo(new BigDecimal(".0000000001")) < 0); } count++; int c = rs.getInt(2); Assert.assertFalse("C is null!", rs.wasNull()); int d = rs.getInt(4); Assert.assertFalse("D is null!", rs.wasNull()); } Assert.assertEquals("Incorrect row count!", 2, count); }
From source file:pe.gob.mef.gescon.web.ui.PerfilMB.java
public void cleanAttributes() { this.setId(BigDecimal.ZERO); this.setDescripcion(StringUtils.EMPTY); this.setNombre(StringUtils.EMPTY); this.setActivo(BigDecimal.ONE); this.setSelectedPerfil(null); Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages(); if (iter.hasNext() == true) { iter.remove();/*from w ww . ja v a2 s . c om*/ FacesContext.getCurrentInstance().renderResponse(); } }