@@ -37,6 +37,7 @@ public class TPStatisticTest {
37
37
38
38
@ Test
39
39
public void testName () {
40
+ Assert .assertEquals ("tp75" , TP75_STATISTIC .getName ());
40
41
Assert .assertEquals ("tp90" , TP90_STATISTIC .getName ());
41
42
Assert .assertEquals ("tp95" , TP95_STATISTIC .getName ());
42
43
Assert .assertEquals ("tp99" , TP99_STATISTIC .getName ());
@@ -96,6 +97,10 @@ public void testTP999Stat() {
96
97
97
98
@ Test
98
99
public void testEquality () {
100
+ Assert .assertFalse (TP75_STATISTIC .equals (null ));
101
+ Assert .assertFalse (TP75_STATISTIC .equals ("ABC" ));
102
+ Assert .assertTrue (TP75_STATISTIC .equals (TP75_STATISTIC ));
103
+
99
104
Assert .assertFalse (TP90_STATISTIC .equals (null ));
100
105
Assert .assertFalse (TP90_STATISTIC .equals ("ABC" ));
101
106
Assert .assertTrue (TP90_STATISTIC .equals (TP90_STATISTIC ));
@@ -115,12 +120,24 @@ public void testEquality() {
115
120
116
121
@ Test
117
122
public void testHashCode () {
123
+ Assert .assertEquals (TP75_STATISTIC .hashCode (), TP75_STATISTIC .hashCode ());
118
124
Assert .assertEquals (TP90_STATISTIC .hashCode (), TP90_STATISTIC .hashCode ());
119
125
Assert .assertEquals (TP95_STATISTIC .hashCode (), TP95_STATISTIC .hashCode ());
120
126
Assert .assertEquals (TP99_STATISTIC .hashCode (), TP99_STATISTIC .hashCode ());
121
127
Assert .assertEquals (TP99P9_STATISTIC .hashCode (), TP99P9_STATISTIC .hashCode ());
122
128
}
123
129
130
+ @ Test
131
+ public void testTP75Accumulator () {
132
+ final Accumulator <?> accumulator = (Accumulator <?>) HISTOGRAM_STATISTIC .createCalculator ();
133
+ for (int x = 1 ; x <= 10000 ; ++x ) {
134
+ accumulator .accumulate (new Quantity .Builder ().setValue ((double ) x ).build ());
135
+ }
136
+ final CalculatedValue <Void > calculated = TP75_STATISTIC .createCalculator ().calculate (
137
+ Collections .singletonMap (HISTOGRAM_STATISTIC , accumulator ));
138
+ Assert .assertTrue (areClose (new Quantity .Builder ().setValue (7500.0 ).build (), calculated .getValue ()));
139
+ }
140
+
124
141
@ Test
125
142
public void testTP90Accumulator () {
126
143
final Accumulator <?> accumulator = (Accumulator <?>) HISTOGRAM_STATISTIC .createCalculator ();
@@ -186,6 +203,7 @@ private boolean areClose(final Quantity expected, final Quantity actual) {
186
203
private static final List <Double > ONE_TO_FIVE = Lists .newArrayList (1d , 2d , 3d , 4d , 5d );
187
204
private static final StatisticFactory STATISTIC_FACTORY = new StatisticFactory ();
188
205
private static final Statistic HISTOGRAM_STATISTIC = STATISTIC_FACTORY .getStatistic ("histogram" );
206
+ private static final TP75Statistic TP75_STATISTIC = (TP75Statistic ) STATISTIC_FACTORY .getStatistic ("tp75" );
189
207
private static final TP90Statistic TP90_STATISTIC = (TP90Statistic ) STATISTIC_FACTORY .getStatistic ("tp90" );
190
208
private static final TP95Statistic TP95_STATISTIC = (TP95Statistic ) STATISTIC_FACTORY .getStatistic ("tp95" );
191
209
private static final TP99Statistic TP99_STATISTIC = (TP99Statistic ) STATISTIC_FACTORY .getStatistic ("tp99" );
0 commit comments