Files
spring-boot-rest/libraries/src/test/java/com/baeldung/commons/math/StatisticsUnitTest.java
Doha2012 48cd6f876f Fix test names (#1853)
* upgrade to spring boot 1.5.2

* add full update to REST API

* modify ratings controller

* upgrade herold

* fix integration test

* fix integration test

* minor fix

* fix integration test

* fix integration test

* minor cleanup

* minor cleanup

* remove log4j properties

* use standard logbook.xml

* remove log4j dependencies

* remove commons-logging

* merge

* fix conflict

* exclude commons-logging dependency

* cleanup

* minor fix

* minor fix

* fix dependency issues

* Revert "fix dependency issues"

This reverts commit 83bf1f9fd2.

* fix dependency issues

* minor fix

* minor fix

* minor fix

* cleanup generated files

* fix commons-logging issue

* add parent to pom

* cleanup parent dependencies

* cleanup pom

* cleanup pom

* add missing parent

* fix logging issue

* fix test names
2017-05-15 11:35:14 -05:00

39 lines
1.1 KiB
Java

package com.baeldung.commons.math;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class StatisticsUnitTest {
private double[] values;
private DescriptiveStatistics descriptiveStatistics;
@Before
public void setUp() {
values = new double[] {65, 51 , 16, 11 , 6519, 191 ,0 , 98, 19854, 1, 32};
descriptiveStatistics = new DescriptiveStatistics();
for(double v : values) {
descriptiveStatistics.addValue(v);
}
}
@Test
public void whenDescriptiveStatisticsGetMean_thenCorrect() {
Assert.assertEquals(2439.8181818181815, descriptiveStatistics.getMean(), 1e-7);
}
@Test
public void whenDescriptiveStatisticsGetMedian_thenCorrect() {
Assert.assertEquals(51, descriptiveStatistics.getPercentile(50), 1e-7);
}
@Test
public void whenDescriptiveStatisticsGetStandardDeviation_thenCorrect() {
Assert.assertEquals(6093.054649651221, descriptiveStatistics.getStandardDeviation(), 1e-7);
}
}