Java Code Examples for org.apache.jmeter.testelement.property.CollectionProperty#get()

The following examples show how to use org.apache.jmeter.testelement.property.CollectionProperty#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrometheusMetricsConfig.java    From jmeter-prometheus-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object o) {
	if (o instanceof PrometheusMetricsConfig) {
		PrometheusMetricsConfig other = (PrometheusMetricsConfig) o;
		
		CollectionProperty thisConfig = this.getCollectorConfigs();
		CollectionProperty otherConfig = other.getCollectorConfigs();
		boolean sameSize = thisConfig.size() == otherConfig.size();
		
		for (int i = 0; i < thisConfig.size(); i++) {
			JMeterProperty left = thisConfig.get(i);
			JMeterProperty right = otherConfig.get(i);
			
			if(!left.equals(right)) {
				return false;
			}
		}
		
		return true && sameSize;
	}
	
	return false;
}
 
Example 2
Source File: WeightedSwitchController.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private CollectionProperty removeDisableSubGroups(CollectionProperty data) {
    CollectionProperty result = new CollectionProperty();
    for (int i = 0; i < data.size(); i++) {
        JMeterProperty property = data.get(i);
        if (property instanceof CollectionProperty &&
                ((CollectionProperty) property).size() == 3 &&
                "true".equals(((CollectionProperty) property).get(2).getStringValue())) {
            result.addProperty(property);
        }
    }
    return result;
}
 
Example 3
Source File: WeightedSwitchController.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private CollectionProperty setEnabledSubGroups(CollectionProperty data) {
    for (int i = 0; i < data.size(); i++) {
        JMeterProperty property = data.get(i);
        if (property instanceof CollectionProperty) {
            CollectionProperty prop = (CollectionProperty) property;
            if (prop.size() == 2) {
                prop.addItem("true");
            }
        }
    }

    setProperty(data);
    return data;
}
 
Example 4
Source File: WeightedSwitchController.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private double[] getWeights(CollectionProperty data) {
    long sum = 0;
    double[] weights = new double[data.size()];
    for (int n = 0; n < data.size(); n++) {
        CollectionProperty row = (CollectionProperty) data.get(n);
        weights[n] = Long.parseLong(row.get(1).getStringValue());
        sum += weights[n];
    }

    for (int n = 0; n < weights.length; n++) {
        weights[n] /= sum;
    }
    //log.info("Weights: " + Arrays.toString(weights));
    return weights;
}
 
Example 5
Source File: WeightedSwitchControllerGui.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private JMeterProperty getRowByName(String rowName, CollectionProperty oldData) {
    for (int i = 0; i <  oldData.size(); i++) {
        JMeterProperty row = oldData.get(i);
        if (row instanceof CollectionProperty && rowName.equals(((CollectionProperty) row).get(0).getStringValue())) {
            return row;
        }
    }
    return null;
}