@@ -34,6 +34,7 @@ public class TPStatisticTest {
34
34
35
35
@ Test
36
36
public void testName () {
37
+ Assert .assertEquals ("tp75" , TP75_STATISTIC .getName ());
37
38
Assert .assertEquals ("tp90" , TP90_STATISTIC .getName ());
38
39
Assert .assertEquals ("tp95" , TP95_STATISTIC .getName ());
39
40
Assert .assertEquals ("tp99" , TP99_STATISTIC .getName ());
@@ -42,6 +43,10 @@ public void testName() {
42
43
43
44
@ Test
44
45
public void testEquality () {
46
+ Assert .assertFalse (TP75_STATISTIC .equals (null ));
47
+ Assert .assertFalse (TP75_STATISTIC .equals ("ABC" ));
48
+ Assert .assertTrue (TP75_STATISTIC .equals (TP75_STATISTIC ));
49
+
45
50
Assert .assertFalse (TP90_STATISTIC .equals (null ));
46
51
Assert .assertFalse (TP90_STATISTIC .equals ("ABC" ));
47
52
Assert .assertTrue (TP90_STATISTIC .equals (TP90_STATISTIC ));
@@ -61,12 +66,24 @@ public void testEquality() {
61
66
62
67
@ Test
63
68
public void testHashCode () {
69
+ Assert .assertEquals (TP75_STATISTIC .hashCode (), TP75_STATISTIC .hashCode ());
64
70
Assert .assertEquals (TP90_STATISTIC .hashCode (), TP90_STATISTIC .hashCode ());
65
71
Assert .assertEquals (TP95_STATISTIC .hashCode (), TP95_STATISTIC .hashCode ());
66
72
Assert .assertEquals (TP99_STATISTIC .hashCode (), TP99_STATISTIC .hashCode ());
67
73
Assert .assertEquals (TP99P9_STATISTIC .hashCode (), TP99P9_STATISTIC .hashCode ());
68
74
}
69
75
76
+ @ Test
77
+ public void testTP75Accumulator () {
78
+ final Accumulator <?> accumulator = (Accumulator <?>) HISTOGRAM_STATISTIC .createCalculator ();
79
+ for (int x = 1 ; x <= 10000 ; ++x ) {
80
+ accumulator .accumulate (new Quantity .Builder ().setValue ((double ) x ).build ());
81
+ }
82
+ final CalculatedValue <Void > calculated = TP75_STATISTIC .createCalculator ().calculate (
83
+ Collections .singletonMap (HISTOGRAM_STATISTIC , accumulator ));
84
+ Assert .assertTrue (areClose (new Quantity .Builder ().setValue (7500.0 ).build (), calculated .getValue ()));
85
+ }
86
+
70
87
@ Test
71
88
public void testTP90Accumulator () {
72
89
final Accumulator <?> accumulator = (Accumulator <?>) HISTOGRAM_STATISTIC .createCalculator ();
@@ -132,6 +149,7 @@ private boolean areClose(final Quantity expected, final Quantity actual) {
132
149
private static final List <Double > ONE_TO_FIVE = Lists .newArrayList (1d , 2d , 3d , 4d , 5d );
133
150
private static final StatisticFactory STATISTIC_FACTORY = new StatisticFactory ();
134
151
private static final Statistic HISTOGRAM_STATISTIC = STATISTIC_FACTORY .getStatistic ("histogram" );
152
+ private static final TP75Statistic TP75_STATISTIC = (TP75Statistic ) STATISTIC_FACTORY .getStatistic ("tp75" );
135
153
private static final TP90Statistic TP90_STATISTIC = (TP90Statistic ) STATISTIC_FACTORY .getStatistic ("tp90" );
136
154
private static final TP95Statistic TP95_STATISTIC = (TP95Statistic ) STATISTIC_FACTORY .getStatistic ("tp95" );
137
155
private static final TP99Statistic TP99_STATISTIC = (TP99Statistic ) STATISTIC_FACTORY .getStatistic ("tp99" );
0 commit comments