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:de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartServiceTest.java

@Test
public void shouldEstimateTaxesWithCache() {
    given(commerceCartEstimateTaxesStrategy.estimateTaxes(cartModel, "11211", "US")).willReturn(BigDecimal.TEN);
    final CommerceOrderParameter orderParameter = new CommerceOrderParameter();
    orderParameter.setOrder(cartModel);/*from  ww w . ja va 2s  .  co  m*/
    orderParameter.setAdditionalValues(Arrays.asList("11211", "US"));

    given(commerceCartHashCalculationStrategy.buildHashForAbstractOrder(any(CommerceOrderParameter.class)))
            .willReturn("hash");
    final DefaultCommerceCartService.HashAndTaxEstimate hashAndTaxEstimate = new DefaultCommerceCartService.HashAndTaxEstimate(
            "hash", BigDecimal.ONE);
    given(sessionService.getAttribute(DefaultCommerceCartService.ESTIMATED_TAXES))
            .willReturn(hashAndTaxEstimate);
    final CommerceCartParameter parameter = new CommerceCartParameter();
    parameter.setEnableHooks(true);
    parameter.setCart(cartModel);
    parameter.setDeliveryZipCode("11211");
    parameter.setDeliveryCountryIso("US");
    final BigDecimal estimatedTaxes = commerceCartService.estimateTaxes(parameter).getTax();
    Assert.assertThat(estimatedTaxes, CoreMatchers.equalTo(BigDecimal.ONE));
}

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

@Test
public void shouldEstimateTaxesWithInvalidCache() {
    given(commerceCartEstimateTaxesStrategy.estimateTaxes(cartModel, "11211", "US")).willReturn(BigDecimal.TEN);
    given(commerceCartHashCalculationStrategy.buildHashForAbstractOrder(any(CommerceOrderParameter.class)))
            .willReturn("invalidhash");
    final DefaultCommerceCartService.HashAndTaxEstimate hashAndTaxEstimate = new DefaultCommerceCartService.HashAndTaxEstimate(
            "hash", BigDecimal.ONE);
    given(sessionService.getAttribute(DefaultCommerceCartService.ESTIMATED_TAXES))
            .willReturn(hashAndTaxEstimate);
    final CommerceCartParameter parameter = new CommerceCartParameter();
    parameter.setEnableHooks(true);/*from   w  w w  . j av a2s  .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.finra.herd.dao.helper.EmrPricingHelperTest.java

@Test
public void testGetEmrClusterPricesWithinLowestCoreInstancePriceThresholdMultiplePricing() throws Exception {
    List<EmrClusterPriceDto> pricingList = Arrays.asList(
            createSimpleEmrClusterPrice(AVAILABILITY_ZONE_1, BigDecimal.ONE),
            createSimpleEmrClusterPrice(AVAILABILITY_ZONE_2, BigDecimal.TEN),
            createSimpleEmrClusterPrice(AVAILABILITY_ZONE_3, ONE_POINT_ONE),
            createSimpleEmrClusterPrice(AVAILABILITY_ZONE_4, ONE_POINT_ONE_ONE));

    List<EmrClusterPriceDto> lowestCoreInstancePriceClusters = emrPricingHelper
            .getEmrClusterPricesWithinLowestCoreInstancePriceThreshold(pricingList, TEN_PERCENT);
    assertEquals(2, lowestCoreInstancePriceClusters.size());
    for (EmrClusterPriceDto emrClusterPriceDto : lowestCoreInstancePriceClusters) {
        assertTrue(Arrays.asList(AVAILABILITY_ZONE_1, AVAILABILITY_ZONE_3)
                .contains(emrClusterPriceDto.getAvailabilityZone()));
    }/*  w  w  w . j a v  a  2 s  .c o  m*/
}

From source file:org.finra.herd.dao.helper.EmrPricingHelperTest.java

/**
 * Tests when the threshold is set to zero.
 *
 * @throws Exception//from ww w.j ava2 s.  co  m
 */
@Test
public void testGetEmrClusterPricesWithinLowestCoreInstancePriceZeroThresholdMultiplePricings()
        throws Exception {
    List<EmrClusterPriceDto> pricingList = Arrays.asList(
            createSimpleEmrClusterPrice(AVAILABILITY_ZONE_1, BigDecimal.ONE),
            createSimpleEmrClusterPrice(AVAILABILITY_ZONE_2, BigDecimal.TEN),
            createSimpleEmrClusterPrice(AVAILABILITY_ZONE_3, BigDecimal.ONE.add(FIVE_UNIT)),
            createSimpleEmrClusterPrice(AVAILABILITY_ZONE_4, BigDecimal.ONE));

    List<EmrClusterPriceDto> lowestCoreInstancePriceClusters = emrPricingHelper
            .getEmrClusterPricesWithinLowestCoreInstancePriceThreshold(pricingList, BigDecimal.ZERO);
    assertEquals(2, lowestCoreInstancePriceClusters.size());
    for (EmrClusterPriceDto emrClusterPriceDto : lowestCoreInstancePriceClusters) {
        assertTrue(Arrays.asList(AVAILABILITY_ZONE_1, AVAILABILITY_ZONE_4)
                .contains(emrClusterPriceDto.getAvailabilityZone()));
    }
}

From source file:org.libreplan.business.test.orders.entities.OrderElementTest.java

@Test
@Transactional//w  ww.jav a 2 s .  co m
public void checkSpreadAdvanceInOrderLine() throws DuplicateValueTrueReportGlobalAdvanceException,
        DuplicateAdvanceAssignmentForOrderElementException {

    OrderLine orderLine = givenOrderLine("element", "element-code", 100);

    AdvanceType advanceType1 = PredefinedAdvancedTypes.PERCENTAGE.getType();
    AdvanceType advanceType2 = PredefinedAdvancedTypes.UNITS.getType();

    addAdvanceAssignmentWithoutMeasurement(orderLine, advanceType1, BigDecimal.TEN, true);
    addAdvanceAssignmentWithoutMeasurement(orderLine, advanceType2, BigDecimal.TEN, false);

    assertThat(orderLine.getReportGlobalAdvanceAssignment().getAdvanceType(), equalTo(advanceType1));
    assertNotNull(orderLine.getReportGlobalAdvanceAssignment());

    orderLine.removeAdvanceAssignment(orderLine.getAdvanceAssignmentByType(advanceType1));

    assertNotNull(orderLine.getReportGlobalAdvanceAssignment());
    assertThat(orderLine.getReportGlobalAdvanceAssignment().getAdvanceType(), equalTo(advanceType2));
}

From source file:fragment.web.BillingControllerTest.java

@Test
public void testChangeAccountType1() throws IOException {

    Tenant tenant = tenantDAO.find(25L);
    CreditCard cc = new CreditCard("VISA", "4111111111111111", 3, 2015, "123", tenant.getOwner().getFirstName(),
            VALID_BILLING_ADDRESS);//  ww w  .j  av a 2  s.co m
    SetAccountTypeForm form = new SetAccountTypeForm(tenant);
    form.setAccountTypeName(accountTypeDAO.find(4L).getName());
    form.setBillingAddress(VALID_BILLING_ADDRESS);
    form.setInitialPayment(BigDecimal.TEN);
    form.setCreditCard(cc);
    ModelMap resultMap = controller.changeAccountType(tenant.getParam(), form, request, response, map);
    Assert.assertNotNull(resultMap);
    String result = (String) resultMap.get("redirecturl");
    Assert.assertNotNull(result);
    Assert.assertEquals("/portal/portal/tenants/editcurrent", result);

}

From source file:fragment.web.BillingControllerTest.java

@Test
@ExpectedException(InvalidAjaxRequestException.class)
public void testChangeAccountTypeSecondTime() throws IOException {

    Tenant tenant = tenantDAO.find(25L);
    CreditCard cc = new CreditCard("VISA", "4111111111111111", 3, 2015, "123", tenant.getOwner().getFirstName(),
            VALID_BILLING_ADDRESS);//from  w  w  w  .  jav a 2 s.com
    SetAccountTypeForm form = new SetAccountTypeForm(tenant);
    form.setAccountTypeName(accountTypeDAO.find(4L).getName());
    form.setBillingAddress(VALID_BILLING_ADDRESS);
    form.setInitialPayment(BigDecimal.TEN);
    form.setCreditCard(cc);
    ModelMap resultMap = controller.changeAccountType(tenant.getParam(), form, request, response, map);
    Assert.assertNotNull(resultMap);
    String result = (String) resultMap.get("redirecturl");
    Assert.assertNotNull(result);
    Assert.assertEquals("/portal/portal/tenants/editcurrent", result);

    controller.changeAccountType(tenant.getParam(), form, request, response, map);

}

From source file:org.egov.ptis.actions.common.PropertyTaxBaseAction.java

public void enableActionsForGIS(final PropertyImpl property, final List<DocumentType> documentTypes) {
    String appConfigValue = propertyTaxCommonUtils.getAppConfigValue(APPCONFIG_GIS_THIRDPARTY_CHECKBOX_REQUIRED,
            PTMODULENAME);/*from  www  .  j  a  v  a  2 s  .  co m*/
    if (property.getState().getNextAction().endsWith(WF_STATE_COMMISSIONER_APPROVAL_PENDING)
            && property.getSurveyVariance().compareTo(BigDecimal.TEN) > 0) {
        showCheckboxForGIS = true;
        if (property.isThirdPartyVerified())
            thirdPartyCheckbox = true;
    }
    if (property.isThirdPartyVerified()
            && property.getState().getValue().endsWith(":".concat(WF_STATE_REJECTED))
            && WF_STATE_UD_REVENUE_INSPECTOR_APPROVAL_PENDING
                    .equalsIgnoreCase(property.getState().getNextAction())) {
        showCheckboxForGIS = true;
        if (PropertyTaxConstants.PROPERTY_MODIFY_REASON_ADD_OR_ALTER
                .equalsIgnoreCase(property.getPropertyModifyReason()) && property.isThirdPartyVerified())
            thirdPartyCheckbox = true;
        for (final DocumentType docType : documentTypes)
            if (DOCUMENT_TYPE_THIRD_PARTY_SURVEY.equalsIgnoreCase(docType.getName()))
                docType.setMandatory(true);
    }
    if ("N".equalsIgnoreCase(appConfigValue))
        disableThirdPartyCheckbox = true;
    else
        disableThirdPartyCheckbox = false;
}

From source file:org.marketcetera.strategy.LanguageTestBase.java

/**
 * Tests a strategy's ability to send arbitrary objects.
 *
 * @throws Exception if an error occurs/*from  w w w .  j  a  va  2 s  .c  om*/
 */
@Test
public void other() throws Exception {
    theStrategy = createStrategy(getOtherStrategy().getName(), getLanguage(), getOtherStrategy().getFile(),
            null, null, outputURN);
    // run the strategy with nothing set
    setPropertiesToNull();
    doOtherTest(theStrategy, new Object[0]);
    assertTrue(
            "Expected properties to be empty, but was: " + AbstractRunningStrategy.getProperties().toString(),
            AbstractRunningStrategy.getProperties().isEmpty());
    // have the strategy send null
    AbstractRunningStrategy.setProperty("sendNull", "true");
    doOtherTest(theStrategy, new Object[0]);
    // make sure only the property we set above is set
    assertEquals(1, AbstractRunningStrategy.getProperties().size());
    assertEquals(AbstractRunningStrategy.getProperty("sendNull"), "true");
    // have the strategy send a string
    setPropertiesToNull();
    AbstractRunningStrategy.setProperty("sendString", "true");
    doOtherTest(theStrategy, new Object[] { "test string" });
    assertEquals("Properties were " + AbstractRunningStrategy.getProperties(), 1,
            AbstractRunningStrategy.getProperties().size());
    assertEquals(AbstractRunningStrategy.getProperty("sendString"), "true");
    // have the strategy send two BigDecimals
    setPropertiesToNull();
    AbstractRunningStrategy.setProperty("sendTwo", "true");
    doOtherTest(theStrategy, new Object[] { BigDecimal.ONE, BigDecimal.TEN });
    assertEquals("Properties was " + AbstractRunningStrategy.getProperties(), 1,
            AbstractRunningStrategy.getProperties().size());
    assertEquals(AbstractRunningStrategy.getProperty("sendTwo"), "true");
    // route orders to strategy and check output
    setPropertiesToNull();
    theStrategy = createStrategy(getOtherStrategy().getName(), getLanguage(), getOtherStrategy().getFile(),
            null, true, outputURN);
    AbstractRunningStrategy.setProperty("sendTwo", "true");
    doOtherTest(theStrategy, new Object[] { BigDecimal.ONE, BigDecimal.TEN });
    assertEquals("Properties was " + AbstractRunningStrategy.getProperties(), 1,
            AbstractRunningStrategy.getProperties().size());
    assertEquals(AbstractRunningStrategy.getProperty("sendTwo"), "true");
}

From source file:webserver.WebResource.java

@SuppressWarnings("unchecked")
@POST/*from ww  w.  j  a  v  a2 s .  c om*/
@Path("index/likepost.html")
@Consumes("application/x-www-form-urlencoded")
public Response likePost(@Context HttpServletRequest request, MultivaluedMap<String, String> form) {

    JSONObject json = new JSONObject();

    try {

        String signature = form.getFirst("signature");
        String likeString = form.getFirst("like");

        Profile activeProfileOpt = ProfileHelper.getInstance().getActiveProfileOpt(request);

        if (likeString != null && activeProfileOpt != null) {
            boolean like = Boolean.valueOf(likeString);
            if (activeProfileOpt.isProfileEnabled()) {

                if (like) {
                    String result;

                    if (activeProfileOpt.getLikedPosts().contains(signature)) {

                        json.put("type", "YouAlreadyLikeThisPost");

                        return Response.status(200).header("Content-Type", "application/json; charset=utf-8")
                                .entity(json.toJSONString()).build();
                    }

                    BlogEntry blogEntryOpt = BlogUtils.getBlogEntryOpt((ArbitraryTransaction) Controller
                            .getInstance().getTransaction(Base58.decode(signature)));

                    boolean ownPost = false;
                    if (blogEntryOpt != null) {
                        if (Controller.getInstance().getAccountByAddress(blogEntryOpt.getCreator()) != null) {
                            ownPost = true;
                        }
                    }

                    if (ownPost) {

                        json.put("type", "YouCantLikeYourOwnPosts");

                        return Response.status(200).header("Content-Type", "application/json; charset=utf-8")
                                .entity(json.toJSONString()).build();

                    }

                    activeProfileOpt.addLikePost(signature);
                    try {

                        String creator = blogEntryOpt.getCreator();
                        List<Payment> payments = new ArrayList<>();
                        if (creator != null) {
                            BigDecimal amount = BigDecimal.TEN;
                            amount = amount.setScale(8);
                            payments.add(new Payment(new Account(creator), AssetCls.FEE_KEY, amount));
                        }
                        result = activeProfileOpt.saveProfile(payments);

                        json.put("type", "LikeSuccessful");
                        json.put("result", result);

                    } catch (WebApplicationException e) {

                        json.put("type", "LikeNotSuccessful");
                        json.put("result", e.getResponse().getEntity());
                    }

                    return Response.status(200).header("Content-Type", "application/json; charset=utf-8")
                            .entity(json.toJSONString()).build();
                } else {
                    if (activeProfileOpt.getLikedPosts().contains(signature)) {

                        activeProfileOpt.removeLikeProfile(signature);
                        String result;
                        try {
                            result = activeProfileOpt.saveProfile(null);

                            json.put("type", "LikeRemovedSuccessful");
                            json.put("result", result);

                        } catch (WebApplicationException e) {

                            json.put("type", "LikeRemovedNotSuccessful");
                            json.put("result", e.getResponse().getEntity());

                        }

                        return Response.status(200).header("Content-Type", "application/json; charset=utf-8")
                                .entity(json.toJSONString()).build();
                    }
                }

            }
        }

    } catch (Throwable e) {
        LOGGER.error(e.getMessage(), e);

        json.put("type", "error");
        json.put("error", e.getMessage());

        return Response.status(200).header("Content-Type", "application/json; charset=utf-8")
                .entity(json.toJSONString()).build();
    }

    return Response.status(200).header("Content-Type", "application/json; charset=utf-8").entity("{}").build();
}