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.system.DataMigratorIntegrationTest.java

@Test
public void testUpdateDisplayName() {
    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, null);
    Event event = eventUsername.getKey();

    try {//from ww w  .  j a v a  2s .co m
        dataMigrator.migrateEventsToCurrentVersion();
        EventMigration eventMigration = eventMigrationRepository.loadEventMigration(event.getId());
        assertNotNull(eventMigration);
        //assertEquals(buildTimestamp, eventMigration.getBuildTimestamp().toString());
        assertEquals(currentVersion, eventMigration.getCurrentVersion());

        Event withDescription = eventRepository.findById(event.getId());
        assertNotNull(withDescription.getDisplayName());
        assertEquals(event.getShortName(), withDescription.getShortName());
        assertEquals(event.getShortName(), withDescription.getDisplayName());
    } finally {
        eventManager.deleteEvent(event.getId(), eventUsername.getValue());
    }
}

From source file:org.apache.olingo.fit.proxy.v4.APIBasicDesignTestITCase.java

@Test
public void createDelete() {
    // Create order ....
    final Order order = getContainer().newEntityInstance(Order.class);
    order.setOrderID(1105);/*w w  w  .  ja v  a2  s .  c  o  m*/

    final Calendar orderDate = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    orderDate.clear();
    orderDate.set(2011, 3, 4, 16, 3, 57);
    order.setOrderDate(new Timestamp(orderDate.getTimeInMillis()));

    order.setShelfLife(BigDecimal.ZERO);

    final PrimitiveCollection<BigDecimal> osl = getContainer().newPrimitiveCollection(BigDecimal.class);
    osl.add(BigDecimal.TEN.negate());
    osl.add(BigDecimal.TEN);

    order.setOrderShelfLifes(osl);

    getContainer().getOrders().add(order);
    getContainer().flush();

    Order actual = getContainer().getOrders().getByKey(1105);
    assertNull(actual.getOrderID());

    actual.load();
    assertEquals(1105, actual.getOrderID(), 0);
    assertEquals(orderDate.getTimeInMillis(), actual.getOrderDate().getTime());
    assertEquals(BigDecimal.ZERO, actual.getShelfLife());
    assertEquals(2, actual.getOrderShelfLifes().size());

    service.getContext().detachAll();

    // (1) Delete by key (see EntityCreateTestITCase)
    getContainer().getOrders().delete(1105);
    assertNull(getContainer().getOrders().getByKey(1105));

    service.getContext().detachAll(); // detach to show the second delete case

    // (2) Delete by object (see EntityCreateTestITCase)
    getContainer().getOrders().delete(getContainer().getOrders().getByKey(1105));
    assertNull(getContainer().getOrders().getByKey(1105));

    // (3) Delete by invoking delete method on the object itself
    service.getContext().detachAll(); // detach to show the third delete case
    getContainer().getOrders().getByKey(1105).delete();
    assertNull(getContainer().getOrders().getByKey(1105));

    getContainer().flush();

    service.getContext().detachAll();
    try {
        getContainer().getOrders().getByKey(1105).load();
        fail();
    } catch (IllegalArgumentException e) {
    }
    service.getContext().detachAll(); // avoid influences
}

From source file:org.marketcetera.saclient.SAClientWSTest.java

@Test
public void getProperties() throws Exception {
    final ModuleURN input = new ModuleURN("test:prov:me:A");
    final Map<String, Object> m = new HashMap<String, Object>();
    m.put("first", BigDecimal.TEN);
    m.put("second", "next");
    m.put("third", 909);
    //Test a non-empty and an empty map.
    List<Map<String, Object>> maps = Arrays.asList(m, new HashMap<String, Object>());
    for (Map<String, Object> map : maps) {
        final Map<String, Object> output = map;
        testAPI(new WSTester<Map<String, Object>>() {
            @Override//from  w  w w  .ja v a2  s  .  com
            protected Map<String, Object> invokeApi(boolean isNullParams) throws Exception {
                return getClient().getProperties(isNullParams ? null : input);
            }

            @Override
            protected Map<String, Object> setReturnValue(boolean isNullParams) {
                getMockSAService()
                        .setPropertiesOut(isNullParams ? null : new MapWrapper<String, Object>(output));
                return isNullParams ? null : output;
            }

            @Override
            protected void verifyInputParams(boolean isNullParams) throws Exception {
                verifyEquals(isNullParams ? null : input, getMockSAService().getURN());
            }
        });
        resetServiceParameters();
    }
}

From source file:alfio.manager.AdminReservationManagerIntegrationTest.java

@Test
public void testReserveMixed() 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));
    Pair<Event, String> eventWithUsername = initEvent(categories, organizationRepository, userManager,
            eventManager, eventRepository);
    Event event = eventWithUsername.getKey();
    String username = eventWithUsername.getValue();
    DateTimeModification expiration = DateTimeModification.fromZonedDateTime(ZonedDateTime.now().plusDays(1));
    CustomerData customerData = new CustomerData("Integration", "Test", "integration-test@test.ch",
            "Billing Address", "en");

    TicketCategory existingCategory = ticketCategoryRepository.findByEventId(event.getId()).get(0);

    Category resExistingCategory = new Category(existingCategory.getId(), "", existingCategory.getPrice());
    Category resNewCategory = new Category(null, "name", new BigDecimal("100.00"));
    int attendees = 1;
    List<TicketsInfo> ticketsInfoList = Arrays.asList(
            new TicketsInfo(resExistingCategory, generateAttendees(attendees), false, false),
            new TicketsInfo(resNewCategory, generateAttendees(attendees), false, false),
            new TicketsInfo(resExistingCategory, generateAttendees(attendees), false, false));
    AdminReservationModification modification = new AdminReservationModification(expiration, customerData,
            ticketsInfoList, "en", false, null);
    Result<Pair<TicketReservation, List<Ticket>>> result = adminReservationManager
            .createReservation(modification, event.getShortName(), username);
    assertTrue(result.isSuccess());/*from   w  w  w .j a  v  a2s  .  c om*/
    Pair<TicketReservation, List<Ticket>> data = result.getData();
    List<Ticket> tickets = data.getRight();
    assertTrue(tickets.size() == 3);
    assertNotNull(data.getLeft());
    assertTrue(tickets.stream().allMatch(t -> t.getTicketsReservationId().equals(data.getKey().getId())));
    int resExistingCategoryId = tickets.get(0).getCategoryId();
    int resNewCategoryId = tickets.get(2).getCategoryId();

    Event modified = eventManager.getSingleEvent(event.getShortName(), username);
    assertEquals(AVAILABLE_SEATS, eventRepository.countExistingTickets(event.getId()).intValue());
    assertEquals(3, ticketRepository
            .findPendingTicketsInCategories(Arrays.asList(resExistingCategoryId, resNewCategoryId)).size());
    assertEquals(3, ticketRepository.findTicketsInReservation(data.getLeft().getId()).size());

    String reservationId = data.getLeft().getId();
    assertEquals(ticketRepository.findTicketsInReservation(reservationId).stream().findFirst().get().getId(),
            ticketRepository.findFirstTicketInReservation(reservationId).get().getId());

    ticketCategoryRepository.findByEventId(event.getId())
            .forEach(tc -> assertTrue(specialPriceRepository.findAllByCategoryId(tc.getId()).stream()
                    .allMatch(sp -> sp.getStatus() == SpecialPrice.Status.PENDING)));
    adminReservationManager.confirmReservation(event.getShortName(), data.getLeft().getId(), username);
    ticketCategoryRepository.findByEventId(event.getId())
            .forEach(tc -> assertTrue(specialPriceRepository.findAllByCategoryId(tc.getId()).stream()
                    .allMatch(sp -> sp.getStatus() == SpecialPrice.Status.TAKEN)));
    assertFalse(ticketRepository.findAllReservationsConfirmedButNotAssigned(event.getId())
            .contains(data.getLeft().getId()));
}

From source file:uk.dsxt.voting.client.web.MockVotingApiResource.java

License:asdf

@POST
@Path("/getAllClientVotes")
@Produces("application/json")
public RequestResult getAllClientVotes(@FormParam("cookie") String cookie,
        @FormParam("votingId") String votingId) {
    final VoteResultWeb[] results = new VoteResultWeb[10];

    results[0] = new VoteResultWeb(votingId, "Voting Name 2016", "client_1", "Dr. Watson", BigDecimal.TEN,
            VoteResultStatus.OK, "message_1");
    results[1] = new VoteResultWeb(votingId, "Voting Name 2016", "client_2", "Mr. Drow", BigDecimal.ONE,
            VoteResultStatus.OK, "message_2");
    results[2] = new VoteResultWeb(votingId, "Voting Name 2016", "client_3", "Mrs. Smith", BigDecimal.ZERO,
            VoteResultStatus.SignatureFailed, "message_3");
    results[3] = new VoteResultWeb(votingId, "Voting Name 2016", "client_4", "Mr. Zuba", BigDecimal.ZERO,
            VoteResultStatus.OK, "message_4");
    results[4] = new VoteResultWeb(votingId, "Voting Name 2016", "client_5", "Mr. Lenin",
            new BigDecimal(24324234), VoteResultStatus.SignatureFailed, "message_5");
    results[5] = new VoteResultWeb(votingId, "Voting Name 2016", "client_6", "Mr. Kak", BigDecimal.ONE,
            VoteResultStatus.OK, "message_6");
    results[6] = new VoteResultWeb(votingId, "Voting Name 2016", "client_7", "Mrs. Drow", BigDecimal.ZERO,
            VoteResultStatus.SignatureFailed, "message_7");
    results[7] = new VoteResultWeb(votingId, "Voting Name 2016", "client_8", "Mr. Smith", BigDecimal.ZERO,
            VoteResultStatus.OK, "message_8");
    results[8] = new VoteResultWeb(votingId, "Voting Name 2016", "client_9", "Mr. Stalin",
            new BigDecimal(6435674), VoteResultStatus.SignatureFailed, "message_9");
    results[9] = new VoteResultWeb(votingId, "Voting Name 2016", "client_10", "Mr. Kalinin",
            new BigDecimal(5632626), VoteResultStatus.OK, "message_10");

    return new RequestResult<>(results, null);
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testAddUnboundedCategoryShrinkBoundedCategory() {
    //create the event with a single category which contains all the tickets
    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));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager,
            eventRepository);//from  www .  java  2  s  .  co m
    Event event = pair.getKey();
    //shrink the original category to AVAILABLE_SEATS - 2, this would free two seats
    int categoryId = ticketCategoryRepository.findAllTicketCategories(event.getId()).get(0).getId();
    TicketCategoryModification shrink = new TicketCategoryModification(categoryId, "default",
            AVAILABLE_SEATS - 2, new DateTimeModification(LocalDate.now(), LocalTime.now()),
            new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "",
            true, null, null, null, null, null);
    eventManager.updateCategory(categoryId, event.getId(), shrink, pair.getRight());

    //now insert an unbounded ticket category
    TicketCategoryModification tcm = 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);
    eventManager.insertCategory(event.getId(), tcm, pair.getValue());

    waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertNotNull(tickets);
    assertFalse(tickets.isEmpty());
    assertEquals(AVAILABLE_SEATS, tickets.size());
    assertEquals(18,
            tickets.stream().filter(t -> t.getCategoryId() != null && t.getCategoryId() == categoryId).count());
    assertEquals(2, tickets.stream().filter(t -> t.getCategoryId() == null).count());
}

From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java

@Test
public void testAssignTicketToWaitingQueueUnboundedCategory() {
    LocalDateTime start = LocalDateTime.now().minusMinutes(1);
    LocalDateTime end = LocalDateTime.now().plusMinutes(20);
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null,
            "default", AVAILABLE_SEATS, new DateTimeModification(start.toLocalDate(), start.toLocalTime()),
            new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, false,
            "", false, null, null, null, null, null));

    configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true");

    Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository)
            .getKey();/*from  w  ww .  jav a2  s  . c o  m*/

    TicketCategory unbounded = ticketCategoryRepository.findByEventId(event.getId()).get(0);

    TicketReservationModification tr = new TicketReservationModification();
    tr.setAmount(AVAILABLE_SEATS - 1);
    tr.setTicketCategoryId(unbounded.getId());

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

    TicketReservationWithOptionalCodeModification multi = new TicketReservationWithOptionalCodeModification(tr,
            Optional.empty());
    TicketReservationWithOptionalCodeModification single = new TicketReservationWithOptionalCodeModification(
            tr2, Optional.empty());

    String reservationId = ticketReservationManager.createTicketReservation(event,
            Collections.singletonList(multi), Collections.emptyList(), DateUtils.addDays(new Date(), 1),
            Optional.empty(), Optional.empty(), Locale.ENGLISH, false);
    TotalPrice reservationCost = ticketReservationManager.totalReservationCostWithVAT(reservationId);
    PaymentResult result = ticketReservationManager.confirm("", null, event, reservationId, "test@test.ch",
            new CustomerName("Full Name", "Full", "Name", event), Locale.ENGLISH, "", reservationCost,
            Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null, null, null);
    assertTrue(result.isSuccessful());

    String reservationIdSingle = ticketReservationManager.createTicketReservation(event,
            Collections.singletonList(single), Collections.emptyList(), DateUtils.addDays(new Date(), 1),
            Optional.empty(), Optional.empty(), Locale.ENGLISH, false);
    TotalPrice reservationCostSingle = ticketReservationManager
            .totalReservationCostWithVAT(reservationIdSingle);
    PaymentResult resultSingle = ticketReservationManager.confirm("", null, event, reservationIdSingle,
            "test@test.ch", new CustomerName("Full Name", "Full", "Name", event), Locale.ENGLISH, "",
            reservationCostSingle, Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null, null,
            null);
    assertTrue(resultSingle.isSuccessful());

    assertEquals(0, eventRepository.findStatisticsFor(event.getId()).getDynamicAllocation());

    assertTrue(
            waitingQueueManager.subscribe(event, customerJohnDoe(event), "john@doe.com", null, Locale.ENGLISH));

    ticketReservationManager.deleteOfflinePayment(event, reservationIdSingle, false);

    List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager
            .distributeSeats(event).collect(Collectors.toList());
    assertEquals(1, subscriptions.size());
    Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime> subscriptionDetail = subscriptions
            .get(0);
    assertEquals("john@doe.com", subscriptionDetail.getLeft().getEmailAddress());
    TicketReservationWithOptionalCodeModification reservation = subscriptionDetail.getMiddle();
    assertEquals(Integer.valueOf(unbounded.getId()), reservation.getTicketCategoryId());
    assertEquals(Integer.valueOf(1), reservation.getAmount());
    assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now()));
}

From source file:com.ning.billing.analytics.dao.TestAnalyticsDao.java

@Test(groups = "slow")
public void testCreateSaveAndRetrieveAccounts() {
    // Create and retrieve an account
    businessAccountDao.createAccount(account);
    final BusinessAccount foundAccount = businessAccountDao.getAccount(ACCOUNT_KEY);
    Assert.assertNotNull(foundAccount.getCreatedDt());
    Assert.assertEquals(foundAccount.getCreatedDt(), foundAccount.getUpdatedDt());
    // Verify the joiner stuff
    Assert.assertEquals(foundAccount.getTags().size(), 2);
    Assert.assertEquals(foundAccount.getTags().get(0), "batch1");
    Assert.assertEquals(foundAccount.getTags().get(1), "great,guy");
    // Verify the dates by backfilling them
    account.setCreatedDt(foundAccount.getCreatedDt());
    account.setUpdatedDt(foundAccount.getUpdatedDt());
    Assert.assertEquals(foundAccount, account);

    // Try to update the account
    final DateTime previousUpdatedDt = account.getUpdatedDt();
    account.setBalance(BigDecimal.TEN);
    account.setPaymentMethod("PayPal");
    businessAccountDao.saveAccount(account);
    // Verify the save worked as expected
    account = businessAccountDao.getAccount(ACCOUNT_KEY);
    Assert.assertEquals(Rounder.round(BigDecimal.TEN), account.getRoundedBalance());
    Assert.assertEquals("PayPal", account.getPaymentMethod());
    Assert.assertTrue(account.getUpdatedDt().compareTo(previousUpdatedDt) > 0);

    // Account not found
    Assert.assertNull(businessAccountDao.getAccount("Doesn't exist"));
}

From source file:org.openinfobutton.responder.service.impl.ResponderServiceImplMockitoTest.java

private Collection<Asset> getTestAssets() {

    Collection<Asset> assets = new ArrayList<>();

    Asset a1 = new Asset();
    a1.setAssetId(BigDecimal.ONE);
    a1.setDisplayName("a1");

    Asset a10 = new Asset();
    a10.setAssetId(BigDecimal.TEN);
    a10.setDisplayName("a10");

    assets.add(a1);//from   ww w.j a  va 2 s  .  com
    assets.add(a10);

    return assets;

}

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

@Test
public void testUpdateTicketReservation() {
    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   w ww  .  java  2  s .co  m
        TicketReservationModification trm = new TicketReservationModification();
        trm.setAmount(1);
        trm.setTicketCategoryId(eventManager.loadTicketCategories(event).get(0).getId());
        TicketReservationWithOptionalCodeModification r = new TicketReservationWithOptionalCodeModification(trm,
                Optional.empty());
        Date expiration = DateUtils.addDays(new Date(), 1);
        String reservationId = ticketReservationManager.createTicketReservation(event,
                Collections.singletonList(r), Collections.emptyList(), expiration, Optional.empty(),
                Optional.empty(), Locale.ENGLISH, false);
        dataMigrator.fillReservationsLanguage();
        TicketReservation ticketReservation = ticketReservationManager.findById(reservationId).get();
        assertEquals("en", ticketReservation.getUserLanguage());
    } finally {
        eventManager.deleteEvent(event.getId(), eventUsername.getValue());
    }
}