You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2017/11/25 17:23:32 UTC
svn commit: r1816333 - in /jmeter/trunk:
src/core/org/apache/jmeter/report/processor/ApdexSummaryConsumer.java
test/src/org/apache/jmeter/report/processor/ApdexSummaryConsumerSpec.groovy
Author: fschumacher
Date: Sat Nov 25 17:23:32 2017
New Revision: 1816333
URL: http://svn.apache.org/viewvc?rev=1816333&view=rev
Log:
More unit tests and a bit of simplification plus removal of useless javadoc.
This closes #332 from github
Contributed by Graham Russell
Added:
jmeter/trunk/test/src/org/apache/jmeter/report/processor/ApdexSummaryConsumerSpec.groovy (with props)
Modified:
jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryConsumer.java
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryConsumer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryConsumer.java?rev=1816333&r1=1816332&r2=1816333&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryConsumer.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryConsumer.java Sat Nov 25 17:23:32 2017
@@ -17,6 +17,7 @@
*/
package org.apache.jmeter.report.processor;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.jmeter.report.core.Sample;
import org.apache.jmeter.util.JMeterUtils;
@@ -38,21 +39,10 @@ public class ApdexSummaryConsumer extend
private ThresholdSelector thresholdSelector;
- /**
- * Gets the APDEX threshold selector.
- *
- * @return the threshold selector
- */
public final ThresholdSelector getThresholdSelector() {
return thresholdSelector;
}
- /**
- * Sets the APDEX threshold selector.
- *
- * @param thresholdSelector
- * the APDEX threshold selector to set
- */
public final void setThresholdSelector(ThresholdSelector thresholdSelector) {
this.thresholdSelector = thresholdSelector;
}
@@ -63,16 +53,18 @@ public class ApdexSummaryConsumer extend
@Override
protected ListResultData createDataResult(String key, ApdexSummaryData data) {
- ListResultData result = new ListResultData();
- result.addResult(new ValueResultData(Double.valueOf(getApdex(data))));
+ Double apdex = Double.valueOf(getApdex(data));
ApdexThresholdsInfo thresholdsInfo = data.getApdexThresholdInfo();
- result.addResult(new ValueResultData(Long.valueOf(thresholdsInfo
- .getSatisfiedThreshold())));
- result.addResult(new ValueResultData(Long.valueOf(thresholdsInfo
- .getToleratedThreshold())));
- result.addResult(new ValueResultData(key != null ? key : JMeterUtils
- .getResString("reportgenerator_summary_total")));
+ Long satisfiedThreshold = Long.valueOf(thresholdsInfo.getSatisfiedThreshold());
+ Long toleratedThreshold = Long.valueOf(thresholdsInfo.getToleratedThreshold());
+ String keyOrDefault = ObjectUtils.defaultIfNull(
+ key, JMeterUtils.getResString("reportgenerator_summary_total"));
+ ListResultData result = new ListResultData();
+ result.addResult(new ValueResultData(apdex));
+ result.addResult(new ValueResultData(satisfiedThreshold));
+ result.addResult(new ValueResultData(toleratedThreshold));
+ result.addResult(new ValueResultData(keyOrDefault));
return result;
}
Added: jmeter/trunk/test/src/org/apache/jmeter/report/processor/ApdexSummaryConsumerSpec.groovy
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/report/processor/ApdexSummaryConsumerSpec.groovy?rev=1816333&view=auto
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/report/processor/ApdexSummaryConsumerSpec.groovy (added)
+++ jmeter/trunk/test/src/org/apache/jmeter/report/processor/ApdexSummaryConsumerSpec.groovy Sat Nov 25 17:23:32 2017
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jmeter.report.processor
+
+import spock.lang.Specification
+
+class ApdexSummaryConsumerSpec extends Specification {
+
+ def sut = new ApdexSummaryConsumer()
+
+ def "createDataResult contains apdex, satisfied, tolerated, key"() {
+ given:
+ def info = new ApdexThresholdsInfo()
+ info.setSatisfiedThreshold(3L)
+ info.setToleratedThreshold(12L)
+ def data = new ApdexSummaryData(info)
+ data.satisfiedCount = 60L
+ data.toleratedCount = 30L
+ data.totalCount = 100L
+ def expectedApdex = 0.75
+ when:
+ def result = sut.createDataResult("key", data)
+ then:
+ def resultValues = result.asList().collect {
+ ((ValueResultData) it).value
+ }
+ // [apdex, satisfied, tolerated, key]
+ resultValues == [expectedApdex, 3L, 12L, "key"]
+ }
+}
Propchange: jmeter/trunk/test/src/org/apache/jmeter/report/processor/ApdexSummaryConsumerSpec.groovy
------------------------------------------------------------------------------
svn:eol-style = native