use of org.apache.jmeter.report.processor.ResultData in project jmeter by apache.
the class AbstractDataExporter method findData.
/**
* Finds a inner ResultData matching the specified data name in a ResultData
* tree. Supports only MapResultData walking.
*
* @param data
* the name of the data containing the value
* @param root
* the root of the tree
* @return the ResultData matching the data name
*/
protected static ResultData findData(String data, ResultData root) {
String[] pathItems = StringUtils.split(data, '.');
if (pathItems == null || !(root instanceof MapResultData)) {
return null;
}
ResultData result = null;
int count = pathItems.length;
int index = 0;
MapResultData map = (MapResultData) root;
while (index < count && result == null) {
ResultData current = map.getResult(pathItems[index]);
if (index == count - 1) {
result = current;
} else {
if (current instanceof MapResultData) {
map = (MapResultData) current;
index++;
}
}
}
return result;
}
use of org.apache.jmeter.report.processor.ResultData in project jmeter by apache.
the class HtmlTemplateExporter method addResultToContext.
private <T> void addResultToContext(String resultKey, Map<String, Object> storage, DataContext dataContext, ResultDataVisitor<T> visitor, ResultCustomizer customizer, ResultChecker checker) {
Object data = storage.get(resultKey);
if (data instanceof ResultData) {
ResultData result = (ResultData) data;
if (checker != null) {
checker.checkResult(dataContext, result);
}
if (customizer != null) {
result = customizer.customizeResult(result);
}
dataContext.put(resultKey, result.accept(visitor));
}
}
use of org.apache.jmeter.report.processor.ResultData in project jmeter by apache.
the class HtmlTemplateExporter method addResultToContext.
private <TVisit> void addResultToContext(String resultKey, Map<String, Object> storage, DataContext dataContext, ResultDataVisitor<TVisit> visitor, ResultCustomizer customizer, ResultChecker checker) {
Object data = storage.get(resultKey);
if (data instanceof ResultData) {
ResultData result = (ResultData) data;
if (checker != null) {
checker.checkResult(dataContext, result);
}
if (customizer != null) {
result = customizer.customizeResult(result);
}
dataContext.put(resultKey, result.accept(visitor));
}
}
use of org.apache.jmeter.report.processor.ResultData in project jmeter by apache.
the class AbstractDataExporter method findValue.
/**
* Finds a value matching the specified data name in a ResultData tree.
* Supports only MapResultData walking.
*
* @param clazz
* the type of the value
* @param data
* the name of the data containing the value
* @param root
* the root of the tree
* @param <T>
* type of value to be found
* @return the value matching the data name
*/
protected static <T> T findValue(Class<T> clazz, String data, ResultData root) {
T value = null;
ResultData result = findData(data, root);
if (result instanceof ValueResultData) {
ValueResultData valueResult = (ValueResultData) result;
Object object = valueResult.getValue();
if (object != null && clazz.isAssignableFrom(object.getClass())) {
value = clazz.cast(object);
}
}
return value;
}
use of org.apache.jmeter.report.processor.ResultData in project jmeter by apache.
the class CustomGraphConsumerTest method testInitializeExtraResults.
@Test
public void testInitializeExtraResults() {
customGraphConsumer.initializeExtraResults(resultData);
JsonizerVisitor jsonizer = new JsonizerVisitor();
for (Map.Entry<String, ResultData> entrySet : resultData.entrySet()) {
Object testedValue = entrySet.getValue().accept(jsonizer);
String key = entrySet.getKey();
if (key.equals("granularity")) {
assertThat(testedValue, equalTo("60000"));
} else if (key.equals("X_Axis")) {
assertThat(testedValue, equalTo("\"X axis name\""));
} else if (key.equals("Y_Axis")) {
assertThat(testedValue, equalTo("\"Y axis name\""));
} else if (key.equals("sample_Metric_Name")) {
assertThat(testedValue, equalTo("\"ulp_lag_ratio\""));
} else if (key.equals("content_Message")) {
assertThat(testedValue, equalTo("\"content message\""));
}
}
}
Aggregations