Example usage for java.math BigDecimal TEN

List of usage examples for java.math BigDecimal TEN

Introduction

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

Prototype

BigDecimal TEN

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

Click Source Link

Document

The value 10, with a scale of 0.

Usage

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

public void testDefaultValue() throws Exception {
    this.rootNode.getSession().refresh(false);
    testDefaultValue(rootNode, "default");

    testDefaultValue(rootNode, (byte) 10);
    testDefaultValue(rootNode, (short) 10);
    testDefaultValue(rootNode, 10);/*from w  ww  .  j  av  a 2  s  .c  o m*/
    testDefaultValue(rootNode, 10l);

    testDefaultValue(rootNode, 10.0f);
    testDefaultValue(rootNode, 10.0d);
    testDefaultValue(rootNode, new BigDecimal("50.50"));

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

    testDefaultValue(rootNode, refCal);
    testDefaultValue(rootNode, refDate);
    testDefaultValue(rootNode, refTime);

    testDefaultValue(rootNode, BigDecimal.TEN);
}

From source file:alfio.manager.AdminReservationManagerIntegrationTest.java

@Test
public void testReserveFromExistingCategoryNotEnoughSeatsNotBounded() 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, "",
            false, null, null, null, null, null));
    performExistingCategoryTest(categories, false, Collections.singletonList(1), false, true, 0,
            AVAILABLE_SEATS);/*from   ww w. j a  v  a 2s.c  o  m*/
}

From source file:computech.controller.CatalogControllerIntegrationTests.java

@Test
public void detailIntegrationTest() throws Exception {
    Model model = new ExtendedModelMap();

    Article article = new Articlebuilder().withname("test").withimage("a1").withmodel("ab")
            .withprice(Money.of(BigDecimal.TEN, Currencies.EURO)).withtype(Article.ArticleType.NOTEBOOK)
            .build();//  w  w w  . j a  v a2 s.  c om
    ProductIdentifier id = article.getId();

    computerCatalog.save(article);
    Iterable<Article> result = computerCatalog.findByType(Article.ArticleType.NOTEBOOK);
    assertThat(result, is(iterableWithSize(3)));

    String returnedView = controller.detail(article, model);
    assertThat(returnedView, is("detail"));

}

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

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

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

    final BigDecimal transferAmount = BigDecimal.TEN;
    makePayment(firstTenantId, firstTenantApiKey, secondTenantId, ASSET_CODE, transferAmount);

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

    checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId),
            transferAmount);/* w  w  w.  java  2s.c o  m*/

    makePayment(secondTenantId, secondTenantApiKey, firstTenantId, ASSET_CODE, transferAmount);

    accountListener.waitForCredits(PAY_WAIT, creditMatcher(firstTenantId, BigDecimal.TEN, ASSET_CODE,
            vaultMatcher(secondTenantId, firstTenantId)));

    checkBalance(firstTenantId, firstTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(secondTenantId),
            BigDecimal.ZERO);

    checkBalance(firstTenantId, firstTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId),
            VAULT_BALANCE);

    checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId),
            BigDecimal.ZERO);

    checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(secondTenantId),
            VAULT_BALANCE);
}

From source file:alfio.manager.system.DataMigratorIntegrationTest.java

private Pair<Event, String> initEvent(List<TicketCategoryModification> categories, String displayName) {
    String organizationName = UUID.randomUUID().toString();
    String username = UUID.randomUUID().toString();
    String eventName = UUID.randomUUID().toString();

    organizationRepository.create(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);

    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", null,
            null, eventName, displayName, organization.getId(), "muh location", "0.0", "0.0",
            ZoneId.systemDefault().getId(), desc,
            new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()),
            new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now().plusHours(1)), BigDecimal.TEN,
            "CHF", AVAILABLE_SEATS, BigDecimal.ONE, true, null, categories, false,
            new LocationDescriptor("", "", "", ""), 7, null, null);
    eventManager.createEvent(em);/*from   w  w  w  .j a va2  s . co m*/
    return Pair.of(eventManager.getSingleEvent(eventName, username), username);
}

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

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

    final AccountListener accountListener = new AccountListener(serverAddress, firstTenantId, secondTenantId,
            thirdTenantId);//from  www  .  j ava 2 s.  c  om

    final BigDecimal transferAmount = BigDecimal.TEN;
    makePayment(firstTenantId, firstTenantApiKey, secondTenantId, ASSET_CODE, transferAmount);
    makePayment(secondTenantId, secondTenantApiKey, thirdTenantId, ASSET_CODE, transferAmount);

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

    checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId),
            transferAmount);
    checkBalance(thirdTenantId, thirdTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(secondTenantId),
            transferAmount);

    makePayment(thirdTenantId, thirdTenantApiKey, firstTenantId, ASSET_CODE, transferAmount);

    accountListener.waitForCredits(MAX_PAY_WAIT * 5,
            creditMatcher(firstTenantId, transferAmount, ASSET_CODE, secondTenantId),
            creditMatcher(firstTenantId, transferAmount, ASSET_CODE, firstTenantId),
            creditMatcher(secondTenantId, transferAmount, ASSET_CODE, secondTenantId));

    checkBalance(firstTenantId, firstTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(secondTenantId),
            BigDecimal.ZERO);
    checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId),
            BigDecimal.ZERO);
    checkBalance(thirdTenantId, thirdTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId),
            BigDecimal.ZERO);
    checkBalance(thirdTenantId, thirdTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(secondTenantId),
            BigDecimal.ZERO);
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testUnboundedEventGeneration() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null,
            "default", 10, 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();//from  w  w  w  .  j  av a  2  s . co  m
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertNotNull(tickets);
    assertFalse(tickets.isEmpty());
    assertEquals(AVAILABLE_SEATS, tickets.size());
    assertEquals(AVAILABLE_SEATS, tickets.stream().filter(t -> t.getCategoryId() == null).count());
    List<TicketCategory> ticketCategories = ticketCategoryRepository.findByEventId(event.getId());
    assertEquals(1, ticketCategories.size());
    assertEquals(0, ticketCategories.get(0).getMaxTickets());
}

From source file:alfio.manager.AdminReservationManagerIntegrationTest.java

@Test
public void testReserveExistingCategoryNotEnoughSeatsNotBoundedSoldOut() 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, "",
            false, null, null, null, null, null));
    performExistingCategoryTest(categories, false, Collections.singletonList(1), true, true, AVAILABLE_SEATS,
            AVAILABLE_SEATS + 1);//from  w  w w  .  j ava 2  s  .com
}

From source file:computech.controller.CatalogControllerIntegrationTests.java

@Test
public void changetest() throws Exception {
    ModelMap model = new ExtendedModelMap();
    Part part = new PartBuilder().withname("test1").withimage("t1").withmodel("t1")
            .withprice(Money.of(BigDecimal.TEN, Currencies.EURO)).withtype(Part.PartType.PROCESSOR).build();
    partscatalog.save(part);/*w  ww  .  j ava  2 s  .  co  m*/
    Computer all = new Computerbuilder().withname("test2").withimage("t2").withmodel("t2")
            .withprice(Money.of(BigDecimal.TEN, Currencies.EURO)).withtype(Computer.Computertype.COMPUTER)
            .build();
    allinoneCatalog.save(all);
    InventoryItem i = new InventoryItem(part, Quantity.of(10));
    InventoryItem b = new InventoryItem(part, Quantity.of(10));
    inventory.save(i);
    inventory.save(b);
    String returnedView = controller.changeprocessor(part, all, model);
    assertThat(returnedView, is("compudetail"));
}

From source file:alfio.manager.TicketReservationManagerIntegrationTest.java

@Test
public void testTicketSelection() {
    List<TicketCategoryModification> categories = Arrays.asList(
            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),
            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));
    Pair<Event, String> eventAndUsername = initEvent(categories, organizationRepository, userManager,
            eventManager, eventRepository);
    Event event = eventAndUsername.getKey();

    TicketCategory bounded = ticketCategoryRepository.findByEventId(event.getId()).stream()
            .filter(TicketCategory::isBounded).findFirst().orElseThrow(IllegalStateException::new);
    TicketCategory unbounded = ticketCategoryRepository.findByEventId(event.getId()).stream()
            .filter(t -> !t.isBounded()).findFirst().orElseThrow(IllegalStateException::new);

    assertEquals(0, eventStatisticsManager.loadModifiedTickets(event.getId(), bounded.getId(), 0, null).size());
    assertEquals(Integer.valueOf(0),
            eventStatisticsManager.countModifiedTicket(event.getId(), bounded.getId(), null));
    assertEquals(0,//from w  ww .  j av  a2  s . com
            eventStatisticsManager.loadModifiedTickets(event.getId(), unbounded.getId(), 0, null).size());

    TicketReservationModification tr = new TicketReservationModification();
    tr.setAmount(10);
    tr.setTicketCategoryId(bounded.getId());

    TicketReservationModification tr2 = new TicketReservationModification();
    tr2.setAmount(9);
    tr2.setTicketCategoryId(unbounded.getId());

    TicketReservationWithOptionalCodeModification mod = new TicketReservationWithOptionalCodeModification(tr,
            Optional.empty());
    TicketReservationWithOptionalCodeModification mod2 = new TicketReservationWithOptionalCodeModification(tr2,
            Optional.empty());
    String reservationId = ticketReservationManager.createTicketReservation(event, Arrays.asList(mod, mod2),
            Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(),
            Locale.ENGLISH, false);

    List<TicketReservation> reservations = ticketReservationManager
            .findAllReservationsInEvent(event.getId(), 0, null, null).getKey();
    assertTrue(reservations.size() == 1);
    assertEquals(reservationId, reservations.get(0).getId());

    List<Ticket> pendingTickets = ticketRepository
            .findPendingTicketsInCategories(Arrays.asList(bounded.getId(), unbounded.getId()));
    assertEquals(19, pendingTickets.size());
    pendingTickets.forEach(t -> assertEquals(1000, t.getFinalPriceCts()));
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertEquals(1, tickets.size());
    assertTrue(tickets.stream().allMatch(t -> t.getCategoryId() == null));

    TotalPrice totalPrice = ticketReservationManager.totalReservationCostWithVAT(reservationId);

    assertEquals(0, ticketReservationManager.getPendingPayments(event).size());

    PaymentResult confirm = ticketReservationManager.confirm(null, null, event, reservationId,
            "email@example.com", new CustomerName("full name", "full", "name", event), Locale.ENGLISH,
            "billing address", totalPrice, Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null,
            null, null);

    assertTrue(confirm.isSuccessful());

    assertEquals(TicketReservation.TicketReservationStatus.OFFLINE_PAYMENT,
            ticketReservationManager.findById(reservationId).get().getStatus());

    assertEquals(1, ticketReservationManager.getPendingPayments(event).size());

    Date now = new Date();
    Date from = DateUtils.addDays(now, -1);
    Date to = DateUtils.addDays(now, 1);

    assertTrue(ticketReservationRepository.getSoldStatistic(event.getId(), from, to).isEmpty()); // -> no reservations
    ticketReservationManager.validateAndConfirmOfflinePayment(reservationId, event, new BigDecimal("190.00"),
            eventAndUsername.getValue());

    assertEquals(19,
            ticketReservationRepository.getSoldStatistic(event.getId(), from, to).get(0).getTicketSoldCount()); // -> 19 tickets reserved

    assertEquals(10,
            eventStatisticsManager.loadModifiedTickets(event.getId(), bounded.getId(), 0, null).size());
    assertEquals(Integer.valueOf(10),
            eventStatisticsManager.countModifiedTicket(event.getId(), bounded.getId(), null));
    assertEquals(9,
            eventStatisticsManager.loadModifiedTickets(event.getId(), unbounded.getId(), 0, null).size());
    assertEquals(Integer.valueOf(9),
            eventStatisticsManager.countModifiedTicket(event.getId(), unbounded.getId(), null));

    assertEquals(TicketReservation.TicketReservationStatus.COMPLETE,
            ticketReservationManager.findById(reservationId).get().getStatus());

    //-------------------

    TicketReservationModification trForDelete = new TicketReservationModification();
    trForDelete.setAmount(1);
    trForDelete.setTicketCategoryId(unbounded.getId());
    TicketReservationWithOptionalCodeModification modForDelete = new TicketReservationWithOptionalCodeModification(
            trForDelete, Optional.empty());
    String reservationId2 = ticketReservationManager.createTicketReservation(event,
            Collections.singletonList(modForDelete), Collections.emptyList(), DateUtils.addDays(new Date(), 1),
            Optional.empty(), Optional.empty(), Locale.ENGLISH, false);

    ticketReservationManager.confirm(null, null, event, reservationId2, "email@example.com",
            new CustomerName("full name", "full", "name", event), Locale.ENGLISH, "billing address", totalPrice,
            Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null, null, null);

    assertTrue(ticketReservationManager.findById(reservationId2).isPresent());

    ticketReservationManager.deleteOfflinePayment(event, reservationId2, false);

    Assert.assertFalse(ticketReservationManager.findById(reservationId2).isPresent());
}