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:net.joaopeixoto.geode.server.functions.PatternFunctions.java

/**
 * Replace here with your favorite algorithm
 *///from   ww w . j ava 2s .  co m
@GemfireFunction
public DistanceResult distance(List<Metric> metrics) {
    Assert.notEmpty(metrics);
    Metric first = metrics.get(0);

    LinkedList<Metric> currentWindow = new LinkedList<>();
    LinkedList<Metric> matchedWindow = new LinkedList<>();
    double minDistance = THRESHOLD;
    int matchCount = 0;

    log.debug("Checking for patterns comparing with {}", metrics);

    List<Metric> localValues = new ArrayList<>(metricRegion.values());

    /**
     * Ensure the local values are ordered. {@link Region#values()} does not guarantee it.
     */
    Collections.sort(localValues);
    for (Metric metric : localValues) {

        // Ignore overlapping points or noise
        if (metric.getTimestamp() >= first.getTimestamp() || metric.getValue().compareTo(BigDecimal.TEN) < 1) {
            if (!currentWindow.isEmpty()) {
                currentWindow.pop();
            }
            continue;
        }

        currentWindow.add(metric);
        if (currentWindow.size() > 13) {
            currentWindow.pop();
        }

        /**
         * We only compare windows the same size (for now)
         */
        if (currentWindow.size() == 13) {

            TimeWarpInfo compare = DTW.compare(metricToSeries(currentWindow), metricToSeries(metrics),
                    Distances.EUCLIDEAN_DISTANCE);
            if (compare.getDistance() <= 1D) {
                matchCount++;
                matchedWindow = new LinkedList<>(currentWindow);
            }
        }
    }

    if (matchCount > 0) {
        return new DistanceResult(matchedWindow, minDistance, matchCount);
    }
    return null;
}

From source file:com.haulmont.cuba.core.NonDetachedTest.java

@Before
public void setUp() throws Exception {
    persistence = cont.persistence();/*www.  ja  va  2  s .co  m*/
    metadata = cont.metadata();

    try (Transaction tx = persistence.createTransaction()) {
        EntityManager em = persistence.getEntityManager();

        user = metadata.create(User.class);
        user.setName("testUser");
        user.setLogin("testLogin");
        companyGroup = em.find(Group.class, TestSupport.COMPANY_GROUP_ID);
        user.setGroup(companyGroup);
        em.persist(user);

        customer = metadata.create(Customer.class);
        customer.setName("test customer");
        em.persist(customer);

        order = metadata.create(Order.class);
        order.setDate(new Date());
        order.setAmount(BigDecimal.TEN);
        order.setCustomer(customer);
        order.setUser(user);
        em.persist(order);

        cascadeEntity1 = metadata.create(CascadeEntity.class);
        cascadeEntity1.setName("cascadeEntity1");
        em.persist(cascadeEntity1);

        cascadeEntity2 = metadata.create(CascadeEntity.class);
        cascadeEntity2.setName("cascadeEntity2");
        cascadeEntity2.setFather(cascadeEntity1);
        em.persist(cascadeEntity2);

        cascadeEntity1.setFirstChild(cascadeEntity2);

        tx.commit();
    }

    orderView = new View(Order.class).addProperty("date").addProperty("amount")
            .addProperty("customer", new View(Customer.class).addProperty("name"))
            .addProperty("user", new View(User.class).addProperty("login").addProperty("name"));
}

From source file:org.apache.sling.jcr.resource.internal.JcrPropertyMapTest.java

public void testJCRType() throws Exception {
    this.rootNode.getSession().refresh(false);
    testValue(rootNode, "A String");
    testValue(rootNode, Calendar.getInstance());
    testValue(rootNode, 5L);//  ww  w  .jav  a2 s  .c  om
    testValue(rootNode, 1.4D);
    testValue(rootNode, true);
    testValue(rootNode, BigDecimal.TEN);
}

From source file:com.jive.myco.seyren.core.service.notification.HttpNotificationServiceTest.java

@Test
public void checkingOutTheHappyPath() {

    String seyrenUrl = clientDriver.getBaseUrl() + "/seyren";

    when(mockSeyrenConfig.getGraphiteUrl()).thenReturn(clientDriver.getBaseUrl() + "/graphite");
    when(mockSeyrenConfig.getBaseUrl()).thenReturn(seyrenUrl);

    Check check = new Check().withEnabled(true).withName("check-name").withTarget("statsd.metric.name")
            .withState(AlertType.ERROR).withWarn(BigDecimal.ONE).withError(BigDecimal.TEN);

    Subscription subscription = new Subscription().withType(SubscriptionType.HTTP)
            .withTarget(clientDriver.getBaseUrl() + "/myendpoint/thatdoesstuff");

    Alert alert = new Alert().withTarget("the.target.name").withValue(BigDecimal.valueOf(12))
            .withWarn(BigDecimal.valueOf(5)).withError(BigDecimal.valueOf(10)).withFromType(AlertType.WARN)
            .withToType(AlertType.ERROR);

    List<Alert> alerts = Arrays.asList(alert);

    BodyCapture<JsonNode> bodyCapture = new JsonBodyCapture();

    clientDriver.addExpectation(/*  w w  w . j  a  v  a2 s.c  om*/
            onRequestTo("/myendpoint/thatdoesstuff").withMethod(Method.POST).capturingBodyIn(bodyCapture),
            giveResponse("success", "text/plain"));

    service.sendNotification(check, subscription, alerts);

    JsonNode node = bodyCapture.getContent();

    assertThat(node, hasJsonPath("$.seyrenUrl", is(seyrenUrl)));
    assertThat(node, hasJsonPath("$.check.name", is("check-name")));
    assertThat(node, hasJsonPath("$.check.state", is("ERROR")));
    assertThat(node, hasJsonPath("$.alerts", hasSize(1)));
    assertThat(node, hasJsonPath("$.alerts[0].target", is("the.target.name")));
    assertThat(node, hasJsonPath("$.alerts[0].value", is(12)));
    assertThat(node, hasJsonPath("$.alerts[0].warn", is(5)));
    assertThat(node, hasJsonPath("$.alerts[0].error", is(10)));
    assertThat(node, hasJsonPath("$.alerts[0].fromType", is("WARN")));
    assertThat(node, hasJsonPath("$.alerts[0].toType", is("ERROR")));
    assertThat(node, hasJsonPath("$.preview", Matchers.startsWith("<br />")));
    assertThat(node, hasJsonPath("$.preview", containsString(check.getTarget())));

    verify(mockSeyrenConfig).getGraphiteUrl();
    verify(mockSeyrenConfig).getBaseUrl();

}

From source file:org.openvpms.archetype.rules.supplier.OrderGeneratorTestCase.java

/**
 * Sets up the test case.//w w  w.  j  a  v a2  s.  com
 */
@Before
public void setUp() {
    super.setUp();
    Party practice = (Party) create(PracticeArchetypes.PRACTICE);
    gst = TestHelper.createTaxType(BigDecimal.TEN);
    practice.addClassification(gst);
    taxRules = new TaxRules(practice, getArchetypeService(), getLookupService());
}

From source file:fakingXmocking.CurrencyConversionHttpClientFake.java

private BigDecimal findConversionRate(String from, String to) {
    BigDecimal rate = currenciesAndRates.get(from + '>' + to);

    if (rate != null) {
        return rate;
    }/* www. j  a v a2s  .c o m*/

    // Special cases:
    if (from.equals(to)) {
        rate = BigDecimal.ONE;
    } else if ("USD".equals(from) && "CNY".equals(to)) {
        rate = BigDecimal.TEN;
    } else if ("CNY".equals(from) && "USD".equals(to)) {
        rate = new BigDecimal("0.1");
    } else {
        rate = DEFAULT_RATE;
    }

    return rate;
}

From source file:com.redhat.lightblue.metadata.types.BigDecimalTypeTest.java

@Test
public void testCastBigDecimal() {
    assertTrue(bigDecimalType.cast(BigDecimal.TEN) instanceof BigDecimal);
}

From source file:cz.muni.fi.pa165.legomanager.dao.LegoKitDaoImplTest.java

@Test(expected = DataAccessException.class)
public void addLegoRestrictionTestNull() {
    LegoKit legoKit = createLegoKit("StarWars Death Star", BigDecimal.TEN, null, new HashSet<Category>(),
            new ArrayList<LegoPiece>(), new ArrayList<LegoSet>());
    legoKitDao.addLegoKit(legoKit);//from  w ww  .ja  va  2s .  co  m
}

From source file:de.jfachwert.post.PLZ.java

private static void validateNumberWith(String plz, int length, String zahl) {
    LengthValidator.validate(plz, length);
    new NumberValidator(BigDecimal.ZERO, BigDecimal.TEN.pow(length)).validate(zahl);
}

From source file:br.edu.ifrn.conta.servico.LancamentoServicoIT.java

@Test(expected = IllegalArgumentException.class)
public void lancamentoComContaSaidaInvalida() {
    Lancamento lancamento = Lancamento.builder().contaEntrada(this.contaPatrimonioFabrica.poupanca())
            .contaSaida(this.contaDebitoFabrica.gasolina()).valor(BigDecimal.TEN).data(new Date())
            .dono(this.donoFabrica.papai()).build();

    this.lancamentoServico.save(lancamento);
}