List of usage examples for java.math BigDecimal TEN
BigDecimal TEN
To view the source code for java.math BigDecimal TEN.
Click Source Link
From source file:alfio.manager.system.DataMigratorIntegrationTest.java
@Test public void testMigration() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); Pair<Event, String> eventUsername = initEvent(categories); Event event = eventUsername.getKey(); try {//from www .j av a 2 s. co m eventRepository.updatePrices("CHF", 40, false, BigDecimal.ONE, "STRIPE", event.getId(), PriceContainer.VatStatus.NOT_INCLUDED, 1000); dataMigrator.migrateEventsToCurrentVersion(); EventMigration eventMigration = eventMigrationRepository.loadEventMigration(event.getId()); assertNotNull(eventMigration); //assertEquals(buildTimestamp, eventMigration.getBuildTimestamp().toString()); assertEquals(currentVersion, eventMigration.getCurrentVersion()); List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId()); assertNotNull(tickets); assertFalse(tickets.isEmpty()); assertEquals(AVAILABLE_SEATS, tickets.size()); assertTrue(tickets.stream().allMatch(t -> t.getCategoryId() == null)); } finally { eventManager.deleteEvent(event.getId(), eventUsername.getValue()); } }
From source file:cz.muni.fi.pa165.legomanager.dao.LegoKitDaoImplTest.java
@Test public void updateLegoKitPriceTest() { LegoKit legoKit1 = createLegoKit("Pokemon Charizard", new BigDecimal(42), 12, new HashSet<Category>(), new ArrayList<LegoPiece>(), new ArrayList<LegoSet>()); legoKitDao.addLegoKit(legoKit1);// w w w .j av a 2 s.c o m legoKit1.setPrice(BigDecimal.TEN); try { legoKitDao.updateLegoKit(legoKit1); LegoKit updated = legoKitDao.findLegoKitById(legoKit1.getId()); assertEquals(updated.getPrice(), BigDecimal.TEN); } catch (Exception ex) { fail("Updating price throws exception " + ex); } }
From source file:alfio.manager.AdminReservationManagerIntegrationTest.java
@Test public void testReserveFromExistingCategoryNotEnoughSeatsBounded() throws Exception { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 1, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null)); performExistingCategoryTest(categories, true, Collections.singletonList(2), false, true, 0, AVAILABLE_SEATS);//from ww w . ja v a 2 s. co m }
From source file:uk.dsxt.voting.client.web.MockVotingApiResource.java
License:asdf
@POST @Path("/vote") @Produces("application/json") public RequestResult vote(@FormParam("cookie") String cookie, @FormParam("votingId") String votingId, @FormParam("votingChoice") String votingChoice) { try {//from w w w . j av a 2 s . c o m log.debug("vote method called. cookie={}; votingId={}; votingChoice={}", cookie, votingId, votingChoice); VotingChoice choice = mapper.readValue(votingChoice, VotingChoice.class); for (String question : choice.getQuestionChoices().keySet()) { log.debug("Question: {}, Answer: {}", question, choice.getQuestionChoices().get(question)); } final AnswerWeb[] answers1 = new AnswerWeb[4]; answers1[0] = new AnswerWeb("1", "answer_1", BigDecimal.TEN); answers1[1] = new AnswerWeb("2", "answer_2", BigDecimal.ONE); answers1[2] = new AnswerWeb("3", "answer_3", BigDecimal.TEN); answers1[3] = new AnswerWeb("4", "answer_4", BigDecimal.ONE); final AnswerWeb[] answers2 = new AnswerWeb[1]; answers2[0] = new AnswerWeb("1", "yes", BigDecimal.TEN); final QuestionWeb[] questions = new QuestionWeb[3]; questions[0] = new QuestionWeb("1", "question_1_multi", answers1, true, 1); questions[1] = new QuestionWeb("2", "question_2_yes_no", answers2, false, 1); questions[2] = new QuestionWeb("3", "question_3_no_vote", new AnswerWeb[0], false, 1); return new RequestResult<>(new VotingInfoWeb(questions, new BigDecimal(22), 57000L), null); } catch (Exception e) { log.error("vote method failed. cookie={}; votingId={}; votingChoice={}", cookie, votingId, votingChoice, e); return new RequestResult<>(APIException.UNKNOWN_EXCEPTION); } }
From source file:org.apache.olingo.fit.proxy.EntityUpdateTestITCase.java
@Test public void concurrentModification() { Order order = getContainer().getOrders().getByKey(8).load(); final String etag = ((EntityInvocationHandler) Proxy.getInvocationHandler(order)).getETag(); assertTrue(StringUtils.isNotBlank(etag)); order.setShelfLife(BigDecimal.TEN); getContainer().flush();// w w w. j a v a 2s .co m order = getContainer().getOrders().getByKey(8).load(); assertEquals(BigDecimal.TEN, order.getShelfLife()); }
From source file:com.payu.sdk.util.UtilTest.java
/** * Test the signature helper utility/* ww w . java 2s. co m*/ */ @Test public void signatureHelperTest() { Order order = new Order(); try { SignatureHelper.buildSignature(order, null, "1", SignatureHelper.DECIMAL_FORMAT_1, SignatureHelper.MD5_ALGORITHM); Assert.fail("No exception was thrown"); } catch (IllegalArgumentException e) { LoggerUtil.error(e.getMessage(), e); } try { SignatureHelper.buildSignature(order, 1, "1", SignatureHelper.DECIMAL_FORMAT_1, SignatureHelper.MD5_ALGORITHM); Assert.fail("No exception was thrown"); } catch (IllegalArgumentException e) { LoggerUtil.error(e.getMessage(), e); } try { order.setReferenceCode("ABC"); SignatureHelper.buildSignature(order, 1, "1", SignatureHelper.DECIMAL_FORMAT_1, SignatureHelper.MD5_ALGORITHM); Assert.fail("No exception was thrown"); } catch (IllegalArgumentException e) { LoggerUtil.error(e.getMessage(), e); } try { order.setAdditionalValues(new HashMap<String, AdditionalValue>()); AdditionalValue additionalValue = new AdditionalValue(); order.getAdditionalValues().put("TX_VALUE", additionalValue); SignatureHelper.buildSignature(order, 1, "1", SignatureHelper.DECIMAL_FORMAT_1, SignatureHelper.MD5_ALGORITHM); Assert.fail("No exception was thrown"); } catch (IllegalArgumentException e) { LoggerUtil.error(e.getMessage(), e); } try { order.setAdditionalValues(new HashMap<String, AdditionalValue>()); AdditionalValue additionalValue = new AdditionalValue(); additionalValue.setCurrency(Currency.COP); order.getAdditionalValues().put("TX_VALUE", additionalValue); SignatureHelper.buildSignature(order, 1, "1", SignatureHelper.DECIMAL_FORMAT_1, SignatureHelper.MD5_ALGORITHM); Assert.fail("No exception was thrown"); } catch (IllegalArgumentException e) { LoggerUtil.error(e.getMessage(), e); } try { order.setAdditionalValues(new HashMap<String, AdditionalValue>()); AdditionalValue additionalValue = new AdditionalValue(); additionalValue.setCurrency(Currency.COP); order.getAdditionalValues().put("TX_VALUE", additionalValue); SignatureHelper.buildSignature(order, 1, "1", SignatureHelper.DECIMAL_FORMAT_1, "OTRO"); Assert.fail("No exception was thrown"); } catch (IllegalArgumentException e) { LoggerUtil.error(e.getMessage(), e); } try { order.setAdditionalValues(new HashMap<String, AdditionalValue>()); AdditionalValue additionalValue = new AdditionalValue(); additionalValue.setCurrency(Currency.COP); additionalValue.setValue(BigDecimal.TEN); order.getAdditionalValues().put("TX_VALUE", additionalValue); SignatureHelper.buildSignature(order, 1, "1", SignatureHelper.DECIMAL_FORMAT_1, "OTRO"); Assert.fail("No exception was thrown"); } catch (IllegalArgumentException e) { LoggerUtil.error(e.getMessage(), e); } order.setAdditionalValues(new HashMap<String, AdditionalValue>()); AdditionalValue additionalValue = new AdditionalValue(); additionalValue.setCurrency(Currency.COP); additionalValue.setValue(BigDecimal.TEN); order.getAdditionalValues().put("TX_VALUE", additionalValue); SignatureHelper.buildSignature(order, 1, "1", SignatureHelper.DECIMAL_FORMAT_1, SignatureHelper.SHA_ALGORITHM); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testEventGenerationWithUnboundedCategory() { List<TicketCategoryModification> categories = Arrays.asList( new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null), new TicketCategoryModification(null, "default", 9, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null), new TicketCategoryModification(null, "default", 0, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository) .getKey();//w w w. j a va 2s. com List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId()); assertNotNull(tickets); assertFalse(tickets.isEmpty()); assertEquals(AVAILABLE_SEATS, tickets.size()); assertEquals(1, tickets.stream().filter(t -> t.getCategoryId() == null).count()); }
From source file:org.fineract.module.stellar.TestPaymentInSimpleNetwork.java
@Test public void overlappingPayments() throws Exception { logger.info("overlappingPayments test begin"); final AccountListener accountListener = new AccountListener(serverAddress, firstTenantId, secondTenantId); final BigDecimal transferAmount = BigDecimal.TEN; final BigDecimal doubleTransferAmount = transferAmount.add(transferAmount); makePayment(firstTenantId, firstTenantApiKey, secondTenantId, ASSET_CODE, transferAmount); makePayment(secondTenantId, secondTenantApiKey, firstTenantId, ASSET_CODE, doubleTransferAmount); accountListener.waitForCredits(PAY_WAIT, creditMatcher(firstTenantId, doubleTransferAmount, ASSET_CODE, secondTenantId), creditMatcher(secondTenantId, transferAmount, ASSET_CODE, vaultMatcher(firstTenantId, secondTenantId)), creditMatcher(secondTenantId, transferAmount, ASSET_CODE, secondTenantId)); checkBalance(firstTenantId, firstTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(secondTenantId), transferAmount);// w w w . j a v a 2 s . c om checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId), BigDecimal.ZERO); //Return balances to zero for next test. makePayment(firstTenantId, firstTenantApiKey, secondTenantId, ASSET_CODE, transferAmount); accountListener.waitForCredits(PAY_WAIT, creditMatcher(secondTenantId, transferAmount, ASSET_CODE, vaultMatcher(firstTenantId, secondTenantId))); }
From source file:alfio.controller.ReservationFlowIntegrationTest.java
@Before public void ensureConfiguration() { IntegrationTestUtil.ensureMinimalConfiguration(configurationRepository); List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now().minusDays(1), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); Pair<Event, String> eventAndUser = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);/*from ww w. j a v a2s .co m*/ event = eventAndUser.getKey(); user = eventAndUser.getValue() + "_owner"; // TemplateManager templateManager = Mockito.mock(TemplateManager.class); reservationApiController = new ReservationApiController(eventRepository, ticketHelper, templateManager, i18nManager, euVatChecker, ticketReservationRepository, ticketReservationManager); }
From source file:alfio.manager.AdminReservationManagerIntegrationTest.java
@Test public void testReserveFromExistingCategoryNotEnoughSeatsNoExtensionAllowedBounded() throws Exception { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null)); performExistingCategoryTest(categories, true, Collections.singletonList(AVAILABLE_SEATS + 1), false, false, 0, AVAILABLE_SEATS);//w w w.j a v a 2 s. c o m }