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 testUpdateBoundedFlagToTrue() {
    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> pair = initEvent(categories, organizationRepository, userManager, eventManager,
            eventRepository);/*from  w ww . j ava 2s  .  c o m*/
    Event event = pair.getLeft();
    String username = pair.getRight();
    assertEquals(new Integer(AVAILABLE_SEATS), ticketRepository.countFreeTicketsForUnbounded(event.getId()));
    TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
    Map<String, String> categoryDescription = ticketCategoryDescriptionRepository
            .descriptionForTicketCategory(category.getId());
    TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(),
            AVAILABLE_SEATS, DateTimeModification.fromZonedDateTime(category.getUtcInception()),
            DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription,
            category.getPrice(), false, "", true, null, null, null, null, null);
    Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username);
    assertTrue(result.isSuccess());
    assertEquals(new Integer(0), ticketRepository.countFreeTicketsForUnbounded(event.getId()));
}

From source file:org.apache.olingo.server.core.serializer.json.EdmAssistedJsonSerializerTest.java

@Test
public void entityCollectionWithComplexPropertyMetadataNone() throws Exception {
    Entity entity = new Entity();
    entity.setId(null);/*ww w  .ja  v a 2 s  .c  om*/
    entity.addProperty(new Property(null, "Property1", ValueType.PRIMITIVE, 1L));
    ComplexValue complexValue = new ComplexValue();
    complexValue.getValue()
            .add(new Property(null, "Inner1", ValueType.PRIMITIVE, BigDecimal.TEN.scaleByPowerOfTen(-5)));
    Calendar time = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    time.clear();
    time.set(Calendar.HOUR_OF_DAY, 13);
    time.set(Calendar.SECOND, 59);
    time.set(Calendar.MILLISECOND, 999);
    complexValue.getValue().add(new Property("Edm.TimeOfDay", "Inner2", ValueType.PRIMITIVE, time));
    entity.addProperty(new Property("Namespace.ComplexType", "Property2", ValueType.COMPLEX, complexValue));
    EntityCollection entityCollection = new EntityCollection();
    entityCollection.getEntities().add(entity);
    Assert.assertEquals(
            "{" + "\"value\":[{" + "\"Property1\":1," + "\"Property2\":{" + "\"Inner1\":0.00010,"
                    + "\"Inner2\":\"13:00:59.999\"}}]}",
            serialize(serializerNone, metadata, null, entityCollection, null));
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testUpdateBoundedFlagToFalse() {
    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 ww  w.ja v a  2 s .c o m
    Event event = pair.getLeft();
    String username = pair.getRight();
    assertEquals(new Integer(0), ticketRepository.countFreeTicketsForUnbounded(event.getId()));

    TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
    Map<String, String> categoryDescription = ticketCategoryDescriptionRepository
            .descriptionForTicketCategory(category.getId());

    TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(),
            AVAILABLE_SEATS, DateTimeModification.fromZonedDateTime(category.getUtcInception()),
            DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription,
            category.getPrice(), false, "", false, null, null, null, null, null);
    Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username);
    assertTrue(result.isSuccess());
    assertEquals(AVAILABLE_SEATS, ticketRepository.countReleasedUnboundedTickets(event.getId()).intValue());
    waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);
    assertEquals(AVAILABLE_SEATS, ticketRepository.countFreeTicketsForUnbounded(event.getId()).intValue());
}

From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java

private List<TicketCategoryModification> getPreSalesTicketCategoryModifications(boolean firstBounded,
        int firstSeats, boolean lastBounded, int lastSeats) {
    LocalDateTime start = LocalDateTime.now().plusMinutes(4);
    return Arrays.asList(
            new TicketCategoryModification(null, "defaultFirst", firstSeats,
                    new DateTimeModification(start.toLocalDate(), start.toLocalTime()),
                    new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), DESCRIPTION,
                    BigDecimal.TEN, false, "", firstBounded, null, null, null, null, null),
            new TicketCategoryModification(null, "defaultLast", lastSeats,
                    new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()),
                    new DateTimeModification(LocalDate.now().plusDays(2), LocalTime.now()), DESCRIPTION,
                    BigDecimal.TEN, false, "", lastBounded, null, null, null, null, null));
}

From source file:com.payu.sdk.util.UtilTest.java

/**
 * Test the signature utility//from  ww  w. j a v  a 2s  .c  om
 */
@Test
public void signUtilTest() {

    PayU.apiKey = "12345";
    PayU.merchantId = "1";

    Order order = new Order();

    Transaction transaction = new Transaction();

    try {

        SignUtil.createSignature(transaction);
        Assert.fail("No exception was thrown");

    } catch (IllegalArgumentException e) {
        LoggerUtil.error(e.getMessage(), e);
    }

    try {

        transaction.setOrder(order);
        SignUtil.createSignature(transaction);
        Assert.fail("No exception was thrown");

    } catch (IllegalArgumentException e) {
        LoggerUtil.error(e.getMessage(), e);
    }

    try {
        order.setReferenceCode("ABC");
        SignUtil.createSignature(transaction);
        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);
        SignUtil.createSignature(transaction);
        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);
        SignUtil.createSignature(transaction);
        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 testValidationBoundedFailedRestrictedFlag() {
    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, true, "", true, null, null, null, null, null));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager,
            eventRepository);//from w  w w .  ja v a2 s .c om

    Event event = pair.getLeft();
    String username = pair.getRight();

    TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
    Map<String, String> categoryDescription = ticketCategoryDescriptionRepository
            .descriptionForTicketCategory(category.getId());

    TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 10,
            DateTimeModification.fromZonedDateTime(category.getUtcInception()),
            DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription,
            category.getPrice(), true, "", false, null, null, null, null, null);
    Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username);
    assertFalse(result.isSuccess());
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testValidationBoundedFailedPendingTickets() {
    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));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager,
            eventRepository);/*w w w .j a va 2 s. c  o  m*/
    Event event = pair.getLeft();
    String username = pair.getRight();

    TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
    Map<String, String> categoryDescription = ticketCategoryDescriptionRepository
            .descriptionForTicketCategory(category.getId());

    List<Integer> tickets = ticketRepository.selectTicketInCategoryForUpdate(event.getId(), category.getId(), 1,
            Collections.singletonList(Ticket.TicketStatus.FREE.name()));
    String reservationId = "12345678";
    ticketReservationRepository.createNewReservation(reservationId, DateUtils.addDays(new Date(), 1), null,
            "en", event.getId(), event.getVat(), event.isVatIncluded());
    ticketRepository.reserveTickets(reservationId, tickets, category.getId(), "en", 100);
    TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 10,
            DateTimeModification.fromZonedDateTime(category.getUtcInception()),
            DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription,
            category.getPrice(), false, "", false, null, null, null, null, null);
    Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username);
    assertFalse(result.isSuccess());
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testIncreaseRestrictedCategory() {
    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, true, "", true, null, null, null, null, null));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager,
            eventRepository);/*w  w  w  .j  a  va 2s.  c o m*/

    Event event = pair.getLeft();
    String username = pair.getRight();

    TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
    Map<String, String> categoryDescription = ticketCategoryDescriptionRepository
            .descriptionForTicketCategory(category.getId());

    TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 11,
            DateTimeModification.fromZonedDateTime(category.getUtcInception()),
            DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription,
            category.getPrice(), true, "", true, null, null, null, null, null);
    Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username);
    assertTrue(result.isSuccess());
    assertEquals(11, ticketRepository.countFreeTickets(event.getId(), category.getId()).intValue());
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testDecreaseRestrictedCategory() {
    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, true, "", true, null, null, null, null, null));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager,
            eventRepository);/*from   w  w w. ja  v  a  2 s .  co m*/

    Event event = pair.getLeft();
    String username = pair.getRight();

    TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
    Map<String, String> categoryDescription = ticketCategoryDescriptionRepository
            .descriptionForTicketCategory(category.getId());

    TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 9,
            DateTimeModification.fromZonedDateTime(category.getUtcInception()),
            DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription,
            category.getPrice(), true, "", true, null, null, null, null, null);
    Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username);
    assertTrue(result.isSuccess());
    assertEquals(9, ticketRepository.countFreeTickets(event.getId(), category.getId()).intValue());
    assertEquals(1, ticketRepository.countReleasedUnboundedTickets(event.getId()).intValue());
}

From source file:jp.furplag.util.commons.NumberUtilsTest.java

/**
 * {@link jp.furplag.util.commons.NumberUtils#floor(java.lang.Object, java.lang.Class)}.
 *//*from  w  w w .  j a  v a 2 s  .c  om*/
@SuppressWarnings("unchecked")
@Test
public void testFloorObjectClassOfT() {
    assertEquals("null", null, floor(null, null));
    assertEquals("null", null, floor("", null));
    assertEquals("null", null, floor("not a number.", null));
    for (Class<?> type : NUMBERS) {
        try {
            Object expected = null;
            Class<? extends Number> typeOfN = (Class<? extends Number>) type;
            Class<? extends Number> wrapper = (Class<? extends Number>) ClassUtils.primitiveToWrapper(type);
            if (ClassUtils.isPrimitiveWrapper(wrapper)) {
                expected = wrapper.getMethod("valueOf", String.class).invoke(null, "3");
            } else {
                Constructor<?> c = type.getDeclaredConstructor(String.class);
                expected = c.newInstance("3");
            }
            assertEquals("PI: String: " + type.getSimpleName(), expected, floor("3.14", typeOfN));
            assertEquals("PI: Float: " + type.getSimpleName(), expected, floor(3.141592653589793f, typeOfN));
            assertEquals("PI: Double: " + type.getSimpleName(), expected, floor(Math.PI, typeOfN));
            assertEquals("PI: BigDecimal: " + type.getSimpleName(), expected,
                    floor(BigDecimal.valueOf(Math.PI), typeOfN));
            assertEquals("(Double) (10 / 3): " + type.getSimpleName(), expected, floor(
                    (Object) (BigDecimal.TEN.divide(new BigDecimal("3"), MathContext.DECIMAL128)), typeOfN));
            if (ObjectUtils.isAny(wrapper, Double.class, Float.class)) {
                expected = wrapper.getField("POSITIVE_INFINITY").get(null);
            } else if (ClassUtils.isPrimitiveWrapper(wrapper)) {
                expected = wrapper.getField("MAX_VALUE").get(null);
                assertEquals("Huge: " + type.getSimpleName(), expected,
                        floor((Object) INFINITY_DOUBLE.pow(10, MathContext.DECIMAL128), typeOfN));
            } else if (BigDecimal.class.equals(type)) {
                expected = INFINITY_DOUBLE.pow(10, MathContext.DECIMAL128).toPlainString();
                Object actual = floor((Object) INFINITY_DOUBLE.pow(10, MathContext.DECIMAL128),
                        BigDecimal.class).toPlainString();
                assertEquals("Huge: " + type.getSimpleName(), expected, actual);
            } else {
                expected = INFINITY_DOUBLE.pow(10, MathContext.DECIMAL128).toBigInteger();
                Object actual = floor((Object) INFINITY_DOUBLE.pow(10, MathContext.DECIMAL128),
                        BigInteger.class);
                assertEquals("Huge: " + type.getSimpleName(), expected, actual);
            }
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage() + "\n" + Arrays.toString(e.getStackTrace()));
        }
    }
}