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:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testUnboundedTicketsGeneration() {
    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));
    Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository)
            .getKey();/*from w  w w  .j a  va  2 s  .  c o m*/
    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));
}

From source file:alfio.manager.TicketReservationManagerIntegrationTest.java

@Test
public void testPriceIsOverridden() {
    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));
    Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository)
            .getKey();/*from w w  w .  j a  v  a  2s.co  m*/

    TicketReservationModification tr = new TicketReservationModification();
    tr.setAmount(2);
    TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
    tr.setTicketCategoryId(category.getId());
    TicketReservationWithOptionalCodeModification mod = new TicketReservationWithOptionalCodeModification(tr,
            Optional.empty());
    ticketReservationManager.createTicketReservation(event, Collections.singletonList(mod),
            Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(),
            Locale.ENGLISH, false);
    List<Ticket> pendingTickets = ticketRepository
            .findPendingTicketsInCategories(Collections.singletonList(category.getId()));
    assertEquals(2, pendingTickets.size());
    pendingTickets.forEach(t -> assertEquals(1000, t.getFinalPriceCts()));
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertEquals(18, tickets.size());
    assertTrue(tickets.stream().allMatch(t -> t.getCategoryId() == null));
}

From source file:nl.strohalm.cyclos.utils.conversion.NumberConverter.java

private BigDecimal getDelta() {
    if (delta == null) {
        final int precision = numberFormat.getMaximumFractionDigits();
        delta = BigDecimal.ONE.divide(BigDecimal.TEN.pow(precision), precision, RoundingMode.HALF_UP).negate();
    }//from   w w  w. j av a 2s . c  o m
    return delta;
}

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

@Test
public void createTrustLineHappyCase() {
    final String secondTenantId = UUID.randomUUID().toString();
    final String secondTenantApiKey = createAndDestroyBridge(secondTenantId, testCleanup,
            testRig.getMifosAddress());//from  w  w w  .  j av a 2s. c  om
    setVaultSize(secondTenantId, secondTenantApiKey, ASSET_CODE, BigDecimal.TEN);

    final String secondTenantStellarAddress = tenantVaultStellarAddress(secondTenantId);

    createAndDestroyTrustLine(firstTenantId, firstTenantApiKey, secondTenantStellarAddress, ASSET_CODE,
            BigDecimal.valueOf(1000), testCleanup);
}

From source file:alfio.manager.AdminReservationManagerIntegrationTest.java

@Test
public void testReserveFromExistingMultipleCategories() throws Exception {
    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, "", false, null, null, null, null, null),
            new TicketCategoryModification(null, "2nd", 10,
                    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, Arrays.asList(10, 10), false, true, 0, AVAILABLE_SEATS);
}

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  ava 2s. c om
    Event event = eventManager.getSingleEvent(eventName, username);
    Assert.assertEquals(AVAILABLE_SEATS, eventRepository.countExistingTickets(event.getId()).intValue());
    return Pair.of(event, username);
}

From source file:alfio.manager.WaitingQueueProcessorIntegrationTest.java

@Test
public void testPreRegistration() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null,
            "default", 10, new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()),
            new DateTimeModification(LocalDate.now().plusDays(2), LocalTime.now()), DESCRIPTION, BigDecimal.TEN,
            false, "", false, null, null, null, null, null));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager,
            eventRepository);//from  w  w w. j  av  a2  s .c  o m
    Event event = pair.getKey();
    waitingQueueManager.subscribe(event, new CustomerName("Giuseppe Garibaldi", "Giuseppe", "Garibaldi", event),
            "peppino@garibaldi.com", null, Locale.ENGLISH);
    waitingQueueManager.subscribe(event, new CustomerName("Nino Bixio", "Nino", "Bixio", event),
            "bixio@mille.org", null, Locale.ITALIAN);
    assertTrue(waitingQueueRepository.countWaitingPeople(event.getId()) == 2);

    waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);
    assertEquals(18, ticketRepository.findFreeByEventId(event.getId()).size());

    TicketCategoryModification tcm = new TicketCategoryModification(null, "default", 10,
            new DateTimeModification(LocalDate.now().minusDays(1), LocalTime.now()),
            new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()), DESCRIPTION, BigDecimal.TEN,
            false, "", true, null, null, null, null, null);
    eventManager.insertCategory(event.getId(), tcm, pair.getValue());

    waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);

    List<WaitingQueueSubscription> subscriptions = waitingQueueRepository.loadAll(event.getId());
    assertEquals(2, subscriptions.stream().filter(w -> StringUtils.isNotBlank(w.getReservationId())).count());
    assertTrue(subscriptions.stream()
            .allMatch(w -> w.getStatus().equals(WaitingQueueSubscription.Status.PENDING)));
    assertTrue(subscriptions.stream()
            .allMatch(w -> w.getSubscriptionType().equals(WaitingQueueSubscription.Type.PRE_SALES)));

}

From source file:org.onehippo.repository.mock.MockSessionTest.java

@Test
public void valueFactoryCanCreateValues() throws RepositoryException {
    MockSession session = new MockSession(MockNode.root());
    MockValueFactory factory = session.getValueFactory();

    assertEquals("foo", factory.createValue("foo").getString());
    assertEquals(true, factory.createValue(true).getBoolean());
    assertEquals(42, factory.createValue(42).getLong());
    assertEquals(3.14, factory.createValue(3.14).getDouble(), 0);
    assertEquals(BigDecimal.TEN, factory.createValue(BigDecimal.TEN).getDecimal());

    final Calendar now = Calendar.getInstance();
    assertEquals(now.getTime(), factory.createValue(now).getDate().getTime());
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testEventGeneration() {
    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, "",
            true, null, null, null, null, null));
    Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository)
            .getKey();/* w  ww  .  j  av a  2s .c o m*/
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertNotNull(tickets);
    assertFalse(tickets.isEmpty());
    assertEquals(AVAILABLE_SEATS, tickets.size());
    assertEquals(10, tickets.stream().filter(t -> t.getCategoryId() == null).count());
}

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

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

    final AccountListener accountListener = new AccountListener(serverAddress, thirdTenantId);

    makePayment(firstTenantId, firstTenantApiKey, thirdTenantId, ASSET_CODE, BigDecimal.TEN);

    accountListener.waitForCredits(MAX_PAY_WAIT,
            creditMatcher(secondTenantId, BigDecimal.TEN, ASSET_CODE, thirdTenantId));

    checkBalance(thirdTenantId, thirdTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId),
            BigDecimal.ZERO);//from w  w w . jav  a 2 s  .  com
}