All Downloads are FREE. Search and download functionalities are using the official Maven repository.

automation.library.conversion2jmx.common.model.jmx.JmxJsonPostProcessor Maven / Gradle / Ivy

Go to download

The 'conversion2jmx' library to helps creating JMeter JMX files from different sources

The newest version!
package automation.library.conversion2jmx.common.model.jmx;

import automation.library.conversion2jmx.postman2jmx.model.postman.PostmanEvent;
import automation.library.conversion2jmx.postman2jmx.model.postman.PostmanItem;
import org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor;
import org.apache.jmeter.extractor.json.jsonpath.gui.JSONPostProcessorGui;
import org.apache.jmeter.testelement.TestElement;

import java.util.ArrayList;
import java.util.List;

public class JmxJsonPostProcessor {

    public static JSONPostProcessor newInstance(String name) {
        JSONPostProcessor jsonPostProcessor = new JSONPostProcessor();
        jsonPostProcessor.setProperty(TestElement.GUI_CLASS, JSONPostProcessorGui.class.getName());
        jsonPostProcessor.setProperty(TestElement.TEST_CLASS, JSONPostProcessor.class.getName());
        jsonPostProcessor.setEnabled(true);
        jsonPostProcessor.setName(name);
        jsonPostProcessor.setMatchNumbers("0");
        jsonPostProcessor.setRefNames(name);
        jsonPostProcessor.setJsonPathExpressions("." + name);

        return jsonPostProcessor;
    }

    private static List getInstances(List variables) {
        List jsonPostProcessors = new ArrayList<>();
        for (String variable : variables) {
            jsonPostProcessors.add(JmxJsonPostProcessor.newInstance(variable));
        }
        return jsonPostProcessors;

    }

    public static List getJsonPostProcessors(PostmanItem postmanItem) {
        List jsonPostProcessors = new ArrayList<>();
        for (PostmanEvent event : postmanItem.getEvents()) {
            jsonPostProcessors.addAll(JmxJsonPostProcessor.getInstances(event.getVariables()));
        }
        return jsonPostProcessors;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy