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 testDecreaseRestrictedCategoryWithAlreadySentToken() {

    ensureMinimalConfiguration(configurationRepository);

    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null,
            "default", 4, 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 . jav 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());

    specialPriceTokenGenerator.generatePendingCodesForCategory(category.getId());

    List<SendCodeModification> linked = specialPriceManager.linkAssigneeToCode(
            Arrays.asList(new SendCodeModification(null, "test1", "test@test.com", "it"),
                    new SendCodeModification(null, "test2", "test@test.com", "it")),
            event.getShortName(), category.getId(), username);

    specialPriceManager.sendCodeToAssignee(linked, event.getShortName(), category.getId(), username);

    TicketCategoryModification tcmOk = new TicketCategoryModification(category.getId(), category.getName(), 2,
            DateTimeModification.fromZonedDateTime(category.getUtcInception()),
            DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription,
            category.getPrice(), true, "", true, null, null, null, null, null);
    Result<TicketCategory> resOk = eventManager.updateCategory(category.getId(), event, tcmOk, username);
    Assert.assertTrue(resOk.isSuccess());

    TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 1,
            DateTimeModification.fromZonedDateTime(category.getUtcInception()),
            DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription,
            category.getPrice(), true, "", true, null, null, null, null, null);
    Result<TicketCategory> res = eventManager.updateCategory(category.getId(), event, tcm, username);
    Assert.assertFalse(res.isSuccess());
    Assert.assertTrue(res.getErrors().contains(ErrorCode.CategoryError.NOT_ENOUGH_FREE_TOKEN_FOR_SHRINK));
}

From source file:org.egov.ptis.actions.modify.ModifyPropertyAction.java

/**
 * Modifies and Forwards the assessment to next user when form is submitted in read only mode
 *
 * @return//w ww .  ja v a2s  .  com
 */
@SkipValidation
@Action(value = "/modifyProperty-forwardView")
public String forwardView() {
    validateApproverDetails();
    if (hasErrors())
        if (isAssistantOrRIApprovalPending())
            return NEW;
        else if (isCommissionerRoOrBillCollector())
            return VIEW;
    propertyModel = (PropertyImpl) getPersistenceService().findByNamedQuery(QUERY_PROPERTYIMPL_BYID,
            Long.valueOf(getModelId()));
    if (multipleSubmitCondition(propertyModel, approverPositionId))
        return multipleSubmitRedirect();
    transitionWorkFlow(propertyModel);
    if (SOURCE_SURVEY.equalsIgnoreCase(propertyModel.getSource())) {
        SurveyBean surveyBean = new SurveyBean();
        if (propertyModel.getCurrentState().getValue().toUpperCase()
                .endsWith(WF_STATE_REVENUE_OFFICER_APPROVED.toUpperCase())) {
            BigDecimal surveyVariance = propertyTaxUtil.getTaxDifferenceForGIS(propertyModel);
            propertyModel.setSurveyVariance(surveyVariance);
            if (surveyVariance.compareTo(BigDecimal.TEN) > 0 && !propertyModel.isThirdPartyVerified()) {
                noticeService.generateComparisonNotice(propertyModel);
                propertyModel.setSentToThirdParty(true);
            }
        }
        surveyBean.setProperty(propertyModel);
        propertySurveyService.updateSurveyIndex(APPLICATION_TYPE_ALTER_ASSESSENT, surveyBean);
    }

    propService.updateIndexes(propertyModel, getApplicationType());
    basicPropertyService.update(basicProp);
    if (propertyModel.getSource().equalsIgnoreCase(Source.CITIZENPORTAL.toString()))
        propService.updatePortal(propertyModel, getApplicationType());
    setModifyRsn(propertyModel.getPropertyDetail().getPropertyMutationMaster().getCode());
    prepareAckMsg();
    buildEmailandSms(propertyModel, APPLICATION_TYPE_ALTER_ASSESSENT);
    addActionMessage(
            getText(PROPERTY_FORWARD_SUCCESS, new String[] { propertyModel.getBasicProperty().getUpicNo() }));
    return RESULT_ACK;
}

From source file:com.magnet.android.mms.controller.RequestPrimitiveTest.java

@SmallTest
public void testSingleListBigDecimalPostParam() throws JSONException {
    ControllerHandler handler = new ControllerHandler();
    String methodName = "postBigDecimals";
    JMethod method = new JMethod();
    JMeta metaInfo = new JMeta(methodName, API_METHOD_POST + methodName, POST);
    method.setMetaInfo(metaInfo);//from www .j  a  va 2 s. c o  m

    // int
    method.addParam("param0", PLAIN, List.class, BigDecimal.class, "", false);

    List<BigDecimal> values = new ArrayList<BigDecimal>();
    values.add(BigDecimal.TEN);
    values.add(BigDecimal.valueOf(101.99));

    String uriString = handler.buildUri(method, new Object[] { values });
    String bodyString = handler.buildRequestBodyString(method, new Object[] { values });

    String expected = API_METHOD_POST + methodName;
    logger.log(Level.INFO, "uriString=" + uriString);
    logger.log(Level.INFO, "bodyString=" + bodyString);
    assertEquals(expected, uriString);

    JSONArray jarray = new JSONArray(bodyString);
    int idx = 0;
    for (BigDecimal value : values) {
        assertEquals(jarray.getString(idx), value.toString());
        idx++;
    }
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testNewCategoryBoundedAddReleasedTickets() {
    Pair<Event, String> eventAndUser = generateAndEditEvent(AVAILABLE_SEATS + 10);
    //now we have 20 free seats, 10 of which RELEASED
    Event event = eventAndUser.getLeft();
    String username = eventAndUser.getRight();
    TicketCategoryModification tcm = new TicketCategoryModification(null, "additional", 20,
            DateTimeModification.fromZonedDateTime(ZonedDateTime.now(event.getZoneId()).minusMinutes(1)),
            DateTimeModification.fromZonedDateTime(ZonedDateTime.now(event.getZoneId()).plusDays(5)),
            Collections.emptyMap(), BigDecimal.TEN, false, "", true, null, null, null, null, null);
    Result<Integer> result = eventManager.insertCategory(event, tcm, username);
    assertTrue(result.isSuccess());//from w w  w  . j av  a 2  s.c o  m
    assertEquals(20,
            ticketRepository.countReleasedTicketInCategory(event.getId(), result.getData()).intValue());
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testNewRestrictedCategory() {
    Pair<Event, String> eventAndUser = generateAndEditEvent(AVAILABLE_SEATS + 10);
    //now we have 20 free seats, 10 of which RELEASED
    Event event = eventAndUser.getLeft();
    String username = eventAndUser.getRight();
    TicketCategoryModification tcm = new TicketCategoryModification(null, "additional", 20,
            DateTimeModification.fromZonedDateTime(ZonedDateTime.now(event.getZoneId()).minusMinutes(1)),
            DateTimeModification.fromZonedDateTime(ZonedDateTime.now(event.getZoneId()).plusDays(5)),
            Collections.emptyMap(), BigDecimal.TEN, true, "", true, null, null, null, null, null);
    Result<Integer> result = eventManager.insertCategory(event, tcm, username);
    assertTrue(result.isSuccess());/*  www.ja v  a2s.  c  om*/
    assertEquals(20, ticketRepository.countFreeTickets(event.getId(), result.getData()).intValue());
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testNewBoundedCategoryWithExistingBoundedAndPendingTicket() {
    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 ww w  . j  a va  2s.c  om*/
    Event event = pair.getLeft();
    String username = pair.getRight();
    assertEquals(new Integer(AVAILABLE_SEATS), ticketRepository.countFreeTicketsForUnbounded(event.getId()));
    TicketReservationModification trm = new TicketReservationModification();
    trm.setAmount(1);
    trm.setTicketCategoryId(ticketCategoryRepository.findByEventId(event.getId()).get(0).getId());
    TicketReservationWithOptionalCodeModification reservation = new TicketReservationWithOptionalCodeModification(
            trm, Optional.empty());
    ticketReservationManager.createTicketReservation(event, Collections.singletonList(reservation),
            Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(),
            Locale.ENGLISH, false);
    TicketCategoryModification tcm = new TicketCategoryModification(null, "new", 1,
            DateTimeModification.fromZonedDateTime(ZonedDateTime.now()),
            DateTimeModification.fromZonedDateTime(ZonedDateTime.now().plusDays(1)), Collections.emptyMap(),
            BigDecimal.TEN, false, "", true, null, null, null, null, null);
    Result<Integer> insertResult = eventManager.insertCategory(event, tcm, username);
    assertTrue(insertResult.isSuccess());
    Integer categoryID = insertResult.getData();
    tcm = new TicketCategoryModification(categoryID, tcm.getName(), AVAILABLE_SEATS, tcm.getInception(),
            tcm.getExpiration(), tcm.getDescription(), tcm.getPrice(), false, "", true, null, null, null, null,
            null);
    Result<TicketCategory> result = eventManager.updateCategory(categoryID, event, tcm, username);
    assertFalse(result.isSuccess());
}

From source file:alfio.manager.EventManagerIntegrationTest.java

private Pair<Event, String> generateAndEditEvent(int newEventSize) {
    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);//from ww w.j av  a2s  . c om

    Event event = pair.getKey();
    if (newEventSize != AVAILABLE_SEATS) {
        EventModification update = new EventModification(event.getId(), Event.EventType.INTERNAL, null, null,
                null, null, null, null, null, event.getOrganizationId(), null, null, null,
                event.getZoneId().toString(), Collections.emptyMap(),
                DateTimeModification.fromZonedDateTime(event.getBegin()),
                DateTimeModification.fromZonedDateTime(event.getEnd()), event.getRegularPrice(),
                event.getCurrency(), newEventSize, event.getVat(), event.isVatIncluded(),
                event.getAllowedPaymentProxies(), null, event.isFreeOfCharge(), null, 7, null, null);
        eventManager.updateEventPrices(event, update, pair.getValue());
    }
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertNotNull(tickets);
    assertFalse(tickets.isEmpty());
    assertEquals(AVAILABLE_SEATS, tickets.size());
    if (newEventSize > AVAILABLE_SEATS) {
        assertEquals(newEventSize - AVAILABLE_SEATS,
                ticketRepository.countReleasedUnboundedTickets(event.getId()).intValue());
    }
    assertEquals(10, tickets.stream().filter(t -> t.getCategoryId() != null).count());
    return Pair.of(eventRepository.findById(event.getId()), pair.getRight());
}

From source file:fragment.web.WorkflowControllerTest.java

/**
 * @desc Private method to change the account type of the given tenant to the given account type
 * @author vinayv//ww w .j  av a 2  s .c  o m
 * @param tenant
 * @param accountTypeName
 * @throws IOException
 */
private void changeAccountType(Tenant tenant, String accountTypeName) throws IOException {

    CreditCard creditCard = new CreditCard("VISA", "4111111111111111", 3, 2015, "123",
            tenant.getOwner().getFirstName(), VALID_BILLING_ADDRESS);
    if (creditCard != null) {
        creditCard.setNameOnCard(creditCard.getFirstNameOnCard() + " " + creditCard.getLastNameOnCard());
    }
    AccountType accountType = accountTypeService.locateAccountTypeName(accountTypeName);
    if (accountType.getSupportedPaymentModes().get(0) == PaymentMode.CREDIT_CARD) {
        if (creditCard == null || creditCard.getCreditCardNumber() == null) {
            throw new InvalidPaymentModeException("Credit card is required for this account type");
        }
    }
    tenantService.convertAccountType(tenant, new BillingInfo(creditCard), BigDecimal.TEN, accountTypeName,
            null);
}

From source file:de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartServiceTest.java

@Test
public void shouldEstimateTaxesWithoutCache() {
    given(commerceCartEstimateTaxesStrategy.estimateTaxes(cartModel, "11211", "US")).willReturn(BigDecimal.TEN);
    given(commerceCartHashCalculationStrategy.buildHashForAbstractOrder(cartModel,
            Arrays.asList("11211", "US"))).willReturn("hash");
    given(sessionService.getAttribute(DefaultCommerceCartService.ESTIMATED_TAXES)).willReturn(null);

    final CommerceCartParameter parameter = new CommerceCartParameter();
    parameter.setEnableHooks(true);// www. j  ava 2s  .  c  o  m
    parameter.setCart(cartModel);
    parameter.setDeliveryZipCode("11211");
    parameter.setDeliveryCountryIso("US");

    final BigDecimal estimatedTaxes = commerceCartService.estimateTaxes(parameter).getTax();
    Assert.assertThat(estimatedTaxes, CoreMatchers.equalTo(BigDecimal.TEN));
}

From source file:org.egov.ptis.actions.create.CreatePropertyAction.java

@SkipValidation
@Action(value = "/createProperty-forward")
public String forward() {
    String loggedInUserDesignation = "";
    if (property.getState() != null) {
        final List<Assignment> loggedInUserAssign = assignmentService.getAssignmentByPositionAndUserAsOnDate(
                property.getCurrentState().getOwnerPosition().getId(), securityUtils.getCurrentUser().getId(),
                new Date());
        loggedInUserDesignation = !loggedInUserAssign.isEmpty()
                ? loggedInUserAssign.get(0).getDesignation().getName()
                : null;/*from  w  w w  . j a va  2s.  c om*/
    }
    final Assignment wfInitiator = getWorkflowInitiator(loggedInUserDesignation);
    if (WFLOW_ACTION_STEP_REJECT.equalsIgnoreCase(workFlowAction) && wfInitiator == null) {
        if (propertyTaxCommonUtils.isRoOrCommissioner(loggedInUserDesignation))
            addActionError(getText(REJECT_ERROR_INITIATOR_INACTIVE, Arrays.asList(REVENUE_INSPECTOR_DESGN)));
        else
            addActionError(getText(REJECT_ERROR_INITIATOR_INACTIVE,
                    Arrays.asList(JUNIOR_ASSISTANT + "/" + SENIOR_ASSISTANT)));
        return mode.equalsIgnoreCase(EDIT) ? RESULT_NEW : RESULT_VIEW;
    } else if (WFLOW_ACTION_STEP_REJECT.equalsIgnoreCase(workFlowAction)
            && propService.getWorkflowInitiator(property) == null) {
        addActionError(getText(REJECT_ERROR_INITIATOR_INACTIVE,
                Arrays.asList(JUNIOR_ASSISTANT + "/" + SENIOR_ASSISTANT)));
        return mode.equalsIgnoreCase(EDIT) ? RESULT_NEW : RESULT_VIEW;
    }
    if (multipleSubmitCondition(property, approverPositionId)) {
        return multipleSubmitRedirect();
    }
    if (mode.equalsIgnoreCase(EDIT) && !WFLOW_ACTION_STEP_REJECT.equalsIgnoreCase(workFlowAction)) {
        validate();
        if (hasErrors() && (StringUtils.containsIgnoreCase(userDesignationList, REVENUE_INSPECTOR_DESGN)
                || StringUtils.containsIgnoreCase(userDesignationList, JUNIOR_ASSISTANT)
                || StringUtils.containsIgnoreCase(userDesignationList, SENIOR_ASSISTANT))) {
            showTaxCalcBtn = Boolean.TRUE;
            setAllowEditDocument(Boolean.TRUE);
            return RESULT_NEW;
        } else if (hasErrors())
            return RESULT_NEW;
        updatePropertyDetails();
        try {
            propService.createDemand(property, basicProp.getPropOccupationDate());
        } catch (final TaxCalculatorExeption e) {
            addActionError(getText(UNIT_RATE_ERROR));
            logger.error("forward : There are no Unit rates defined for chosen combinations", e);
            return RESULT_NEW;
        }
    } else {
        validateApproverDetails();
        if (hasErrors())
            return RESULT_VIEW;
    }
    if (!WFLOW_ACTION_STEP_REJECT.equalsIgnoreCase(workFlowAction))
        transitionWorkFlow(property);

    if (WFLOW_ACTION_STEP_APPROVE.equalsIgnoreCase(workFlowAction))
        return approve();
    else if (WFLOW_ACTION_STEP_REJECT.equalsIgnoreCase(workFlowAction)) {
        transitionWorkFlow(property);
        return reject();
    }
    basicProp.setUnderWorkflow(true);
    basicPropertyService.applyAuditing(property.getState());
    if (SOURCE_SURVEY.equalsIgnoreCase(property.getSource())) {
        SurveyBean surveyBean = new SurveyBean();
        surveyBean.setProperty(property);
        if (StringUtils.containsIgnoreCase(userDesignationList, REVENUE_INSPECTOR_DESGN)
                || StringUtils.containsIgnoreCase(userDesignationList, JUNIOR_ASSISTANT)
                || StringUtils.containsIgnoreCase(userDesignationList, SENIOR_ASSISTANT)) {
            BigDecimal totalTax = propService.getSurveyTax(property, new Date());
            surveyBean.setApplicationTax(totalTax);
            GisDetails gisDetails = property.getGisDetails();
            if (gisDetails != null) {
                gisDetails.setPropertyZone(basicProp.getPropertyID().getZone());
                gisDetails.setApplicationTax(totalTax);
                GisAuditDetails auditDetails = new GisAuditDetails(gisDetails);
                gisDetails.addAuditDetails(auditDetails);
            }
        }
        if (property.getCurrentState().getValue().toUpperCase()
                .endsWith(WF_STATE_REVENUE_OFFICER_APPROVED.toUpperCase())) {
            BigDecimal surveyVariance = propertyTaxUtil.getTaxDifferenceForGIS(property);
            property.setSurveyVariance(surveyVariance);
            if (surveyVariance.compareTo(BigDecimal.TEN) > 0 && !property.isThirdPartyVerified()) {
                noticeService.generateComparisonNotice(property);
                property.setSentToThirdParty(true);
                surveyBean.setProperty(property);
            }
        }
        propertySurveyService.updateSurveyIndex(APPLICATION_TYPE_NEW_ASSESSENT, surveyBean);
    }
    basicProp.addProperty(property);
    propService.updateIndexes(property, APPLICATION_TYPE_NEW_ASSESSENT);
    if (Source.CITIZENPORTAL.toString().equalsIgnoreCase(property.getSource()))
        propService.updatePortal(property, APPLICATION_TYPE_NEW_ASSESSENT);
    basicPropertyService.persist(basicProp);
    setDocNumber(getDocNumber());
    setApplicationNoMessage(" with application number : ");
    return RESULT_ACK;
}