Search in sources :

Example 1 with ResultData

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;
}
Also used : MapResultData(org.apache.jmeter.report.processor.MapResultData) ValueResultData(org.apache.jmeter.report.processor.ValueResultData) ResultData(org.apache.jmeter.report.processor.ResultData) MapResultData(org.apache.jmeter.report.processor.MapResultData)

Example 2 with ResultData

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));
    }
}
Also used : ListResultData(org.apache.jmeter.report.processor.ListResultData) MapResultData(org.apache.jmeter.report.processor.MapResultData) ValueResultData(org.apache.jmeter.report.processor.ValueResultData) ResultData(org.apache.jmeter.report.processor.ResultData)

Example 3 with ResultData

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));
    }
}
Also used : ListResultData(org.apache.jmeter.report.processor.ListResultData) MapResultData(org.apache.jmeter.report.processor.MapResultData) ValueResultData(org.apache.jmeter.report.processor.ValueResultData) ResultData(org.apache.jmeter.report.processor.ResultData)

Example 4 with ResultData

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;
}
Also used : MapResultData(org.apache.jmeter.report.processor.MapResultData) ValueResultData(org.apache.jmeter.report.processor.ValueResultData) ResultData(org.apache.jmeter.report.processor.ResultData) ValueResultData(org.apache.jmeter.report.processor.ValueResultData)

Example 5 with ResultData

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\""));
        }
    }
}
Also used : MapResultData(org.apache.jmeter.report.processor.MapResultData) ResultData(org.apache.jmeter.report.processor.ResultData) JsonizerVisitor(org.apache.jmeter.report.dashboard.JsonizerVisitor) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

MapResultData (org.apache.jmeter.report.processor.MapResultData)5 ResultData (org.apache.jmeter.report.processor.ResultData)5 ValueResultData (org.apache.jmeter.report.processor.ValueResultData)4 ListResultData (org.apache.jmeter.report.processor.ListResultData)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JsonizerVisitor (org.apache.jmeter.report.dashboard.JsonizerVisitor)1 Test (org.junit.jupiter.api.Test)1